scoped-transform-stream

0.1.1 • Public • Published

scoped-transform-stream

Scope a transform stream, using json-pointer and write-transform-read.

npm install scoped-transform-stream

Example

var scope = require('scoped-transform-stream')
var through2 = require('through2')
 
var square = through2.obj(function(data, enc, cb) {
  cb(null, (data * data))
})
 
var scoped = scope(square, '/foo/bar')
scoped.on('data', console.log)
scoped.write({foo: { bar: 2 }, baz: 'yay'}) // {foo: { bar: 4 }, baz: 'yay'}
scoped.write({foo: { bar: 4 }, baz: 'yay'}) // {foo: { bar: 16 }, baz: 'yay'}
scoped.write({foo: { bar: 8 }, baz: 'yay'}) // {foo: { bar: 64 }, baz: 'yay'}
scoped.write({foo: { bar: 16 }, baz: 'yay'}) // {foo: { bar: 256 }, baz: 'yay'}

/scoped-transform-stream/

    Package Sidebar

    Install

    npm i scoped-transform-stream

    Weekly Downloads

    3

    Version

    0.1.1

    License

    MIT

    Last publish

    Collaborators

    • jbenet