accumul

0.1.0 • Public • Published

Example

$ npm install accumul --save

or using yarn

$ yarn add accumul
const { accumul } = require('accumul')
// ES2015 modules
import { accumul } from 'accumul'

const callingFunction = x => x * x

const releaseFunction = args => {
  console.log(args)
}

const buffered = accumul(callingFunction, 2000, releaseFunction)

buffered.fire(1)
buffered.fire(2)
buffered.fire(3)
buffered.fire(4)

// after ~2 seconds you will see in a console
// [1, 4, 9, 16]

// or you can release buffered values beforehand

const buffered = accumul(callingFunction, 2000, releaseFunction)

buffered.fire(1)
buffered.fire(2)
buffered.fire(3)

buffered.release()
// [1, 4, 9]

buffered.fire(4)
// after ~2 seconds you will see in a console
// [16]

Package Sidebar

Install

npm i accumul

Weekly Downloads

1

Version

0.1.0

License

ISC

Unpacked Size

2.67 kB

Total Files

3

Last publish

Collaborators

  • ole_kaps