1.1.0 • Published 6 years ago

significant-stream v1.1.0

Weekly downloads
3
License
MIT
Repository
github
Last release
6 years ago

significant-streambuild status

Stream where only significant changes are pushed through

NPM

NPM

Installation

npm install significant-stream

Example

Input

var stream1 = require('./significant-stream')()
  , stream2 = require('./significant-stream')({ key: 'foo' })
  , stream3 = require('./significant-stream')({ cache: { max: 100 } }) // LRU cache options

stream1.on('data', function (row) { console.log('data from stream1', row) })

console.log('stream1 will only ouput the second string, since the diff between them is an append')
stream1.write('Hello')
stream1.write('Hello, world!')
stream1.end()

console.log('stream2 has similar behaviour as stream1, but it is an object')
stream2.on('data', function (obj) { console.log('data from stream2', obj) })
stream2.write({ foo: 'Yeah', bar: 'beep' })
stream2.write({ foo: 'Oh, Yeah', bar: 'boop' })
stream2.end()

console.log('stream3 has same behaviour as stream1, but uses lru-cache for diff')
stream1.on('data', function (row) { console.log('data from stream3', row) })
stream1.write('Hello')
stream1.write('Hello, world!')
stream1.end()

Output

stream1 will only ouput the second string, since the diff between them is an append
data from stream1 Hello, world!
stream2 has similar behaviour as stream1, but it is an object
data from stream2 { foo: 'Oh, Yeah', bar: 'boop' }
stream3 has same behaviour as stream1, but uses lru-cache for diff
data from stream3 Hello, world!

Licence

Copyright (c) 2014 Mic Network, Inc

This software is released under the MIT license:

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.