@seedalpha/throttle

throttle/debounce events

Usage no npm install needed!

<script type="module">
  import seedalphaThrottle from 'https://cdn.skypack.dev/@seedalpha/throttle';
</script>

README

throttle

queue/debounce events

Installation

$ npm install seed-throttle --save

Usage


var throttle = require('seed-throttle');

function fn(items, cb) {
  // array of items in the queue
  // cb when done
}

var queue = throttle({
  timeout: 20000, // flush every 20 seconds (if queue is not empty)
  size: 20 // flush if queue is at least 20 events long
}, fn);

queue.push(item);
queue.push(item2, item3, item4)
queue.push([item5, item6, item7]);
queue.flush(function() {
  // force flush and get a callback when all done
});

Author

Vladimir Popov vlad@seedalpha.net

License

©2016 SeedAlpha