Socket
Socket
Sign inDemoInstall

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 blazing fast recursive directory crawler with lazy sync and async iterator support.


Version published
Weekly downloads
8K
increased by18.02%
Maintainers
1
Weekly downloads
 
Created
Source

Get All Files

NPM version

A blazing fast recursive directory crawler with sync and async iterator support.

Install

Supports Node.js versions 10 and above.

$ npm i get-all-files

Usage

import getAllFiles from 'get-all-files'

// Get array of filenames synchronously
console.log(getAllFiles.sync.array(`path/to/dir/or/file`))

// Lazily iterate over filenames synchronously
for (const filename of getAllFiles.sync(`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)
}

;(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)
  }
})()

API

Methods

getAllFiles.sync(path[, options])

Returns a lazy iterable/iterator that iterates over the file paths recursively found at path in no particular order.

getAllFiles.sync.array(path[, options])

Returns a string[] of file paths recursively found at path in no particular ordering.

getAllFiles.async(path[, options])

Returns a lazy async iterable/iterator that asynchronously iterates over the file paths recursively found at path in no particular order.

getAllFiles.async.array(path[, options])

Returns a Promise<string[]> of file paths recursively found at path in no particular ordering.

Parameters

path

Type: string

A path of file or directory to recursively find files in.

options

Type: object

Properties
resolve

Type: boolean Default: false

Whether to resolve paths to absolute paths (relative to process.cwd()).

isExcludedDir

Type: (dirname: string) => boolean Default: () => false

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 usinggetAllFiles.sync or getAllFiles.async.

License

MIT © Tomer Aberbach

Keywords

FAQs

Package last updated on 03 May 2020

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