@rearguard/batch
TypeScript icon, indicating that this package has built-in type declarations

1.9.6 • Public • Published

@rearguard/batch.

Installation.

npm i @rearguard/batch

Intro.

@rearguard/batch is an LRU batching cache mechanism, it allows stacking and progressively releasing an array of data based on ticking mechanism.

Usage.

const {batchLru} = require('@rearguard/batch');

/**
 * max items: 2
 * ttl: 1000ms
 * fn: callback
 * timeout: timeout in order to release the resource
 */
const batch = batchLru(2, 1000, items => {
  console.log(items);
});

batch.add(1);
batch.add({foo: 'bar'});

// after 1000ms
// => [1, {foo: 'bar'}]

Tests.

yarn test

Readme

Keywords

Package Sidebar

Install

npm i @rearguard/batch

Weekly Downloads

0

Version

1.9.6

License

MIT

Unpacked Size

4.56 kB

Total Files

8

Last publish

Collaborators

  • vorillaz