pull-stream
Version:
minimal pull stream
80 lines (50 loc) • 1.96 kB
Markdown
A Through is a stream that both reads and is read by
another stream.
Through streams are optional.
Put through streams in-between [sources](https://github.com/dominictarr/pull-stream/blob/master/docs/sources.md) and [sinks](https://github.com/dominictarr/pull-stream/blob/master/docs/sinks.md),
like this:
```js
pull(source, through, sink)
```
Also, if you don't have the source/sink yet,
you can pipe multiple through streams together
to get one through stream!
```js
var throughABC = function () {
return throughA()
.pipe(throughB())
.pipe(throughC())
}
```
Which can then be treated like a normal through stream!
```js
source().pipe(throughABC()).pipe(sink())
```
See also:
* [Sources](https://github.com/dominictarr/pull-stream/blob/master/docs/sources.md)
* [Sinks](https://github.com/dominictarr/pull-stream/blob/master/docs/sinks.md)
## map (fun)
Like `[].map(function (data) {return data})`
Like `map` but the signature of `fun` must be
`function (data, cb) { cb(null, data) }`
Like `[].filter(function (data) {return true || false})`
only `data` where `test(data) == true` are let through
to the next stream.
Like filter, but remove items where the filter returns true.
Filter items that have a repeated value for `prop()`,
by default, `prop = function (it) {return it }`, if prop is a string,
it will filter nodes which have repeated values for that property.
Filter unique items -- get the duplicates.
The inverse of `unique`
If test is a function, read data from the source stream and forward it downstream until test(data) returns false.
If `opts.last` is set to true, the data for which the test failed will be included in what is forwarded.
If test is an integer, take n item from the source.
## flatten ()
Turn a stream of arrays into a stream of their items, (undoes group).