@0xdd/fs-walk 中文文档教程
fs-walk
用于 Node.js 的基于生成器的轻量级内存高效递归目录遍历。
Installation
npm: npm install @0xdd/fs-walk
纱线: yarn add @0xdd/fs-walk
pnpm: pnpm add @0xdd/fs-walk
Usage
import { walk, walkSync } from '@0xdd/fs-walk';
(async () => {
for await (const i of walk('.')) {
console.log(i);
}
})();
for (const i of walkSync('.', { skip: [/node_modules/, /\.git/] })) {
console.log(i.path);
}
Motivation
fs.readdir
不对目录树进行递归遍历。 由于递归限制,在线提供的解决方案有时无法处理大型目录。
License
walk 的Apache-2.0
Attribution
文档和界面改编自 Go 版权所有 2009 Go 作者。 版权所有。 BSD 许可证。
受 Deno 启发的 TypeScript 界面 版权所有 2018-2021 Deno 作者。
fs-walk
A generator-based lightweight memory efficient recursive directory walk for Node.js.
Installation
npm: npm install @0xdd/fs-walk
yarn: yarn add @0xdd/fs-walk
pnpm: pnpm add @0xdd/fs-walk
Usage
import { walk, walkSync } from '@0xdd/fs-walk';
(async () => {
for await (const i of walk('.')) {
console.log(i);
}
})();
for (const i of walkSync('.', { skip: [/node_modules/, /\.git/] })) {
console.log(i.path);
}
Motivation
fs.readdir
does not do recursive traversal of directory tree. The solutions available online sometimes fail to work on large directories due to recursion limits.
License
Apache-2.0
Attribution
Documentation and interface for walk were adapted from Go Copyright 2009 The Go Authors. All rights reserved. BSD license.
TypeScript interface inspired by Deno Copyright 2018-2021 the Deno authors.