readdir-on-steroids
TypeScript icon, indicating that this package has built-in type declarations

1.1.2 • Public • Published

readdir-on-steroids

CircleCI

Recursively read the contents of a directory.

Installation

npm install readdir-on-steroids

Usage

import readdir from "readdir-on-steroids";
 
const directory = process.argv[3] || ".";
 
// only list files
function listFilter(path, stats) {
  return stats.isFile();
}
 
// don't traverse the .git, lib, node_modules or .vscode directories
function walkFilter(path, stats) {
  return (
    !/\.git$/.test(path) &&
    !/lib/.test(path) &&
    !/node_modules/.test(path) &&
    !/\.vscode/.test(path)
  );
}
 
readdir(directory, { listFilter, walkFilter }).then(
  paths => console.log(paths.join("\n")),
  error => console.error(error)
);

Output:

.gitignore
README.md
examples/index.ts
package.json
src/__mocks__/fs.ts
src/index.test.ts
src/index.ts
yarn.lock

API

readdir(directorystring, options?: Options)Promise<string[]>
Parameter Type Required Default Description
directory string The directory to read.
options Options {} The options.

Options

Parameter Type Required Default Description
concurrency number 4 The maximum number of concurrent calls to readdir.
listFilter (path: string, stats: Stats) => boolean A function filtering the paths that will be returned.
walkFilter (path: string, stats: Stats) => boolean A function filtering the paths that will be walked.

Stats

Parameter Type Required Default Description
root string The root directory being read.
depth number The relative depth from the root directory.

/readdir-on-steroids/

    Package Sidebar

    Install

    npm i readdir-on-steroids

    Weekly Downloads

    239

    Version

    1.1.2

    License

    MIT

    Unpacked Size

    13.7 kB

    Total Files

    10

    Last publish

    Collaborators

    • jameslnewell