Socket
Socket
Sign inDemoInstall

fdir

Package Overview
Dependencies
Maintainers
1
Versions
40
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

fdir - npm Package Compare versions

Comparing version 3.3.0 to 3.4.0

2

index.d.ts

@@ -22,3 +22,3 @@ declare module "fdir" {

onlyCounts?: boolean;
filter?: FilterFn;
filters?: FilterFn[];
exclude?: ExcludeFn;

@@ -25,0 +25,0 @@ };

{
"name": "fdir",
"version": "3.3.0",
"version": "3.4.0",
"description": "The fastest directory crawler for NodeJS. Crawls 10k files in 13ms.",

@@ -10,3 +10,4 @@ "main": "index.js",

"bench": "node benchmarks/benchmark.js",
"bench:glob": "node benchmarks/glob-benchmark.js"
"bench:glob": "node benchmarks/glob-benchmark.js",
"bench:fdir": "node benchmarks/fdir-benchmark.js"
},

@@ -13,0 +14,0 @@ "repository": {

<p align="center">
<img src="https://github.com/thecodrr/fdir/raw/master/assets/fdir.gif" width="75%"/>
<h1 align="center">The Fastest Directory Crawler for NodeJS</h1>
<h1 align="center">The Fastest Directory Crawler & Globber for NodeJS</h1>
<p align="center">

@@ -72,8 +72,2 @@ <a href="https://www.npmjs.com/package/fdir"><img src="https://img.shields.io/npm/v/fdir?style=for-the-badge"/></a>

_Last updated: May 10, 2020 (fdir v3.0.0)_
```sh
$ yarn benchmark
```
**Specs:**

@@ -102,4 +96,28 @@

### Node v14.2.0:
### The Fastest Globber
_Last updated: May 13, 2020 (fdir v3.3.0)_
```sh
$ yarn bench:glob
```
> glob pattern used: `**.js` & `**/**.js`
#### Node v13.13.0
| Synchronous | Asynchronous |
| :-------------------------------------------------------------------: | :--------------------------------------------------------------------: |
| ![](https://github.com/thecodrr/fdir/raw/master/assets/glob-sync.png) | ![](https://github.com/thecodrr/fdir/raw/master/assets/glob-async.png) |
### The Fastest Directory Crawler
_Last updated: May 10, 2020 (fdir v3.0.0)_
```sh
$ yarn bench
```
#### Node v14.2.0:
| Synchronous | Asynchronous |

@@ -109,3 +127,3 @@ | :---------------------------------------------------------------------: | :----------------------------------------------------------------------: |

### Node v8.7.0:
#### Node v8.7.0:

@@ -112,0 +130,0 @@ _Older versions of fdir (1.x & 2.x) used synchronous `lstat` call (`lstatSync`) in the asynchronous API to acheive speed on Node < 10. This has been fixed in fdir 3.0.0._

@@ -12,12 +12,14 @@ const { sep } = require("path");

/** PUSH FILE */
module.exports.pushFileFilterAndCount = function(filter) {
module.exports.pushFileFilterAndCount = function(filters) {
return function(filename, _files, _dir, state) {
if (filter(filename)) state.counts.files++;
if (filters.some((f) => f(filename))) state.counts.files++;
};
};
module.exports.pushFileFilter = function(filter) {
module.exports.pushFileFilter = function(filters) {
return function(filename, files) {
if (filter(filename)) files.push(filename);
if (filters.some((f) => f(filename))) files.push(filename);
};
};
module.exports.pushFileCount = function(_filename, _files, _dir, state) {

@@ -24,0 +26,0 @@ state.counts.files++;

@@ -62,3 +62,3 @@ const { sep, resolve: pathResolve } = require("path");

const {
filterFn,
filters,
onlyCountsVar,

@@ -72,6 +72,6 @@ includeBasePath,

// build function for adding paths to array
if (filterFn && onlyCountsVar) {
pushFile = fns.pushFileFilterAndCount(filterFn);
} else if (filterFn) {
pushFile = fns.pushFileFilter(filterFn);
if (filters.length && onlyCountsVar) {
pushFile = fns.pushFileFilterAndCount(filters);
} else if (filters.length) {
pushFile = fns.pushFileFilter(filters);
} else if (onlyCountsVar) {

@@ -78,0 +78,0 @@ pushFile = fns.pushFileCount;

const APIBuilder = require("./apiBuilder");
var pm = null;
var globCache = null;
/* istanbul ignore next */

@@ -7,2 +8,3 @@ try {

pm = require("picomatch");
globCache = {};
} catch (_e) {

@@ -15,2 +17,3 @@ // do nothing

this.suppressErrors = true;
this.filters = [];
}

@@ -27,3 +30,3 @@

options.excludeFn = options.exclude;
options.filterFn = options.filter;
options.filters = options.filters || [];
return new APIBuilder(path, options);

@@ -69,3 +72,3 @@ };

Builder.prototype.filter = function(filterFn) {
this.filterFn = filterFn;
this.filters.push(filterFn);
return this;

@@ -81,6 +84,8 @@ };

}
const isMatch = pm(patterns);
this.filterFn = (path) => {
return isMatch(path, patterns);
};
var isMatch = globCache[patterns.join("||")];
if (!isMatch) {
isMatch = pm(patterns);
globCache[patterns.join("||")] = isMatch;
}
this.filters.push((path) => isMatch(path));
return this;

@@ -87,0 +92,0 @@ };

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc