patrolling
Patrol buffers and flush, periodically or when the buffer is full.
Installation
npm install patrolling
Usage
; /** * @class Patrolling * * @constructor * @param * @param * @param * @param */var patrolling = capacity timeout flush push ;
Example
const buffer = ; const capacity = 10;const timeout = 100;const flush = { buffer = ; console; }const push = { buffer; } const cache = capacity timeout flush push ; // At the tenth iteration the buffer is flushed because it hits the capacity.// The buffer ends up with five elements left when the loop ends.for var i = 0; i < 15; ++i cache; // If execution so far lasts for at least 100 milliseconds, the remaining five// elements are flushed. // You can flush it yourself anytime as well.cache;
License
MIT. See LICENSE.md for details.