debarrel

A library for NodeJS that allows you to accumulate a load of changes, then run a function after a set amount of time with those changes.


License
MIT
Install
npm install debarrel@1.0.2

Documentation

debarrel

GitHub code size in bytes GitHub package.json version GitHub js-semistandard-style

A library for NodeJS that allows you to accumulate a load of changes, then run a function after a set amount of time with those changes.

Installation

npm install --save debarrel

Usage

The debarrel module returns an function that can be called to mutate the cache.

Example

const debarrel = require('debarrel');

let total = 0;
const watch = debarrel(function () {
  console.log('total:', total);
}, {
  minimumFlushTime: 100,
  maximumFlushTime: 2000
})

const increment = watch(function (increment) {
  total = total + increment;
})

// call increment. debarrel will flush every 10
const interval = setInterval(function () {
  increment(1)
}, 10);

// stop after 20 increments
setTimeout(() => {
  clearInterval(interval)
, 200);