streaming pipeline with a mutable configuration
Installations
npm install stream-splicer
Developer
browserify
Developer Guide
Module System
CommonJS
Min. Node Version
Typescript Support
No
Node Version
11.15.0
NPM Version
6.9.0
Statistics
55 Stars
77 Commits
12 Forks
2 Watching
2 Branches
30 Contributors
Updated on 22 Nov 2023
Bundle Size
29.43 kB
Minified
8.40 kB
Minified + Gzipped
Languages
JavaScript (100%)
Total Downloads
Cumulative downloads
Total Downloads
355,642,514
Last day
-4.7%
213,765
Compared to previous day
Last week
7.8%
1,367,979
Compared to previous week
Last month
25.6%
4,984,418
Compared to previous month
Last year
-20.9%
50,464,437
Compared to previous year
Daily Downloads
Weekly Downloads
Monthly Downloads
Yearly Downloads
Dependencies
2
Dev Dependencies
5
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.
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.
1var splicer = require('stream-splicer'); 2var through = require('through2'); 3var jsonStream = require('jsonstream2'); 4var split = require('split2'); 5 6var headerData = {}; 7var headers = through.obj(function (buf, enc, next) { 8 var line = buf.toString('utf8'); 9 if (line === '') { 10 this.push(headerData); 11 pipeline.splice(1, 1, jsonStream.parse([ 'rows', true ])); 12 } 13 else { 14 var m = /^(\S+):(.+)/.exec(line); 15 var key = m && m[1].trim(); 16 var value = m && m[2].trim(); 17 if (m) headerData[key] = value; 18 } 19 next(); 20}); 21var pipeline = splicer([ split(), headers, jsonStream.stringify() ]); 22process.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
1var 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
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
0 existing vulnerabilities detected
Reason
license file detected
Details
- Info: project has a license file: LICENSE:0
- Info: FSF or OSI recognized license: MIT License: LICENSE:0
Reason
security policy file detected
Details
- Info: security policy file detected: github.com/browserify/.github/SECURITY.md:1
- Info: Found linked content: github.com/browserify/.github/SECURITY.md:1
- Info: Found disclosure, vulnerability, and/or timelines in security policy: github.com/browserify/.github/SECURITY.md:1
- Info: Found text in security policy: github.com/browserify/.github/SECURITY.md:1
Reason
Found 3/26 approved changesets -- score normalized to 1
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
project is not fuzzed
Details
- Warn: no fuzzer integrations found
Reason
branch protection not enabled on development/release branches
Details
- Warn: branch protection not enabled for branch 'master'
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
- Warn: 0 commits out of 8 are checked with a SAST tool
Score
4
/10
Last Scanned on 2024-11-25
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More