Gathering detailed insights and metrics for klaw-sync
Gathering detailed insights and metrics for klaw-sync
Gathering detailed insights and metrics for klaw-sync
Gathering detailed insights and metrics for klaw-sync
npm install klaw-sync
Module System
Min. Node Version
Typescript Support
Node Version
NPM Version
158 Stars
89 Commits
10 Forks
3 Watching
1 Branches
4 Contributors
Updated on 22 Oct 2024
JavaScript (100%)
Cumulative downloads
Total Downloads
Last day
-8.2%
501,110
Compared to previous day
Last week
1.4%
2,816,135
Compared to previous week
Last month
10%
11,936,031
Compared to previous month
Last year
20.1%
122,731,324
Compared to previous year
klaw-sync
is a Node.js recursive and fast file system walker, which is the synchronous counterpart of klaw. It lists all files and directories inside a directory recursively and returns an array of objects that each object has two properties: path
and stats
. path
is the full path of the file or directory and stats
is an instance of fs.Stats.
npm i klaw-sync
directory
<String>
options
<Object>
(optional)
nodir
<Boolean>
default: undefined
nofile
<Boolean>
default: undefined
depthLimit
: <Number>
default: -1
-1
for unlimited.fs
: <Object>
default: graceful-fs
fs
, useful when mocking fs
object.filter
<Function>
default: undefined
fn({path: '', stats: {}})
and returns true to include or false to exclude the item.traverseAll
<Boolean>
default: undefined
filter
option. This can be useful when you have a filter function and still want to traverse all subdirectories even if your filter function doesn't pass for some directories.<Array<Object>>
[{path: '', stats: {}}]
1const klawSync = require('klaw-sync') 2 3const paths = klawSync('/some/dir') 4// paths = [{path: '/some/dir/dir1', stats: {}}, {path: '/some/dir/file1', stats: {}}]
catch error
1const klawSync = require('klaw-sync') 2 3let paths 4try { 5 paths = klawSync('/some/dir') 6} catch (er) { 7 console.error(er) 8} 9console.dir(paths)
files only
1const klawSync = require('klaw-sync') 2 3const files = klawSync('/some/dir', {nodir: true}) 4// files = [{path: '/some/dir/file1', stats: {}}, {path: '/some/dir/file2', stats: {}}]
directories only
1const klawSync = require('klaw-sync') 2 3const dirs = klawSync('/some/dir', {nofile: true}) 4// dirs = [{path: '/some/dir/dir1', stats: {}}, {path: '/some/dir/dir2', stats: {}}]
ignore hidden directories
1const path = require('path') 2const klawSync = require('klaw-sync') 3 4const filterFn = item => { 5 const basename = path.basename(item.path) 6 return basename === '.' || basename[0] !== '.' 7} 8 9const paths = klawSync('/some/dir', { filter: filterFn})
filter based on stats
Here traverseAll
option is required since we still want to read all subdirectories even if they don't pass the filter
function, to see if their contents do pass the filter
function.
1const klawSync = require('klaw-sync')
2
3const refTime = new Date(2017, 3, 24).getTime()
4const filterFn = item => item.stats.mtime.getTime() > refTime
5
6const paths = klawSync('/some/dir', { traverseAll: true, filter: filterFn })
lint: npm run lint
unit test: npm run unit
lint & unit: npm test
benchmark: npm run benchmark
Running some benchmark tests on these modules:
klaw-sync
(as of Jan 25, 2017) klaw-sync
is the fastest module!
1Running benchmark tests.. 2 3root dir length: 1110 4walk-sync x 80.71 ops/sec ±1.42% (72 runs sampled) 5klaw-sync x 160 ops/sec ±1.17% (79 runs sampled) 6Fastest is klaw-sync 7 8root dir length: 11110 9walk-sync x 7.55 ops/sec ±3.39% (23 runs sampled) 10klaw-sync x 14.95 ops/sec ±0.27% (40 runs sampled) 11Fastest is klaw-sync 12 13root dir length: 111110 14walk-sync x 0.63 ops/sec ±6.92% (6 runs sampled) 15klaw-sync x 1.22 ops/sec ±0.96% (7 runs sampled) 16Fastest is klaw-sync
Licensed under MIT
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
0 existing vulnerabilities detected
Reason
license file detected
Details
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
Found 2/26 approved changesets -- score normalized to 0
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
Reason
project is not fuzzed
Details
Reason
branch protection not enabled on development/release branches
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Score
Last Scanned on 2024-11-18
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More