Socket
Socket
Sign inDemoInstall

get-all-files

Package Overview
Dependencies
0
Maintainers
1
Versions
13
Alerts
File Explorer

Advanced tools

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
9.5K
increased by2.49%
Maintainers
1
Install size
9.35 kB
Created
Weekly downloads
 

Readme

Source

get-all-files

version CI minzip size
A blazing fast recursive directory crawler with lazy sync and async iterator support.

Install

$ npm i get-all-files

Usage

import { getAllFiles, getAllFilesSync } from 'get-all-files'

// 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 getAllFilesSync(`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())

API

Methods

getAllFiles(path[, options])

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

Calling toArray on the returned value returns a promise that resolves to an array of the file paths.

getAllFiles(path[, options])

Returns a lazy iterable/iterator that 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.

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.

Contributing

Stars are always welcome!

For bugs and feature requests, please create an issue.

License

MIT © Tomer Aberbach

Keywords

FAQs

Last updated on 22 Sep 2021

Did you know?

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc