pultil
Granular Utilities for pull-streams
Funnel
A funnel
is a convenient way to create pull.Sink
(a.k.a reader, a.k.a writable) streams
Requiring funnel
Minimal code generation
Generates least amount of code when browserified/webpacked
var funnel = ;
Full package:
var funnel = funnel;
Funnel API
Funnel
provides a quick and easy way to create
sinks (i.e. write streams).
End signalling
To abort a stream, simply return true
from the funnel
var count = 0;
funnel(function (data) {
if (count++ > 100) { return true; }
console.log(data);
})
Funnel Example
var funnel = ;var src = ; var sink = ;
The above could be created with the more advanced
wsps.Sink
stream factory (as inherited from pull-stream
)
var wsps = var ws = 'ws://localhost:8081' var src = ; var sink = wsps ;
Evidently, funnel
takes away much of the boiler plate
involved with creating a Sink
factory. We only need
use Sink
when funnel
doesn't supply the required
flexibility.
Tunnel
A tunnel
is convenient way to create pull.Through
streams.
Requiring tunnel
Minimal code generation
Generates least amount of code when browserified/webpacked
var tunnel = ;
Full package:
var tunnel = tunnel;
Tunnel API
tunnel(fn:(data, cb?:(mutation)) => mutation?) => Through Factory
Synchronous Tunnel
var syncTransformStream = src.Tunnel(function (data) {
return data * 100;
})
Asynchronous Tunnel
var asyncTransformStream = src.Tunnel(function (data, cb) {
cb(data / 2)
})
Passthrough style
var logStream = src.Tunnel(function (data) {
console.info('data passing through:', data)
})
Tunnel Example
var tunnel = var src = ; var sink = var throughA = var throughB = var throughC = ;