Comparing version 3.1.1 to 3.2.0
@@ -13,2 +13,15 @@ declare module "fdir" { | ||
type Options = { | ||
includeBasePath: boolean; | ||
includeDirs: boolean; | ||
normalizePath: boolean; | ||
maxDepth: number; | ||
resolvePaths: boolean; | ||
suppressErrors: boolean; | ||
group: boolean; | ||
onlyCounts: boolean; | ||
filter: FilterFn; | ||
exclude: ExcludeFn; | ||
}; | ||
class APIBuilder { | ||
@@ -33,9 +46,4 @@ /** | ||
class Builder { | ||
constructor(options?: Options); | ||
/** | ||
* Create a new Builder fluently. | ||
* Shorthand for: `new Builder()` | ||
*/ | ||
static new(): Builder; | ||
/** | ||
* Prepend base path to all the paths | ||
@@ -62,2 +70,7 @@ */ | ||
/** | ||
* Do not suppress errors | ||
*/ | ||
withErrors(): Builder; | ||
/** | ||
* Group files by directories they are in | ||
@@ -99,3 +112,3 @@ */ | ||
*/ | ||
crawl(): APIBuilder; | ||
crawl(dirPath: string): APIBuilder; | ||
} | ||
@@ -102,0 +115,0 @@ |
{ | ||
"name": "fdir", | ||
"version": "3.1.1", | ||
"version": "3.2.0", | ||
"description": "The fastest directory crawler for NodeJS. Crawls 10k files in 13ms.", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -25,3 +25,3 @@ <p align="center"> | ||
🔥 **All Node Versions Supported:** Unlike other similar libraries that have dropped support for Node versions < 10, `fdir` supports all versions > 6. | ||
🔥 **All Node Versions Supported:** Unlike other similar libraries that have dropped support for Node versions < 10, `fdir` supports all versions >= 6. | ||
@@ -28,0 +28,0 @@ 🖮 **Hackable:** Extending `fdir` is extremely simple now that the new Builder API is here. Feel free to experiment around. |
@@ -31,2 +31,3 @@ const { readdir } = require("../compat/fs"); | ||
walkSingleDir(walk, state, dir, dirents, currentDepth, callback, ...args); | ||
if (--state.queue < 0) callback(null, ...args); | ||
}); | ||
@@ -33,0 +34,0 @@ } |
@@ -91,5 +91,5 @@ const { sep } = require("path"); | ||
function report(err, callback, output, supressErrors) { | ||
function report(err, callback, output, suppressErrors) { | ||
if (err) { | ||
if (!supressErrors) callback(err, null); | ||
if (!suppressErrors) callback(err, null); | ||
return; | ||
@@ -102,4 +102,4 @@ } | ||
return function(err, state, callback) { | ||
report(err, callback, state[output], state.options.supressErrors); | ||
report(err, callback, state[output], state.options.suppressErrors); | ||
}; | ||
} |
@@ -58,4 +58,2 @@ const { sep, resolve: pathResolve } = require("path"); | ||
groupFiles(dir, files, state); | ||
if (--state.queue < 0) callback(null, ...args); | ||
} | ||
@@ -62,0 +60,0 @@ |
@@ -18,3 +18,3 @@ const { readdirSync } = require("../compat/fs"); | ||
} catch (e) { | ||
if (!state.options.supressErrors) throw e; | ||
if (!state.options.suppressErrors) throw e; | ||
} | ||
@@ -21,0 +21,0 @@ } |
@@ -6,4 +6,4 @@ const APIBuilder = require("./apiBuilder"); | ||
function Builder() { | ||
this.options = { | ||
function Builder(options = null) { | ||
this.options = options || { | ||
includeBasePath: false, | ||
@@ -14,3 +14,3 @@ includeDirs: false, | ||
resolvePaths: false, | ||
supressErrors: true, | ||
suppressErrors: true, | ||
group: false, | ||
@@ -21,2 +21,3 @@ onlyCounts: false, | ||
}; | ||
this.options.maxDepth = (options && options.maxDepth) || Infinity; | ||
} | ||
@@ -50,3 +51,3 @@ | ||
Builder.prototype.withErrors = function() { | ||
this.options.supressErrors = false; | ||
this.options.suppressErrors = false; | ||
return this; | ||
@@ -53,0 +54,0 @@ }; |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
21104
477