All Projects → browserify → Stream Splicer

browserify / Stream Splicer

Licence: mit
streaming pipeline with a mutable configuration

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to Stream Splicer

Labeled Stream Splicer
stream splicer with labels
Stars: ✭ 37 (-28.85%)
Mutual labels:  stream, streams, pipeline
go-streams
Stream Collections for Go. Inspired in Java 8 Streams and .NET Linq
Stars: ✭ 127 (+144.23%)
Mutual labels:  stream, streams
Rivers
Data Stream Processing API for GO
Stars: ✭ 39 (-25%)
Mutual labels:  stream, pipeline
bash-streams-handbook
💻 Learn Bash streams, pipelines and redirection, from beginner to advanced.
Stars: ✭ 153 (+194.23%)
Mutual labels:  pipeline, streams
streamplify
Java 8 combinatorics-related streams and other utilities
Stars: ✭ 40 (-23.08%)
Mutual labels:  stream, streams
tpack
Pack a Go workflow/function as a Unix-style pipeline command
Stars: ✭ 55 (+5.77%)
Mutual labels:  stream, pipeline
wasm-streams
Bridging between web streams and Rust streams using WebAssembly
Stars: ✭ 61 (+17.31%)
Mutual labels:  stream, streams
godsend
A simple and eloquent workflow for streaming messages to micro-services.
Stars: ✭ 15 (-71.15%)
Mutual labels:  stream, streams
Go Streams
A lightweight stream processing library for Go
Stars: ✭ 615 (+1082.69%)
Mutual labels:  streams, pipeline
Sql Streams
Painless low level jdbc abstraction using the java 8 stream api.
Stars: ✭ 17 (-67.31%)
Mutual labels:  stream, streams
Chunk Store Stream
Convert an abstract-chunk-store compliant store into a readable or writable stream
Stars: ✭ 24 (-53.85%)
Mutual labels:  stream, streams
Multistream
A stream that emits multiple other streams one after another (streams3)
Stars: ✭ 237 (+355.77%)
Mutual labels:  stream, streams
Cypher Stream
Neo4j Cypher queries as Node.js object streams
Stars: ✭ 58 (+11.54%)
Mutual labels:  stream, streams
streamalg
Extensible stream pipelines with object algebras.
Stars: ✭ 26 (-50%)
Mutual labels:  pipeline, streams
web-streams-polyfill
Web Streams, based on the WHATWG spec reference implementation
Stars: ✭ 198 (+280.77%)
Mutual labels:  stream, streams
Remote Web Streams
Web streams that work across web workers and iframes.
Stars: ✭ 26 (-50%)
Mutual labels:  stream, streams
Gollum
An n:m message multiplexer written in Go
Stars: ✭ 883 (+1598.08%)
Mutual labels:  stream, pipeline
Rsoundio
Rust binding for libsound.io
Stars: ✭ 40 (-23.08%)
Mutual labels:  stream
Sns
Analysis pipelines for sequencing data
Stars: ✭ 43 (-17.31%)
Mutual labels:  pipeline
Mmm Rtspstream
MagicMirror² module for streaming an RTSP video stream from a security camera to your MagicMirror.
Stars: ✭ 40 (-23.08%)
Mutual labels:  stream

stream-splicer

streaming pipeline with a mutable configuration

This module is similar to stream-combiner, but with a pipeline configuration that can be changed at runtime.

build status

example

This example begins with an HTTP header parser that waits for an empty line to signify the end of the header. At that point, it switches to a streaming json parser to operate on the HTTP body.

var splicer = require('stream-splicer');
var through = require('through2');
var jsonStream = require('jsonstream2');
var split = require('split2');

var headerData = {};
var headers = through.obj(function (buf, enc, next) {
    var line = buf.toString('utf8');
    if (line === '') {
        this.push(headerData);
        pipeline.splice(1, 1, jsonStream.parse([ 'rows', true ]));
    }
    else {
        var m = /^(\S+):(.+)/.exec(line);
        var key = m && m[1].trim();
        var value = m && m[2].trim();
        if (m) headerData[key] = value;
    }
    next();
});
var pipeline = splicer([ split(), headers, jsonStream.stringify() ]);
process.stdin.pipe(pipeline).pipe(process.stdout);

intput:

GET / HTTP/1.1
Host: substack.net
User-Agent: echo

{"rows":["beep","boop"]}

output:

$ echo -ne 'GET / HTTP/1.1\nHost: substack.net\nUser-Agent: echo\n\n{"rows":["beep","boop"]}\n' | node example/header.js
[
{"Host":"substack.net","User-Agent":"echo"}
,
"beep"
,
"boop"
]

methods

var splicer = require('stream-splicer')

var pipeline = splicer(streams, opts)

Create a pipeline duplex stream given an array of streams. Each stream will be piped to the next. Writes to pipeline get written to the first stream and data for reads from pipeline come from the last stream.

For example, for streams [ a, b, c, d ], this pipeline is constructed internally:

a.pipe(b).pipe(c).pipe(d)

Input will get written into a. Output will be read from d.

If any of the elements in streams are arrays, they will be converted into nested pipelines. This is useful if you want to expose a hookable pipeline with grouped insertion points.

var pipeline = splicer.obj(streams, opts)

Create a pipeline with opts.objectMode set to true for convenience.

var removed = pipeline.splice(index, howMany, stream, ...)

Splice the pipeline starting at index, removing howMany streams and replacing them with each additional stream argument provided.

The streams that were removed from the splice and returned.

pipeline.push(stream, ...)

Push one or more streams to the end of the pipeline.

var stream = pipeline.pop()

Pop a stream from the end of the pipeline.

pipeline.unshift(stream, ...)

Unshift one or more streams to the begining of the pipeline.

var stream = pipeline.shift()

Shift a stream from the begining of the pipeline.

var stream = pipeline.get(index, ...)

Return the stream at index index, .... Indexes can be negative.

Multiple indexes will traverse into nested pipelines.

attributes

pipeline.length

The number of streams in the pipeline

install

With npm do:

npm install stream-splicer

license

MIT

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].