-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
ignores: ["depcheck"] | ||
ignores: ["fs-iterator", "depcheck", "ts-dev-stack", "@types/*"] |
This file was deleted.
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
version: 2 | ||
updates: | ||
- package-ecosystem: npm | ||
directory: '/' | ||
schedule: | ||
interval: daily | ||
ignore: | ||
- dependency-name: 'rimraf' | ||
- package-ecosystem: 'github-actions' | ||
directory: '/' | ||
schedule: | ||
# Check for updates to GitHub Actions every weekday | ||
interval: 'daily' |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
name: CI | ||
on: | ||
push: | ||
branches: | ||
- master | ||
jobs: | ||
test: | ||
name: Node.js ${{ matrix.node-version }} ${{ matrix.os }} | ||
runs-on: ${{ matrix.os }} | ||
strategy: | ||
matrix: | ||
node: ['20'] | ||
os: [ubuntu-latest, windows-latest, macos-latest] | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: actions/setup-node@v4 | ||
with: | ||
node-version: ${{ matrix.node-version }} | ||
- run: git config --global user.name "Github Actions" | ||
- run: git config --global user.email "[email protected]" | ||
- run: npm uninstall node-version-use -g | ||
- run: npm install node-version-use -g | ||
- run: npm ci | ||
- run: npm run format | ||
- run: npm run build | ||
- run: npm run test:engines |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,6 @@ | ||
.DS_Store | ||
.tmp/ | ||
node_modules/ | ||
package-lock.json | ||
data/ | ||
*.heapsnapshot | ||
*.0x |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
{ | ||
"upgrade": true, | ||
"reject": ["rimraf"] | ||
} |
This file was deleted.
This file was deleted.
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
{ | ||
"$schema": "https://biomejs.dev/schemas/1.5.3/schema.json", | ||
"files": { | ||
"ignore": ["assets/**", "dist/**", "node_modules/**", "test/data/**"] | ||
}, | ||
"formatter": { | ||
"enabled": true, | ||
"lineWidth": 320, | ||
"indentStyle": "space" | ||
}, | ||
"javascript": { | ||
"formatter": { | ||
"quoteStyle": "single", | ||
"trailingComma": "es5" | ||
} | ||
}, | ||
"linter": { | ||
"enabled": true, | ||
"rules": { | ||
"recommended": true, | ||
"complexity": { | ||
"noForEach": "off", | ||
"useOptionalChain": "off" | ||
}, | ||
"correctness": { | ||
"noUnusedVariables": "warn", | ||
"noInnerDeclarations": "off" | ||
}, | ||
"style": { | ||
"noParameterAssign": "off" | ||
} | ||
} | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
var Iterator = require('.') | ||
|
||
var i = 0; | ||
|
||
var iterator = new Iterator('/Users/kevin'); | ||
iterator.forEach((entry) => { if(i++%1000===0) console.log(entry.fullPath); }, { concurrency: Infinity }, function(err) { | ||
console.log('DONE') | ||
}) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
"use strict"; | ||
function _instanceof(left, right) { | ||
if (right != null && typeof Symbol !== "undefined" && right[Symbol.hasInstance]) { | ||
return !!right[Symbol.hasInstance](left); | ||
} else { | ||
return left instanceof right; | ||
} | ||
} | ||
var inherits = require("inherits"); | ||
var StackBaseIterator = require("stack-base-iterator"); | ||
var fs = require("fs"); | ||
var path = require("path"); | ||
var PathStack = require("./PathStack"); | ||
var fifoRemove = require("./fifoRemove"); | ||
var fsCompat = require("./fs-compat"); | ||
var lifoFromArray = require("./lifoFromArray"); | ||
function FSIterator(root, options) { | ||
var _this = this; | ||
if (!_instanceof(this, FSIterator)) return new FSIterator(root, options); | ||
StackBaseIterator.call(this, options); | ||
options = options || {}; | ||
if (this.options.depth === undefined) this.options.depth = Infinity; | ||
this.options.readdir = { | ||
encoding: "utf8", | ||
withFileTypes: fs.Dirent && !options.alwaysStat | ||
}; | ||
this.options.stat = { | ||
bigint: process.platform === "win32" | ||
}; | ||
this.options.error = options.error || function defaultError(err) { | ||
return ~FSIterator.EXPECTED_ERRORS.indexOf(err.code); // skip known issues | ||
}; | ||
this.root = path.resolve(root); | ||
this.stack = new PathStack(); | ||
var cancelled = false; | ||
function setup() { | ||
cancelled = true; | ||
} | ||
this.processing.push(setup); | ||
fsCompat.readdir(this.root, this.options.readdir, function(err, files) { | ||
fifoRemove(_this.processing, setup); | ||
if (_this.done || cancelled) return; | ||
if (err) return _this.end(err); | ||
if (files.length) _this.push({ | ||
path: null, | ||
depth: 0, | ||
files: lifoFromArray(files) | ||
}); | ||
}); | ||
} | ||
inherits(FSIterator, StackBaseIterator); | ||
FSIterator.EXPECTED_ERRORS = [ | ||
"ENOENT", | ||
"EPERM", | ||
"EACCES", | ||
"ELOOP" | ||
]; | ||
module.exports = FSIterator; | ||
|
||
if ((typeof exports.default === 'function' || (typeof exports.default === 'object' && exports.default !== null)) && typeof exports.default.__esModule === 'undefined') { | ||
Object.defineProperty(exports.default, '__esModule', { value: true }); | ||
for (var key in exports) exports.default[key] = exports[key]; | ||
module.exports = exports.default; | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
"use strict"; | ||
var FIFO = require("fifo"); | ||
var depthFirst = require("./depthFirst"); | ||
function PathStack() { | ||
this.stack = new FIFO(); | ||
this.length = 0; | ||
} | ||
PathStack.prototype.push = function push(item) { | ||
if (!item) throw new Error("item is mandatory"); | ||
if (item.files && !item.files.length) throw new Error("item files must have a length"); | ||
this.stack.push(item); | ||
this.length += item.files ? item.files.length : 1; | ||
return this; | ||
}; | ||
PathStack.prototype.pop = function pop() { | ||
if (!this.stack.length) throw new Error("Stack is empty"); | ||
var item = this.stack.last(); | ||
this.length--; | ||
// just a simple item | ||
if (!item.files) return depthFirst.bind(null, this.stack.pop()); | ||
// resuse this item | ||
if (item.files.length > 1) return depthFirst.bind(null, { | ||
path: item.path, | ||
basename: item.files.pop(), | ||
depth: item.depth | ||
}); | ||
// done with this item | ||
item.basename = item.files.pop(); | ||
return depthFirst.bind(null, this.stack.pop()); | ||
}; | ||
PathStack.prototype.last = function last() { | ||
return this.stack.last(); | ||
}; | ||
module.exports = PathStack; | ||
|
||
if ((typeof exports.default === 'function' || (typeof exports.default === 'object' && exports.default !== null)) && typeof exports.default.__esModule === 'undefined') { | ||
Object.defineProperty(exports.default, '__esModule', { value: true }); | ||
for (var key in exports) exports.default[key] = exports[key]; | ||
module.exports = exports.default; | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
"use strict"; | ||
var sep = require("path").sep; | ||
function join(left, right) { | ||
if (!left) return right || ""; | ||
if (!right) return left; | ||
return left + sep + right; | ||
} | ||
module.exports = function createEntry(iterator, item) { | ||
var entry = {}; | ||
if (item.basename.name) { | ||
entry.basename = item.basename.name; | ||
entry.stats = item.basename; | ||
} else { | ||
entry.basename = item.basename; | ||
} | ||
entry.path = join(item.path, entry.basename); | ||
entry.fullPath = join(iterator.root, entry.path); | ||
return entry; | ||
}; | ||
|
||
if ((typeof exports.default === 'function' || (typeof exports.default === 'object' && exports.default !== null)) && typeof exports.default.__esModule === 'undefined') { | ||
Object.defineProperty(exports.default, '__esModule', { value: true }); | ||
for (var key in exports) exports.default[key] = exports[key]; | ||
module.exports = exports.default; | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
"use strict"; | ||
var compat = require("async-compat"); | ||
module.exports = function filter(iterator, entry, callback) { | ||
if (!iterator.options.filter) return callback(null, true); | ||
compat.asyncFunction(iterator.options.filter, iterator.options.callbacks, entry, function filterCallback(err, keep) { | ||
if (err) return callback(err); | ||
if (!compat.defaultValue(keep, true)) return callback(); | ||
callback(null, true); | ||
}); | ||
}; | ||
|
||
if ((typeof exports.default === 'function' || (typeof exports.default === 'object' && exports.default !== null)) && typeof exports.default.__esModule === 'undefined') { | ||
Object.defineProperty(exports.default, '__esModule', { value: true }); | ||
for (var key in exports) exports.default[key] = exports[key]; | ||
module.exports = exports.default; | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
"use strict"; | ||
var createEntry = require("./createEntry"); | ||
var filter = require("./filter"); | ||
var stat = require("./stat"); | ||
var fsCompat = require("../fs-compat"); | ||
var lifoFromArray = require("../lifoFromArray"); | ||
function isDirectory(entry) { | ||
if (entry.realStats) return entry.realStats.isDirectory(); | ||
return entry.stats.isDirectory(); | ||
} | ||
module.exports = function path(item, iterator, callback) { | ||
var depth = item.depth; | ||
var entry = createEntry(iterator, item); | ||
item = null; // release reference | ||
stat(iterator, entry, function statCallback(err) { | ||
if (err || iterator.done) return callback(err); | ||
filter(iterator, entry, function filterCallback(err, keep) { | ||
if (err || !keep || iterator.done) return callback(err); | ||
// not a directory or is a directory, but next level is too deep | ||
if (!isDirectory(entry) || depth + 1 > iterator.options.depth) return callback(null, entry); | ||
// get files in this directory | ||
fsCompat.readdir(entry.fullPath, iterator.options.readdir, function readdirCallback(err, files) { | ||
if (err || iterator.done) return callback(err); | ||
if (files.length) iterator.push({ | ||
path: entry.path, | ||
depth: depth + 1, | ||
files: lifoFromArray(files) | ||
}); | ||
return callback(null, entry); | ||
}); | ||
}); | ||
}); | ||
}; | ||
|
||
if ((typeof exports.default === 'function' || (typeof exports.default === 'object' && exports.default !== null)) && typeof exports.default.__esModule === 'undefined') { | ||
Object.defineProperty(exports.default, '__esModule', { value: true }); | ||
for (var key in exports) exports.default[key] = exports[key]; | ||
module.exports = exports.default; | ||
} |