GithubHelp home page GithubHelp logo

readdir-on-steroids's Introduction

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(directory: string, 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's People

Watchers

 avatar  avatar  avatar

readdir-on-steroids's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.