# read-dir-stream

> an object stream to emit each file in a dir, set your `readdir`, `stat` function to use it.

Latest version **0.4.0** (published 2015-08-29) · MIT license · 0 weekly downloads

## Install

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

## 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.4.0 |
| Published | 2015-08-29 |
| First published | 2015-07-11 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 4 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 3 |
| Maintainers | riceball |
| Keywords | readable, stream, dir, directory, readdir, abstract, class, klass |

## Links

- npm: https://www.npmjs.com/package/read-dir-stream
- Repository: https://github.com/snowyu/read-dir-stream.js
- Issues: https://github.com/snowyu/read-dir-stream.js/issues
- npm.io page: https://npm.io/package/read-dir-stream

## Dependencies (4)

- [path.js](https://npm.io/package/path.js.md) ^1.0.6
- [util-ex](https://npm.io/package/util-ex.md) ^0.3.10
- [inherits-ex](https://npm.io/package/inherits-ex.md) ^1.1.3
- [readable-stream](https://npm.io/package/readable-stream.md) ^2.0.1

## Alternatives

- [byte-size](https://npm.io/package/byte-size.md) — 2.1M weekly downloads
- [speed-limiter](https://npm.io/package/speed-limiter.md) — 16.0K weekly downloads
- [@powersync/node](https://npm.io/package/@powersync/node.md) — 10.9K weekly downloads
- [@ledgerhq/coin-cardano](https://npm.io/package/@ledgerhq/coin-cardano.md) — 1.0K weekly downloads
- [@jayesol/jayeson.lib.streamfinder](https://npm.io/package/@jayesol/jayeson.lib.streamfinder.md) — 1.0K weekly downloads

## Recent versions

- 0.4.0 (latest) — 2015-08-29
- 0.3.1 — 2015-07-27
- 0.3.0 — 2015-07-18
- 0.2.0 — 2015-07-11
- 0.1.1 — 2015-07-11
- 0.1.0 — 2015-07-11

## README

## read-dir-stream [![npm](https://img.shields.io/npm/v/read-dir-stream.svg)](https://npmjs.org/package/read-dir-stream)

[![Build Status](https://img.shields.io/travis/snowyu/read-dir-stream.js/master.svg)](http://travis-ci.org/snowyu/read-dir-stream.js)
[![downloads](https://img.shields.io/npm/dm/read-dir-stream.svg)](https://npmjs.org/package/read-dir-stream)
[![license](https://img.shields.io/npm/l/read-dir-stream.svg)](https://npmjs.org/package/read-dir-stream)

the custom readdir-stream class to create an object stream to read a dir.
You should implement your `readdir`, `stat` functions to use it.

## Usage

use it directly:

```js
var fs = require('graceful-fs')
var ReadDirStream = require('read-dir-stream')
var stream = ReadDirStream(dirName, {readdirFn:fs.readdir, statFn: fs.stat})

```

inherits from:

```js
var fs = require('graceful-fs')
var inherits = require('inherits-ex')
var ReadDirStream = require('read-dir-stream')
function MyReadDirStream() {
  ReadDirStream.apply(this, arguments)
}

inherits(MyReadDirStream, ReadDirStream);

MyReadDirStream.prototype._readdir = fs.readdir;
MyReadDirStream.prototype._stat = fs.stat;

var stream = new MyReadDirStream('.', readdir)

stream.on('data', function(file){
  console.log(file.path)
})
```

## API

### constructor(dirName, options)

* options:
  * `cwd` *(String)*: optional the current working directory.
  * `readdirFn` *[function(dirName, done)]*: the readdir function you must be provided
  * `statFn` *[function(fileName, done)]*: the stat function to get the file's stat(must be provided).
  * `makeObjFn` *[function(file)]*: the optional makeObj callback function to make a file object.
    * the `file` object will be passed to makeObjFn function:
      * `path`: is the file path.
      * `stat`: is the file stats object if any.
      * `cwd`: is the dirName of read-dir or cwd if cwd option exist.
    * this `file` will be ignored if return null.
    * this `file` object is used as the default if no makeObjFn provided.
  * deepth *(number)*: the recursive deepth of readdir. defaults to 1.


## License

MIT

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