Comparing version 3.0.0 to 3.1.0
@@ -76,2 +76,9 @@ declare module "fdir" { | ||
/** | ||
* Filter files using glob patterns. | ||
* @param patterns The glob patterns | ||
* @remarks You will need to install `picomatch` to use this. | ||
*/ | ||
glob(...patterns: string[]): Builder; | ||
/** | ||
* Exclude the directories that satisfy a condition | ||
@@ -78,0 +85,0 @@ * @param excludeFn The exclusion function |
{ | ||
"name": "fdir", | ||
"version": "3.0.0", | ||
"version": "3.1.0", | ||
"description": "The fastest directory crawler for NodeJS. Crawls 10k files in 13ms.", | ||
@@ -50,4 +50,5 @@ "main": "index.js", | ||
"rrdir": "^6.1.2", | ||
"walk-sync": "^2.0.2" | ||
"walk-sync": "^2.0.2", | ||
"picomatch": "^2.2.2" | ||
} | ||
} |
@@ -17,12 +17,14 @@ <p align="center"> | ||
⚡ **Extremely Fast:** Nothing similar (in the NodeJS world) beats `fdir` in speed. It can easily crawl a directory containing **1 million files in < 1 second.** | ||
⚡ **The Fastest:** Nothing similar (in the NodeJS world) beats `fdir` in speed. It can easily crawl a directory containing **1 million files in < 1 second.** | ||
💡 **Stupidly Easy:** `fdir` only has 2 functions; `sync` and `async` for crawling the file system synchronously or asynchronously. | ||
💡 **Stupidly Easy:** `fdir` uses expressive Builder pattern to build the crawler increasing code readability. | ||
🤖 **Zero Dependencies:** `fdir` uses pure NodeJS `fs` & `path` namespaces. Nothing else is ever touched. | ||
🤖 **Zero Dependencies:** `fdir` only uses NodeJS `fs` & `path` modules. | ||
🕺 **Astonishingly Small:** < 1KB in size | ||
🕺 **Astonishingly Small:** < 1KB in size gzipped. | ||
🔥 **All Node Versions Supported:** `fdir` runs everywhere on all Node versions (within reason). And it is unsurprisingly fastest there too. | ||
🔥 **All Node Versions Supported:** Unlike other similar libraries that have dropped support for Node versions < 10, `fdir` supports all versions > 6. | ||
🖮 **Hackable:** Extending `fdir` is extremely simple now that the new Builder API is here. Feel free to experiment around. | ||
## Support | ||
@@ -29,0 +31,0 @@ |
@@ -13,9 +13,9 @@ const { sep } = require("path"); | ||
module.exports.pushFileFilterAndCount = function(filter) { | ||
return function(filename, _files, dir, state) { | ||
if (filter(dir, filename)) state.counts.files++; | ||
return function(filename, _files, _dir, state) { | ||
if (filter(filename)) state.counts.files++; | ||
}; | ||
}; | ||
module.exports.pushFileFilter = function(filter) { | ||
return function(filename, files, dir) { | ||
if (filter(dir, filename)) files.push(filename); | ||
return function(filename, files) { | ||
if (filter(filename)) files.push(filename); | ||
}; | ||
@@ -22,0 +22,0 @@ }; |
const APIBuilder = require("./apiBuilder"); | ||
var pm = null; | ||
/* istanbul ignore next */ | ||
if (require.resolve("picomatch")) pm = require("picomatch"); | ||
@@ -63,2 +66,15 @@ function Builder() { | ||
Builder.prototype.glob = function(...patterns) { | ||
/* istanbul ignore next */ | ||
if (!pm) { | ||
throw new Error( | ||
`Please install picomatch: "npm i picomatch" to use glob matching.` | ||
); | ||
} | ||
this.options.filter = (path) => { | ||
return pm.isMatch(path, patterns); | ||
}; | ||
return this; | ||
}; | ||
Builder.prototype.exclude = function(excludeFn) { | ||
@@ -65,0 +81,0 @@ this.options.exclude = excludeFn; |
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
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
20910
14
471
122
0
15