Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/stealify/fs-readdir-stream
https://github.com/stealify/fs-readdir-stream
Last synced: 8 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/stealify/fs-readdir-stream
- Owner: stealify
- License: apache-2.0
- Created: 2018-12-22T23:11:54.000Z (almost 6 years ago)
- Default Branch: master
- Last Pushed: 2020-10-27T10:56:01.000Z (about 4 years ago)
- Last Synced: 2024-10-13T03:10:33.812Z (about 1 month ago)
- Language: JavaScript
- Size: 12.7 KB
- Stars: 2
- Watchers: 2
- Forks: 0
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- License: LICENSE
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}`);
});
```