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

mutate-stream

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

mutate-stream

Object mutation pipelines for flow control

  • 0.0.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

mutate-stream

Object mutation pipelines for flow control

I think object mode streams are really handy for async flow control:

var stream = require('mutate-stream');

validate(req.body)
  .pipe(sanitize())
  .pipe(whatever())
  .pipe(dbWrite)

This module is a simple wrapper to eliminate boilerplate in a lot of my applications.

Installation

Download node at nodejs.org and install it, if you haven't already.

npm install mutate-stream --save

Usage

stream(<transform function>, [ optional flush function ]);

Pass in a transform function and an optional flush function. mutate-stream returns a a function that can take an optional data object parameter (to start your pipeline). This function in turn returns a stream.

Example:

var stream = require('mutate-stream');

function foo (obj, encoding, cb) { /* some transform */ }
function bar (obj, encoding, cb) { /* some transform */ }

var fooStream = stream(foo),
    barStream = stream(bar);

fooStream({some: 'optional data'})
  .pipe(barStream());

Tests

npm install
npm test

> mutate-stream@0.0.0 test /Users/mark/projects/mutate-stream
> node test/mutate-stream.js
TAP version 13
# wraps transform function
ok 1 should be equivalent
1..1
# tests 1
# pass  1
# ok

Dependencies

  • through2: A tiny wrapper around Node streams2 Transform to avoid explicit subclassing noise

Dev Dependencies

  • stream-output: Get the result of a streams transform pipeline for your tests
  • tape: tap-producing test harness for node and browsers

License

MIT

Keywords

FAQs

Package last updated on 26 Mar 2015

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