Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/stealify/fs-readdir-stream


https://github.com/stealify/fs-readdir-stream

Last synced: 8 days ago
JSON representation

Awesome Lists containing this project

README

        

# fs-readdir-stream
Is a Function for Recursiv Dir Reading that returns a RealStream for fs.readdir replacement
Its using Operating system Filesystem Utils for that and returns a NodeStream or MostStream.

## install
```bash
npm install --save [email protected]
```

## Usage
```js
const { findStreamNode, findStreamMost } = require('fs-readdir-stream')
// can also be array supports all options that nativ os find supports
const options = '-maxdepth 1'

let listing = findStreamNode('.',[options])
listing.stdout.on('data', d=>console.log(d.toString()))
listing.stderr.on('data', d=>console.log(d.toString()))
listing.on('close', (code) => {
console.log(`child process exited with code ${code}`);
});

const readdirStream = findStreamMost('.',[options])
readdirStream(process.cwd()).observe(x=>console.log(x))
```

## Expert Usage

Using the Most Stream Interface https://github.com/cujojs/most/blob/master/docs/api.md

```js
const findStreamMost = require('fs-readdir-stream/find-stream.most')
// can also be array supports all options that nativ os find supports
const options = '-maxdepth 1'

const readdirStream = findStreamMost('.',[options])
.observe(x=>console.log(x))
```

using the Node event Stream Interface

```js
const findStreamNode = require('fs-readdir-stream/find-stream')
// can also be array supports all options that nativ os find supports
const options = '-maxdepth 1'

const readdirStream = findStreamNode('.',[options])
readdirStream.stdout.on('data', d=>console.log(d.toString()))
readdirStream.stderr.on('data', d=>console.log(d.toString()))
readdirStream.on('close', (code) => {
console.log(`child process exited with code ${code}`);
});
```