active-array

0.0.4 • Public • Published

ActiveArray

An array which fires a callback when either a count of items is reached, or an interval fires and a minimum count is present.

let x = new ActiveArray(callback, countThreshold, timeCountThreshold, intervalMilliseconds);

x.push(object);
console.log(x.length);

Example:

const ActiveArray = require('active-array');

let x = {};
let max = 5;
for (var i=0; i< max; i++) {
  let id = i;
  x[i] = new ActiveArray(function (list, why) { console.log(`fire ${why} ${id} ${list.length}`); }, 400, 100, 6000);
}
  
// periodically push messages into the buffers
setInterval(function () {
    let id = Math.floor(Math.random()*max);
    x[id].push("m"); // consume message from sqs and store here:
}, 1);

Readme

Keywords

Package Sidebar

Install

npm i active-array

Weekly Downloads

0

Version

0.0.4

License

none

Last publish

Collaborators

  • rmp