@dazl/fs-utils

中文文档
18.10.0发布于 2026/03/30MITES Module近 30 天下载 1万

Filesystem utils, usable in all environments

原始使用文档
文档目录4 节
  1. fs-utils package
  2. Functions
  3. Interfaces
  4. Variables

npm version @dazl/fs-utils on Github

Home > @dazl/fs-utils

fs-utils package

Functions

FunctionDescription
addRelativePrefix(path)
createImportPath({ importedFilePath, targetFilePath, targetPackageJsonPath, fs, })Returns relative import path if imported and target files are in the same package, otherwise returns a bare import specifier.
formatToOSpaths(str)
getBareImportSpecifier(absoluteImportPath, packageJsonPath, packageJsonName)Creates bare import specifier for an absolute import path, stripping extension from JS/TS files.
getDTSPath(filePath)
getFullExtname(filePath)Returns file extension from the first occurrence of the ".", unlike path.extname() which returns from the last occurrence.
getImportPath(filePath)
getPackageJsonPath(filePath, fs)Gets path to package.json file closest to the given file path.
getPackageName(dirPath, fs)Gets package name.
getPackagePath(filePath, fs)Gets path to package directory, closest to the given file path.
getRelativeImportPath(sourceFilePath, filePathToImport)Creates relative import path for a file, stripping extension from JS/TS files.
getRelativeModulePath(sourceAbsFilePath, targetAbsFilePath)
isDirPath(filePath)
isJavaScriptFile(filePath)
isJsonFile(filePath)
isPathIncludesDir(filePath, directoryName)Safely checks if a path contains a directory name.
isRelativeModulePath(path)
isRelativeModuleRequest(request)
isSubPath(path, basePath, fs)Checks if a path is equal to or subpath of a given base path.
isTsOrJS(filePath)
isTypeAffectingFileOrDir(filePath)
isTypeScriptFile(filePath)
isWindowsStyleAbsolutePath(fsPath)
pathChainToRoot(currentPath)
pathToTrueCase(fs, path)Returns case-exact absolute form of the path, similar to fs.realpathSync.native() Trailing segments of the path that don't exist are left unchanged.
readPackageJson(dirPath, fs)Read and parse a directory's package.json
rebaseRelativeModulePath(filePath, modulePath)
replaceWinSlashes(str)

Interfaces

InterfaceDescription
AdjustRelativeImportPathArgs
CreateImportPathArgs

Variables

VariableDescription
fileRequestPrefixprefix for file requests in Language server protocol

版本与发布记录

@dazl/fs-utils 共发布 9 个版本,首次发布于 2025/08/28;过去 12 个月发布了 6 个版本。

版本发布日期距今
18.10.0latest2026/03/307 个月前
18.9.02026/03/307 个月前
18.8.02026/03/058 个月前
18.7.02026/01/229 个月前
18.6.12025/12/0111 个月前
18.6.02025/11/2011 个月前

关于 @dazl/fs-utils 的常见问题

@dazl/fs-utils 是什么?

Filesystem utils, usable in all environments

如何安装 @dazl/fs-utils?

在项目目录运行 npm install @dazl/fs-utils,或使用 pnpm add / yarn add / bun add。

@dazl/fs-utils 支持 TypeScript 吗?

该包的 package.json 没有声明类型入口。需要类型提示时,可以在 npm 上查找社区维护的 @types/dazl__fs-utils 是否存在。

@dazl/fs-utils 支持 ESM 还是 CommonJS?

以 ES Module 形式发布,推荐使用 import 引入。在 CommonJS 项目中,Node.js 20.19+ / 22.12+ 可以直接 require() 不含顶层 await 的 ES Module,更早的版本需要改用动态 import()。

@dazl/fs-utils 可以商用吗?

@dazl/fs-utils 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@dazl/fs-utils 的下载量有多少?

根据 npm 官方下载统计,@dazl/fs-utils 在 2026/10/12 – 2026/11/10 这 30 天内被下载 10,075 次,日均约 336 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@dazl/fs-utils 还在维护吗?

最新版本 18.10.0 发布于 2026/03/30(7 个月前);至今共发布 9 个版本,其中过去 12 个月发布了 6 个;首次发布于 2025/08/28。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。