get-all-files
A blazing fast recursive directory crawler with lazy sync and async iterator support.
Last updated 2 days ago by tomeraberbach .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install get-all-files 
SYNC missed versions from official npm registry.

Get All Files

NPM version

A blazing fast recursive directory crawler with lazy 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 to a 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

Current Tags

  • 3.0.0                                ...           latest (2 days ago)

11 Versions

  • 3.0.0                                ...           2 days ago
  • 2.0.1                                ...           16 days ago
  • 2.0.0                                ...           a month ago
  • 1.0.7                                ...           2 years ago
  • 1.0.6                                ...           2 years ago
  • 1.0.5                                ...           2 years ago
  • 1.0.4                                ...           2 years ago
  • 1.0.3                                ...           2 years ago
  • 1.0.2                                ...           2 years ago
  • 1.0.1                                ...           2 years ago
  • 1.0.0                                ...           2 years ago
Maintainers (1)
Downloads
Today 0
This Week 81
This Month 81
Last Day 5
Last Week 32
Last Month 250
Dependencies (0)
None
Dev Dependencies (29)
Dependents (0)
None

Copyright 2014 - 2016 © taobao.org |