Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

get-all-files

Package Overview
Dependencies
Maintainers
1
Versions
14
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

get-all-files

A fast parallel stack-based readdir-recursively module with micromatch support.

  • 1.0.6
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
4.1K
decreased by-32.92%
Maintainers
1
Weekly downloads
 
Created
Source

Get All Files

NPM version Build Status JavaScript Style Guide

A fast parallel stack-based readdir-recursively module with micromatch support.

Install

Install with npm:

$ npm i get-all-files --save

Usage

const getAllFiles = require('get-all-files')

// All files
getAllFiles('path/to/dir/or/file').then(console.log)

// All JavaScript files
getAllFiles('path/to/dir/or/file', '*.js', {matchBase: true}).then(console.log)

// All files where their path is all lowercase
getAllFiles(
  'path/to/a/dir/or/file',
  filename => filename.toLowerCase() === filename
).then(console.log)

// A combination of options
getAllFiles(
  'path/to/dir/or/file',
  ['*.js', 'foo*', filename => filename.toLowerCase() === filename],
  {matchBase: true}
).then(console.log)

Method

getAllFiles(filename, arr, opt) -> Promise<Array<string>>

If the provided path is a file, an array containing the file path will be resolved in the promise. Otherwise it creates an array containing the file paths of all files recursively in the given directory.

The array is filtered by the given glob pattern(s) and/or predicate(s) and returned as a promise.

Parameters:

  • filename : string - A path to a file or directory.
  • arr : string | function(filename) -> boolean | Array<string | function(filename) -> boolean> (optional) - A string glob pattern, a function taking a file path and returning a boolean, or an array of containing any number of of the former two options.
  • opt : object (optional) - An options object for the micromatch module.

Contributing

Pull requests and stars are always welcome. For bugs and feature requests, please create an issue.

Running Tests

Install dev dependencies:

$ npm i -d && npm test

Benchmarking

Install dev dependencies:

$ npm i -d && npm run benchmark

Sample output (lower is less time):

Results from reading node_modules:
  get-all-files: 0.011025358324145534
  recur-readdir: 0.013531799729364006
  recursive-readdir: 0.01763668430335097
  recursive-files: 0.023923444976076555
  all-files-in-tree: 0.033444816053511704
  fs-readdir-recursive: 0.07518796992481203

Author

Tomer Aberbach

License

Copyright © 2018 Tomer Aberbach Released under the MIT license.

Keywords

FAQs

Package last updated on 09 Aug 2018

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

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