1.0.1 • Published 7 years ago

lazy-task-queue v1.0.1

Weekly downloads
1
License
MIT
Repository
github
Last release
7 years ago

lazy-task-queue: an automatic queue of lazy tasks

What is this?

The lazy-task-queue is an automatic queue of lazy tasks (a.k.a. no-parameter functions that return a promise).

What purpose does it serve?

It was originally created for a Discord music bot I was creating. All of the libaries I could find evaluated strictly, whereas I wanted it to be evaluated lazily. Maybe I'm just dumb :P

How do I use this?

const TaskQueue = require('lazy-task-queue');
const q = new TaskQueue();

const delay = ms => new Promise(res => setTimeout(res, ms)); // for demonstration purposes

q.push(async () => {
	console.log("Hi!");
	await delay(1000);
});
q.push(async () => {
	console.log("Hi again!");
});

/* Output:
 * Hi!
 * <1 second delay>
 * Hi again!
 */
1.0.1

7 years ago

1.0.0

7 years ago