1.0.5 • Published 6 years ago

datequeue v1.0.5

Weekly downloads
4
License
MIT
Repository
-
Last release
6 years ago

DateQueue

A Queue that automatically executes specific (async) functions at a specific time (rounded to the second).

npm.io

You can find the full documentation at https://docs.mo-mar.de/datequeue/, or have a look at the tests to see some real-world examples.

Are you just looking for a simple queue without timing?

Example usage

const DateQueue = require("datequeue");
const dq = new DateQueue();

// q.push(date, func, prio, data)
q.push(new Date(Date.now() + 30000), function() {
    console.log("It's now 30 seconds later!");
}, 2);

// You can't use an arrow function if you want to access `this`.
let x = q.push(new Date(Date.now() + 30000), function() {
    // You can access the 4th argument using this.data
    console.log(this.data);
    // You can access all items accessed in a specific second ("timeframe") - in this case, there should be only the function itself!
    console.log(this.timeframe[0].id);
}, 0, "hello world");