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);

Versions

Current Tags

  • Version
    Downloads (Last 7 Days)
    • Tag
  • 0.0.4
    2
    • latest

Version History

  • Version
    Downloads (Last 7 Days)
    • Published
  • 0.0.4
    2
  • 0.0.3
    0
  • 0.0.2
    0
  • 0.0.1
    0

Package Sidebar

Install

npm i active-array

Weekly Downloads

2

Version

0.0.4

License

none

Last publish

Collaborators

  • rmp