Skip to content

schornio/timed-queue

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Timed Queue

Build Status Dependency Status

Get objects only after timeout, sorted by timeout (longest expiration first).

Install

npm install @aetherwave/timed-queue

Usage

let queue = new TimedQueue();
queue.enqueue(999, 'Hello World');

console.log(queue.dequeue()); // -> null

setTimeout(function () {
  console.log(queue.dequeue()); // -> Hello World
}, 1000);

TimedQueue#enqueue(timeout, obj)

Enqueues object with timeout

TimedQueue#dequeue()

  • If there is one or more item with timeout lower than the current timestamp, this object gets dequeued
  • Else null is going to be returned

TimedQueue#length

Returns length of the queue

Test

Run tests

$ npm test

About

Get objects only after timeout, sorted by timeout, longest expiration first

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published