@wuyuchentr/glob-files
v1.0.0
Published
Fast glob file matching with **, !exclude, and async iteration. Lightweight, zero-dependency.
Maintainers
Readme
@wuyuchentr/glob-files
Fast glob file matching with **, ! exclusion, and async iteration. Zero dependencies, ~100 lines.
10× lighter than
glob(1.6 kB vs 16 kB), with the same core features.
Install
npm install @wuyuchentr/glob-filesUsage
const { glob } = require('@wuyuchentr/glob-files');
// Async iteration — memory friendly
for await (const file of glob('src/**/*.js')) {
console.log(file); // → 'src/index.js', 'src/util/helper.js', ...
}
// Exclude patterns
for await (const file of glob(['src/**/*.js', '!src/vendor/**'])) {
// everything except src/vendor/
}
// Common: exclude node_modules recursively
for await (const file of glob(['**/*.js', '!**/node_modules/**'])) {
// all .js files outside node_modules
}
// Collect all at once
const files = [];
for await (const f of glob('*.md')) files.push(f);Patterns
| Pattern | Matches |
|---------|---------|
| * | any chars except / |
| ** | zero or more directories |
| ? | any single char except / |
| [abc] | any char in set |
| {a,b} | alternative patterns |
| !pattern | exclude matching files |
Options
| Option | Default | Description |
|--------|---------|-------------|
| dotDir | false | Include .-prefixed directories |
