dedupe-stream

1.1.0 • Public • Published

dedupe-stream

A stream that prevents consecutive duplicate emissions.

Build Status npm install

Example

var dedupeStream = require('dedupe-stream')
 
var dedupe = dedupeStream()
 
dedupe.write({fruit: 'apples'}) // emits {fruit: 'apples'}
 
dedupe.write({fruit: 'apples'}) // does not emit
 
dedupe.write({fruit: 'oranges'}) // emits {fruit: 'oranges'}

API

dedupe() -> DuplexStream

  • Input is anything (See "Notes" below)
  • Output is whatever you wrote, assuming it is unique compared to the previous emission.

Notes

Internally, dedupeStream clones the emitted value using JSON.parse(JSON.stringify(obj))) in order to avoid downstream changes from throwing off the equality check. This means that things that aren't faithfully JSON.stringifyed, such as functions and objects with circular references, will cause an error to throw.

License

This project is licensed under the Apache License, Version 2.0. See LICENSE for the full license.

Readme

Keywords

Package Sidebar

Install

npm i dedupe-stream

Weekly Downloads

1

Version

1.1.0

License

Apache-2.0

Last publish

Collaborators

  • urbanairship