# readdir-on-steroids

> Recursively read the contents of a directory.

Latest version **1.1.2** (published 2018-06-18) · MIT license · 0 weekly downloads

## Install

```sh
npm install readdir-on-steroids
pnpm add readdir-on-steroids
yarn add readdir-on-steroids
bun add readdir-on-steroids
```

## Health

**Score 25/100 (F)** — status: abandoned.

Positive: has types; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.1.2 |
| Published | 2018-06-18 |
| First published | 2014-04-03 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 13.4 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | James Newell |
| Maintainers | jameslnewell |
| Keywords | fs, readdir, recursive, directory, filter |

## Links

- npm: https://www.npmjs.com/package/readdir-on-steroids
- Repository: https://github.com/jameslnewell/readdir-on-steroids
- Homepage: https://github.com/jameslnewell/readdir-on-steroids#readme
- npm.io page: https://npm.io/package/readdir-on-steroids

## Alternatives

- [unionfs](https://npm.io/package/unionfs.md) — 2.2M weekly downloads
- [path-starts-with](https://npm.io/package/path-starts-with.md) — 35.9K weekly downloads
- [redzip](https://npm.io/package/redzip.md) — 1.2K weekly downloads
- [vscode-anymatch](https://npm.io/package/vscode-anymatch.md) — 848 weekly downloads
- [@ledgerhq/coin-filecoin](https://npm.io/package/@ledgerhq/coin-filecoin.md) — 793 weekly downloads

## Recent versions

- 1.1.2 (latest) — 2018-06-18
- 1.1.1 — 2018-06-06
- 1.1.0 — 2018-06-06
- 1.0.0 — 2018-06-04
- 0.2.2 — 2015-08-14
- 0.2.1 — 2014-04-05
- 0.2.0 — 2014-04-04
- 0.1.0 — 2014-04-03

## README

# readdir-on-steroids

[![CircleCI](https://circleci.com/gh/jameslnewell/readdir-on-steroids.svg?style=svg)](https://circleci.com/gh/jameslnewell/readdir-on-steroids)

Recursively read the contents of a directory.

## Installation

```bash
npm install readdir-on-steroids
```

## Usage

```js
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

```ts
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. |

---
_Source: https://npm.io/package/readdir-on-steroids · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
