# read-dir-files

> Recursively read files from a directory

Latest version **0.1.1** (published 2012-05-12) · 0 weekly downloads

## Install

```sh
npm install read-dir-files
pnpm add read-dir-files
yarn add read-dir-files
bun add read-dir-files
```

## Health

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

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.1.1 |
| Published | 2012-05-12 |
| First published | 2011-12-05 |
| Weekly downloads | 0 |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >= 0.4 |
| Dependencies | 2 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 12 |
| Author | Maciej Małecki |
| Maintainers | mmalecki |
| Keywords | fs, recursive, file |

## Links

- npm: https://www.npmjs.com/package/read-dir-files
- Repository: https://github.com/mmalecki/node-read-dir-files
- npm.io page: https://npm.io/package/read-dir-files

## Dependencies (2)

- [errs](https://npm.io/package/errs.md) 0.1.x
- [async](https://npm.io/package/async.md) 0.1.x

## 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

- 0.1.1 (latest) — 2012-05-12
- 0.1.0 — 2012-02-28
- 0.0.2 — 2011-12-27
- 0.0.1 — 2011-12-05

## README

# read-dir-files [![Build Status](https://secure.travis-ci.org/mmalecki/node-read-dir-files.png)](http://travis-ci.org/mmalecki/node-read-dir-files)

Module for recursively (and non-recursively) reading all files in a directory.

## Installation

    npm install read-dir-files

## Usage
```js
  var readDirFiles = require('read-dir-files');

  readDirFiles.list('directory', function (err, filenames) {
    if (err) return console.dir(err);
    console.dir(filenames);
  });

  readDirFiles.read('directory', function (err, files) {
    if (err) return console.dir(err);
    console.dir(files);
  });

```

### readDirFiles.read(dir, encoding, recursive, callback)

Parameters:

  * `dir` Directory to read files from
  * `encoding` Files encoding. **Optional.**
  * `recursive` Recurse into subdirectories? **Optional**, default `true`.
  * `callback` Callback. **Optional.**

Asynchronously reads all files from `dir` and returns them to the callback
in form:

```json
{
   dir: {
     file0: <Buffer ...>,
     file1: <Buffer ...>,
     sub: {
      file0: <Buffer ...>
    }
  }
}
```

If you pass it the encoding, instead of buffers you'll get strings.

### readDirFiles.list(dir, options, callback)

Parameters:

  * `dir` Directory to read filenames from
  * `options` Files encoding. **Optional.**
    * `options.recursive` Recurses subdirectories.
    * `options.normalize` Normalizes filenames.
  * `recursive` Recurse into subdirectories? **Optional**, default `true`.
  * `callback` Callback. **Optional.**

Asynchronously reads all filenames from `dir` and returns them to the callback
in form:

```json
[
  'dir',
  'file0',
  'file1'
]
```

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