Gathering detailed insights and metrics for tiny-readdir-glob-gitignore
Gathering detailed insights and metrics for tiny-readdir-glob-gitignore
A simple promisified recursive readdir function, with support for globs and .gitignore files.
npm install tiny-readdir-glob-gitignore
Typescript
Module System
Node Version
NPM Version
71.6
Supply Chain
84.2
Quality
81.6
Maintenance
100
Vulnerability
100
License
TypeScript (69.36%)
JavaScript (30.64%)
Total Downloads
1,389
Last Day
3
Last Week
17
Last Month
76
Last Year
1,389
13 Stars
23 Commits
2 Watching
1 Branches
1 Contributors
Minified
Minified + Gzipped
Latest Version
2.0.5
Package Id
tiny-readdir-glob-gitignore@2.0.5
Unpacked Size
25.75 kB
Size
6.47 kB
File Count
15
NPM Version
10.2.3
Node Version
18.19.0
Publised On
20 Jun 2024
Cumulative downloads
Total Downloads
Last day
0%
3
Compared to previous day
Last week
70%
17
Compared to previous week
Last month
-3.8%
76
Compared to previous month
Last year
0%
1,389
Compared to previous year
A simple promisified recursive readdir function, with support for globs and .gitignore
files.
Compared to simply searching for .gitignore
files first, and normal files second, this approach is more efficient because both are searched for simultaneously, meaning that a single folder is entered at most once, and if a folder is discarded by a .gitignore
file it won't be entered at all.
1npm install --save tiny-readdir-glob-gitignore
1import readdir from 'tiny-readdir-glob-gitignore'; 2 3const aborter = new AbortController (); 4 5const result = await readdir ( ['src/**/*.js'], { 6 cwd: process.cwd (), // The root directory to start searching from 7 depth: 20, // Maximum depth to look at 8 limit: 1_000_000, // Maximum number of files explored, useful as a stop gap in some edge cases 9 followSymlinks: true, // Whether to follow symlinks or not 10 ignore: ['**/.git', '**/node_modules'], // Globs, or raw function, that if returns true will ignore this particular file or a directory and its descendants 11 ignoreFiles: ['.gitignore'], // List of .gitignore-like files to look for, defaults to ['.gitignore'] 12 ignoreFilesFindAbove: true, // Whether to look for .gitignore-like files in parent directories also, defaults to true 13 ignoreFilesFindBetween: true, // Whether to look for .gitignore-like files between the "cwd" directory, and the actual search directories, which due to some optimizations could not be the same 14 ignoreFilesStrictly: true, // Whether to strictly follow the rules in .gitignore-like files, even if they exclude the folder you are explicitly searching into, defaults to false 15 signal: aborter.signal, // Optional abort signal, useful for aborting potentially expensive operations 16 onDirents: dirents => console.log ( dirents ) // Optional callback that will be called as soon as new dirents are available, useful for example for discovering ".gitignore" files while searching 17}); 18 19console.log ( result.directories ); // => Array of absolute paths pointing to directories, filtered by the provided glob 20console.log ( result.files ); // => Array of absolute paths pointing to files, filtered by the provided glob 21console.log ( result.symlinks ); // => Array of absolute paths pointing to symlinks, filtered by the provided glob 22 23console.log ( result.directoriesFound ); // => Array of absolute paths pointing to directories, not fully filtered by the provided glob yet 24console.log ( result.filesFound ); // => Array of absolute paths pointing to files, not fully filtered by the provided glob yet 25console.log ( result.symlinksFound ); // => Array of absolute paths pointing to symlinks, not fully filtered by the provided glob yet 26 27console.log ( result.directoriesFoundNames ); // => Set of directories names found 28console.log ( result.filesFoundNames ); // => Set of files name found 29console.log ( result.symlinksFoundNames ); // => Set of symlinks names found 30 31console.log ( result.directoriesFoundNamesToPaths ); // => Record of directories names found to their paths 32console.log ( result.filesFoundNamesToPaths ); // => Record of files name found to their paths 33console.log ( result.symlinksFoundNamesToPaths ); // => Record of symlinks names found to their paths 34 35setTimeout ( () => aborter.abort (), 10000 ); // Aborting if it's going to take longer than 10s
MIT © Fabio Spampinato
No vulnerabilities found.
No security vulnerabilities found.