0.1.1 • Published 10 years ago

scoped-transform-stream v0.1.1

Weekly downloads
4
License
MIT
Repository
github
Last release
10 years ago

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'}