Skip to content

Progressively calculate and store the differences between the previous added values.

Notifications You must be signed in to change notification settings

observing/diffset

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 

Repository files navigation

diffset

A small set numbers where only the diff of the previously added value is stored. So if your previous value was 120 and you store 123 it will only store the number 3.

Installation

The module is published in the public npm registry and can be installed by running:

npm install --save diffset

API

var Diffset = require('diffset');

var ds = new Diffset(100);

In the example above we import the diffset module and give it a starting value of 100. If no starting value is provided it will default to 0.

push

Add a new value to the set, the method accepts multiple arguments if you want to do a bulk add.

ds.push(120, 122, 130, 100, 101);
ds.push(111);

flush

Clear the internally stored diff set that you created by pushing in new values and return a copy of the data.

var data = ds.flush();
console.log(data) // 20, 2, 8, -30, 1, 10

License

MIT

About

Progressively calculate and store the differences between the previous added values.

Resources

Stars

Watchers

Forks

Packages

No packages published