GithubHelp home page GithubHelp logo

isabella232 / diffset Goto Github PK

View Code? Open in Web Editor NEW

This project forked from observing/diffset

0.0 0.0 0.0 4 KB

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

JavaScript 100.00%

diffset's Introduction

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

diffset's People

Contributors

3rd-eden avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.