get-all-files
Advanced tools
Comparing version 3.0.0 to 4.0.0
105
package.json
{ | ||
"name": "get-all-files", | ||
"version": "3.0.0", | ||
"author": "Tomer Aberbach <tomeraberbach@gmail.com> (https://tomeraberba.ch)", | ||
"version": "4.0.0", | ||
"author": { | ||
"name": "Tomer Aberbach", | ||
"email": "tomeraberbach@gmail.com", | ||
"url": "https://tomeraberba.ch" | ||
}, | ||
"description": "A blazing fast recursive directory crawler with lazy sync and async iterator support.", | ||
@@ -24,53 +28,60 @@ "keywords": [ | ||
"license": "MIT", | ||
"main": "lib/get-all-files.js", | ||
"module": "lib/get-all-files.module.js", | ||
"files": [ | ||
"lib" | ||
"src" | ||
], | ||
"scripts": { | ||
"lint:eslint:base": "eslint -c ./eslint.config.js --cache --ext js --ignore-path .gitignore", | ||
"lint:eslint": "pnpm run lint:eslint:base -- --fix .", | ||
"lint:prettier:base": "prettier --loglevel silent", | ||
"lint:prettier": "pnpm run lint:prettier:base -- --write .", | ||
"lint": "run-s lint:*", | ||
"test": "ava", | ||
"build:main": "cross-env BABEL_ENV=main babel -o lib/get-all-files.js src/index.js", | ||
"build:module": "cross-env BABEL_ENV=module babel -o lib/get-all-files.module.js src/index.js", | ||
"build": "run-p build:*", | ||
"benchmark": "babel-node src/benchmark.js" | ||
"type": "module", | ||
"engines": { | ||
"node": ">= 12.17" | ||
}, | ||
"exports": "./src/index.js", | ||
"module": "./src/index.js", | ||
"types": "./src/index.d.ts", | ||
"prettier": "@tomer/prettier-config", | ||
"eslintConfig": { | ||
"extends": "@tomer" | ||
}, | ||
"lint-staged": { | ||
"*.js": [ | ||
"run-s \"lint:prettier:base -- --write {@}\" --", | ||
"run-s \"lint:eslint:base -- --fix {@}\" --" | ||
], | ||
"*.ts": "run-s \"lint:prettier:base -- --write {@}\" --", | ||
"*.{json,yml,md}": "run-s \"lint:prettier:base -- --write {@}\" --" | ||
}, | ||
"tsd": { | ||
"directory": "./test" | ||
}, | ||
"commitlint": { | ||
"extends": "@commitlint/config-conventional" | ||
}, | ||
"simple-git-hooks": { | ||
"pre-commit": "pnpx --no-install lint-staged", | ||
"commit-msg": "pnpx --no-install commitlint -e" | ||
}, | ||
"devDependencies": { | ||
"@ava/babel": "^1.0.1", | ||
"@babel/cli": "^7.10.1", | ||
"@babel/core": "^7.10.2", | ||
"@babel/node": "^7.10.1", | ||
"@babel/preset-env": "^7.10.2", | ||
"@babel/register": "^7.10.1", | ||
"all-files-in-tree": "^1.1.2", | ||
"ava": "^3.8.2", | ||
"babel-eslint": "10.1.0", | ||
"benny": "^3.6.14", | ||
"core-js": "^3.6.5", | ||
"cross-env": "^7.0.2", | ||
"eslint": "7.1.0", | ||
"eslint-config-prettier": "6.11.0", | ||
"eslint-plugin-ava": "10.3.0", | ||
"eslint-plugin-prettier": "3.1.3", | ||
"fdir": "^3.4.3", | ||
"fs-readdir-recursive": "^1.1.0", | ||
"klaw-sync": "^6.0.0", | ||
"np": "^6.2.3", | ||
"npm-run-all": "^4.1.5", | ||
"prettier": "2.0.5", | ||
"recur-readdir": "^0.0.1", | ||
"recursive-files": "^1.0.2", | ||
"recursive-fs": "^2.1.0", | ||
"recursive-readdir": "^2.2.2", | ||
"regenerator-runtime": "^0.13.5", | ||
"rrdir": "^8.1.1", | ||
"walk-sync": "^2.1.0" | ||
"@commitlint/cli": "12.1.4", | ||
"@commitlint/config-conventional": "12.1.4", | ||
"@tomer/eslint-config": "0.1.1", | ||
"@tomer/prettier-config": "0.1.0", | ||
"ava": "3.15.0", | ||
"c8": "7.7.2", | ||
"eslint": "7.27.0", | ||
"lint-staged": "11.0.0", | ||
"npm-run-all": "4.1.5", | ||
"prettier": "2.3.0", | ||
"simple-git-hooks": "2.4.1", | ||
"tsd": "0.15.1", | ||
"typescript": "4.3.2" | ||
}, | ||
"engines": { | ||
"node": ">= 10" | ||
"scripts": { | ||
"lint:prettier:base": "prettier --loglevel silent --ignore-path .gitignore", | ||
"lint:prettier": "run-s \"lint:prettier:base -- --write .\"", | ||
"lint:eslint:base": "eslint --cache --ext js --ignore-path .gitignore", | ||
"lint:eslint": "run-s \"lint:eslint:base -- --fix .\"", | ||
"lint": "run-s lint:*", | ||
"test:js": "ava", | ||
"test:ts": "tsd", | ||
"test": "run-s test:*", | ||
"coverage": "c8 run-s test:js" | ||
} | ||
} |
@@ -1,11 +0,23 @@ | ||
# Get All Files | ||
<h1 align="center"> | ||
get-all-files | ||
</h1> | ||
[![NPM version](https://img.shields.io/npm/v/get-all-files.svg)](https://www.npmjs.com/package/get-all-files) | ||
<div align="center"> | ||
<a href="https://npmjs.org/package/get-all-files"> | ||
<img src="https://badgen.now.sh/npm/v/get-all-files" alt="version" /> | ||
</a> | ||
<a href="https://github.com/TomerAberbach/get-all-files/actions"> | ||
<img src="https://github.com/TomerAberbach/get-all-files/workflows/CI/badge.svg" alt="CI" /> | ||
</a> | ||
<a href="https://bundlephobia.com/result?p=get-all-files"> | ||
<img src="https://badgen.net/bundlephobia/minzip/get-all-files" alt="minzip size" /> | ||
</a> | ||
</div> | ||
> A blazing fast recursive directory crawler with lazy sync and async iterator support. | ||
<div align="center"> | ||
A blazing fast recursive directory crawler with lazy sync and async iterator support. | ||
</div> | ||
## Install | ||
Supports Node.js versions 10 and above. | ||
```sh | ||
@@ -18,9 +30,16 @@ $ npm i get-all-files | ||
```js | ||
import getAllFiles from 'get-all-files' | ||
import { getAllFiles, getAllFilesSync } from 'get-all-files' | ||
// Get array of filenames synchronously | ||
console.log(getAllFiles.sync.array(`path/to/dir/or/file`)) | ||
// Lazily iterate over filenames asynchronously | ||
for await (const filename of getAllFiles(`path/to/dir/or/file`)) { | ||
// Could break early on some condition and get-all-files | ||
// won't have unnecessarily accumulated the filenames in an array | ||
console.log(filename) | ||
} | ||
// Get array of filenames asynchronously | ||
console.log(await getAllFiles(`path/to/dir/or/file`).toArray()) | ||
// Lazily iterate over filenames synchronously | ||
for (const filename of getAllFiles.sync(`path/to/dir/or/file`)) { | ||
for (const filename of getAllFilesSync(`path/to/dir/or/file`)) { | ||
// Could break early on some condition and get-all-files | ||
@@ -31,13 +50,4 @@ // won't have unnecessarily accumulated the filenames in an array | ||
;(async () => { | ||
// Get array of filenames asynchronously | ||
console.log(await getAllFiles.async.array(`path/to/dir/or/file`)) | ||
// Lazily iterate over filenames asynchronously | ||
for await (const filename of getAllFiles.async(`path/to/dir/or/file`)) { | ||
// Could break early on some condition and get-all-files | ||
// won't have unnecessarily accumulated the filenames in an array | ||
console.log(filename) | ||
} | ||
})() | ||
// Get array of filenames synchronously | ||
console.log(getAllFilesSync(`path/to/dir/or/file`).toArray()) | ||
``` | ||
@@ -49,18 +59,21 @@ | ||
#### `getAllFiles.sync(path[, options])` | ||
#### `getAllFiles(path[, options])` | ||
Returns a lazy [iterable](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols#The_iterable_protocol)/[iterator](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols#The_iterator_protocol) that iterates over the file paths recursively found at `path` in no particular order. | ||
Returns a lazy | ||
[async iterable/iterator](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Symbol/asyncIterator) | ||
that asynchronously iterates over the file paths recursively found at `path` in | ||
no particular order. | ||
#### `getAllFiles.sync.array(path[, options])` | ||
Calling `toArray` on the returned value returns a promise that resolves to an | ||
array of the file paths. | ||
Returns a `string[]` of file paths recursively found at `path` in no particular ordering. | ||
#### `getAllFiles(path[, options])` | ||
#### `getAllFiles.async(path[, options])` | ||
Returns a lazy | ||
[iterable](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols#The_iterable_protocol)/[iterator](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols#The_iterator_protocol) | ||
that iterates over the file paths recursively found at `path` in no particular | ||
order. | ||
Returns a lazy [async iterable/iterator](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Symbol/asyncIterator) that asynchronously iterates over the file paths recursively found at `path` in no particular order. | ||
Calling `toArray` on the returned value returns an array of the file paths. | ||
#### `getAllFiles.async.array(path[, options])` | ||
Returns a `Promise<string[]>` of file paths recursively found at `path` in no particular ordering. | ||
### Parameters | ||
@@ -92,6 +105,17 @@ | ||
A predicate that determines whether the directory with the given `dirname` should be crawled. There is no `isExcludedFile` option because you can exclude files by checking conditions while lazily iterating using`getAllFiles.sync` or `getAllFiles.async`. | ||
A predicate that determines whether the directory with the given `dirname` | ||
should be crawled. There is no `isExcludedFile` option because you can exclude | ||
files by checking conditions while lazily iterating using`getAllFiles.sync` or | ||
`getAllFiles.async`. | ||
## Contributing | ||
Stars are always welcome! | ||
For bugs and feature requests, | ||
[please create an issue](https://github.com/TomerAberbach/get-all-files/issues/new). | ||
## License | ||
[MIT](https://github.com/TomerAberbach/get-all-files/blob/master/license) © [Tomer Aberbach](https://github.com/TomerAberbach) | ||
[MIT](https://github.com/TomerAberbach/get-all-files/blob/main/license) © | ||
[Tomer Aberbach](https://github.com/TomerAberbach) |
Sorry, the diff of this file is not supported yet
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
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
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
13
118
2
Yes
10506
5
152
1