Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

stream-splicer

Package Overview
Dependencies
Maintainers
1
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

stream-splicer

streaming pipeline with a mutable configuration

  • 1.0.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
410K
decreased by-59.39%
Maintainers
1
Weekly downloads
 
Created

What is stream-splicer?

The stream-splicer npm package allows you to create a stream that can be dynamically spliced with other streams. This is particularly useful for building complex streaming pipelines where you need to insert, remove, or replace streams on the fly.

What are stream-splicer's main functionalities?

Dynamic Stream Splicing

This feature allows you to dynamically splice streams into a pipeline. In this example, a through stream is created that converts input to uppercase. The stream-splicer package is used to create a stream pipeline that can be dynamically modified.

const splicer = require('stream-splicer');
const through = require('through2');

const stream = splicer([
  through(function (chunk, enc, callback) {
    this.push(chunk.toString().toUpperCase());
    callback();
  })
]);

stream.write('hello');
stream.write('world');
stream.end();

stream.pipe(process.stdout);

Inserting Streams

This feature allows you to insert new streams into an existing pipeline. In this example, a new stream is inserted that reverses the input string.

const splicer = require('stream-splicer');
const through = require('through2');

const stream = splicer([
  through(function (chunk, enc, callback) {
    this.push(chunk.toString().toUpperCase());
    callback();
  })
]);

const newStream = through(function (chunk, enc, callback) {
  this.push(chunk.toString().split('').reverse().join(''));
  callback();
});

stream.splice(1, 0, newStream);

stream.write('hello');
stream.write('world');
stream.end();

stream.pipe(process.stdout);

Removing Streams

This feature allows you to remove streams from an existing pipeline. In this example, the second stream that reverses the input string is removed from the pipeline.

const splicer = require('stream-splicer');
const through = require('through2');

const stream = splicer([
  through(function (chunk, enc, callback) {
    this.push(chunk.toString().toUpperCase());
    callback();
  }),
  through(function (chunk, enc, callback) {
    this.push(chunk.toString().split('').reverse().join(''));
    callback();
  })
]);

stream.splice(1, 1);

stream.write('hello');
stream.write('world');
stream.end();

stream.pipe(process.stdout);

Other packages similar to stream-splicer

Keywords

FAQs

Package last updated on 09 Jun 2014

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc