git ssb

2+

Dominic / pull-stream



Tree: 81642b10bd4a0105dae4a0d01429420d3ddb2016

Files: 81642b10bd4a0105dae4a0d01429420d3ddb2016 / docs / throughs.md

1957 bytesRaw

Throughs

A Through is a stream that both reads and is read by another stream.

Through streams are optional.

Put through streams in-between sources and sinks, like this:

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!

var throughABC = function () {
 return throughA()
    .pipe(throughB())
    .pipe(throughC())
}

Which can then be treated like a normal through stream!

source().pipe(throughABC()).pipe(sink())

See also:

map (fun)

Like [].map(function (data) {return data})

asyncMap (fun)

Like map but the signature of fun must be function (data, cb) { cb(null, data) }

filter (test)

Like [].filter(function (data) {return true || false})
only data where test(data) == true are let through to the next stream.

filterNot (test)

Like filter, but remove items where the filter returns true.

unique (prop)

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.

nonUnique (prop)

Filter unique items -- get the duplicates. The inverse of unique

take (test [, opts])

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).

Built with git-ssb-web