Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions benchmark/bm.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ const klawSync = require('../klaw-sync.js')

const testDir = path.join(__dirname, 'klaw-sync-benchmark-fixtures')
const paths = [
{dirs: `${testDir}/{0..9}/{0..9}`, files: `${testDir}/{0..9}/{0..9}/{0..9}.txt`}, // 1000 files
{dirs: `${testDir}/{0..9}/{0..9}/{0..9}`, files: `${testDir}/{0..9}/{0..9}/{0..9}/{0..9}.txt`}, // 10,000
{dirs: `${testDir}/{0..9}/{0..9}/{0..9}/{0..9}`, files: `${testDir}/{0..9}/{0..9}/{0..9}/{0..9}/{0..9}.txt`} // 100,000
{ dirs: `${testDir}/{0..9}/{0..9}`, files: `${testDir}/{0..9}/{0..9}/{0..9}.txt` }, // 1000 files
{ dirs: `${testDir}/{0..9}/{0..9}/{0..9}`, files: `${testDir}/{0..9}/{0..9}/{0..9}/{0..9}.txt` }, // 10,000
{ dirs: `${testDir}/{0..9}/{0..9}/{0..9}/{0..9}`, files: `${testDir}/{0..9}/{0..9}/{0..9}/{0..9}/{0..9}.txt` } // 100,000
]

console.log('Running benchmark tests..')
Expand Down
4 changes: 2 additions & 2 deletions klaw-sync.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ function klawSync (dir, opts, ls) {
if (opts.depthLimit > -1) opts.rootDepth = dir.split(path.sep).length + 1
}
const paths = opts.fs.readdirSync(dir).map(p => dir + path.sep + p)
for (var i = 0; i < paths.length; i += 1) {
for (let i = 0; i < paths.length; i += 1) {
const pi = paths[i]
const st = opts.fs.lstatSync(pi)
const item = {path: pi, stats: st}
const item = { path: pi, stats: st }
const isUnderDepthLimit = (!opts.rootDepth || pi.split(path.sep).length - opts.rootDepth < opts.depthLimit)
const filterResult = opts.filter ? opts.filter(item) : true
const isDir = st.isDirectory()
Expand Down
Loading