# dat-readdir-stream

> dat-readdir-stream is a small util to read the file-table of a dat as a stream, rather than through dat.readdir.

Latest version **1.1.0** (published 2018-02-11) · MIT license · 0 weekly downloads

## Install

```sh
npm install dat-readdir-stream
pnpm add dat-readdir-stream
yarn add dat-readdir-stream
bun add dat-readdir-stream
```

## Health

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

Positive: no vulnerabilities.

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

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.1.0 |
| Published | 2018-02-11 |
| First published | 2018-02-07 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 2 |
| Unpacked size | 18.9 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Martin Heidegger |
| Maintainers | leichtgewicht |
| Keywords | dat, stream, readdir |

## Links

- npm: https://www.npmjs.com/package/dat-readdir-stream
- Repository: https://github.com/martinheidegger/dat-readdir-stream
- Homepage: https://github.com/martinheidegger/dat-readdir-stream#readme
- Issues: https://github.com/martinheidegger/dat-readdir-stream/issues
- npm.io page: https://npm.io/package/dat-readdir-stream

## Dependencies (2)

- [minimatch](https://npm.io/package/minimatch.md) ^3.0.4
- [readable-stream](https://npm.io/package/readable-stream.md) ^2.3.3

## Alternatives

- [@regle/core](https://npm.io/package/@regle/core.md) — 47.0K weekly downloads
- [typeof-arguments](https://npm.io/package/typeof-arguments.md) — 12.5K weekly downloads
- [@lokalise/projects-engine-contracts](https://npm.io/package/@lokalise/projects-engine-contracts.md) — 978 weekly downloads
- [@osjwnpm/nam-laboriosam-quibusdam](https://npm.io/package/@osjwnpm/nam-laboriosam-quibusdam.md) — 70 weekly downloads
- [@oridune/validator](https://npm.io/package/@oridune/validator.md) — 16 weekly downloads

## Recent versions

- 1.1.0 (latest) — 2018-02-11
- 1.0.0 — 2018-02-07

## README

# dat-readdir-stream

<a href="https://travis-ci.org/martinheidegger/dat-readdir-stream"><img src="https://travis-ci.org/martinheidegger/dat-readdir-stream.svg?branch=master" alt="Build Status"/></a>
[![JavaScript Style Guide](https://img.shields.io/badge/code_style-standard-brightgreen.svg)](https://standardjs.com)
[![Maintainability](https://api.codeclimate.com/v1/badges/c4e876f726815686ab87/maintainability)](https://codeclimate.com/github/martinheidegger/dat-readdir-stream/maintainability)
[![Test Coverage](https://api.codeclimate.com/v1/badges/c4e876f726815686ab87/test_coverage)](https://codeclimate.com/github/martinheidegger/dat-readdir-stream/test_coverage)

`dat-readdir-stream` is a small util to read the file-table of a dat
as a stream, rather than through `dat.readdir`.

`npm i dat-readdir-stream --save`

### Usage 

```javascript
new ReaddirStream(archive[, opts])
```

 - `archive` [Hyperdrive](https://github.com/mafintosh/hyperdrive) archive (object).
 - `opts.glob` Do a [glob match](https://en.wikipedia.org/wiki/Glob_(programming)) over a folder (string).
 - `opts.globOpts` Options passed to [Minimatch](https://github.com/isaacs/minimatch#options) (object).
 - `opts.cwd` Target directory path (string), defaults to `/`.
 - `opts.recursive` Read all subfolders and their files as well?
 - `opts.maxDepth` Limit the depth until which to look into folders.
 - `opts.depthFirst` Using a [depth-first search](https://en.wikipedia.org/wiki/Depth-first_search) instead of the default [breadth-first search](https://en.wikipedia.org/wiki/Breadth-first_search).
 - Returns a [readable stream](https://nodejs.org/api/stream.html#stream_class_stream_readable) in [`Object Mode`](https://nodejs.org/api/stream.html#stream_object_mode). The payload per entry is an object:
     - `entry.location` The path of the entry
     - `entry.stats` A [Stats](https://nodejs.org/api/fs.html#fs_class_fs_stats) object for that path

```javascript
const ReaddirStream = require('dat-readdir-stream')

var stream = new ReaddirStream(archive, { cwd: '/assets' })
stream.on('data', ({location, stat}) => {
  console.log(location) // => '/assets/profile.png', '/assets/styles.css'
  console.log(stat.isDirectory()) // => false, false
})

var stream = new ReaddirStream(archive, { recursive: true })
stream.on('data', ({location, stat}) => {
  console.log(location) // => '/assets', '/index.html', '/assets/profile.png', '/assets/styles.css'
})

var stream = new ReaddirStream(archive, { recursive: true, depthFirst: true })
stream.on('data', ({location, stat}) => {
  console.log(location) // => '/assets', '/assets/profile.png', '/assets/styles.css', '/index.html'
})
```

### License

MIT

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