create-readdir-stream
Streaming
fs.readdir
, extensible with smart plugins. No recursion and no globs by default - use plugins. Does not stat and doesn't read the filepaths - use plugins. It just push vinyl files to stream. Follows signature and semantics offs.createReadStream
method.
Table of Contents
Install
npm i create-readdir-stream --save
Usage
For more use-cases see the tests
const readdir =
API
CreateReaddirStream
Initialize
CreateReaddirStream
with defaultoptions
.
Params
[options]
{Object}: one of them iscwd
.
Example
const inst = console // => 'function'console // => 'function' // or get constructorconst Readdir = CreateReaddirStream
.use
Smart plugins support using use. It just calls that
fn
immediately and if it returns function again it is called (only when.createReaddirStream
is called) withfile
argument (vinyl file) for each item in the returned array byfs.readdir
.
Params
<fn>
{Function}: plugin to be called immediatelyreturns
{CreateReadStream}: this instance for chaining
Example
const through2 = const readdir = readdir readdir
.createReaddirStream
Reads a
dir
contents, creates vinyl file from each filepath, after that push them to stream.
Params
<dir>
{String|Buffer}: buffer or string folder/directory to read[options]
{Object}: options are extend-shallowed withthis.options
returns
{Stream}: Transform Stream, through2
Example
const th2 = const fs2 = // same signature and api as `fs.createReadStream`fs2
Related
- bash-glob: Bash-powered globbing for node.js | homepage
- glob: a little globber | homepage
- ip-filter: Validates valid IPs (IPv4 and IPv6) using micromatch - glob patterns, RegExp… more | homepage
- is-match-ip: Matching IPs using micromatch and ip-filter - glob patterns, RegExp, string or… more | homepage
- koa-better-router: Fast, simple, smart and correct routing for koa, using path-match. Foundation for… more | homepage
- micromatch: Glob matching for javascript/node.js. A drop-in replacement and faster alternative to minimatch… more | homepage
- nanomatch: Fast, minimal glob matcher for node.js. Similar to micromatch, minimatch and multimatch… more | homepage
- vinyl: Virtual file format. | homepage
Contributing
Pull requests and stars are always welcome. For bugs and feature requests, please create an issue.
But before doing anything, please read the CONTRIBUTING.md guidelines.