pull stream util
Helpers for working with pull streams
- cat
- chain
- combine latest
- join
- many
- notify
- sample
- scan
install
npm install pull-stream-util
examples
from event
Create a stream from a single node style event
var S = var test = var EE = EventEmittervar FromEvent =
from emitter
Take an event emitter and return a stream of it's events
var S = var FromEmitter = var EE = EventEmitter var bus = var streams = bus // all events namespaced by key busbusbus // ---------------------------------------------// this is the foos// foo event// muxed events [ 'foo', 'foo event' ]// muxed events [ 'bar', 'bar event' ]// muxed events [ 'baz', 'baz event' ]
mux
Take an object of streams and return a single stream of their values, namespaced by key
var S = var mux = var streams = foo: S bar: S // ---------------------// [ 'foo', 'foo1' ]// [ 'bar', 'bar1' ]// [ 'foo', 'foo2' ]// [ 'bar', 'bar2' ] var pair = muxconsole // [ 'type', 'data' ]console // 'type'console // 'data'
broadcast
Take a source stream and pipe it to multiple subscribers
var S = var broadcast = var assert = // source *must* be async, or else it will drain before we subscribevar source = // take a normal source, return a function that returns a clone of// the sourcevar _source = // -------------------------------// 1// 1a// 2// 2a// 3// 3a { var streams = a: b: // pass in an object of streams // return a function that creates an object of clones var createStreams = var _streams = // -------------------------------- // 1aa // 1bb // 2aa // 2bb // 3aa // 3bb}
by key
Pipe an object of sources to an object of sinks
var S = var SS = var sources = foo: S bar: S var sinks = foo: S bar: S // ------------------------// foo1// foo2// foo3// bar1// bar2// bar3
http
Create streams of http events from objects of request data
var S = var createServer = createServervar HTTPStream = var HTTPData = var assert = // xhr argsvar RequestData = // path and request bodyvar requestData = var server = server
http data
Helper for creating request data
var HttpRequest = var assert = // take this data and return a new functionvar RequestData = // merge this argument with the request body from above, // return new request objectvar data = consoleassert // pass an array to add path segments to the `url` key,// return a new functionvar FooRequest = // add body data, return request datavar fooData = consoleassert
from cb
Take an async (node style) function, and return a function that returns streams of http events, just like the http request stream in this module.
var assert = var fromCb = var S = { process}