Nostradamus Predicting Maelstroms

npm

Ready to take your JavaScript development to the next level? Meet npm Enterprise - the ultimate in enterprise JavaScript.Learn more »

simple-timed-queue

1.0.8 • Public • Published

Build Status NPM Version

simple-timed-queue

Queue data structure with expiration

Syntax

> var q = new TimedQueue(ttl, delta, disableEvents);
> q.enqueue(10 /* any variable/object */);
> q.dequeue();
10

deque can return timeleft of stored object:

> q.dequeue(true);
[10, 200 /* timeleft */ ]

Usage

> var q = new TimedQueue(100); // entries ttl
> q.enqueue('text1');
> q.dequeue();
// test1
> q.enqueue('text2');
...
// 0.1 second here
...
> q.dequeue();
undefined

Queue will emit 'expire' event for item:

q.on('expired', function(data){
    console.log('expired:', data);
});

This can be disabled with disableEvents flag:

var q = new TimedQueue(100, null, true);

install

npm i simple-timed-queue

Downloadsweekly downloads

36

version

1.0.8

license

ISC

homepage

github.com

repository

Gitgithub

last publish

collaborators

  • avatar
Report a vulnerability