ueue
TypeScript icon, indicating that this package has built-in type declarations

1.0.2 • Public • Published

Queue - ueue is silent

npm versionnode versionBuild status - Linux/OSXBuild status - WindowsCodecov

Event-driven queue manager.

Features

Install

Install via yarn:

yarn add ueue

Install via npm:

npm i ueue

Docs

Read the docs on GitHub pages.

Example

Import

CommonJS

const { Q, } = require('ueue');

ES6

import { Q, } from 'ueue';

Use

Create queue

const q = new Q();

Enqueue things

Consider following script:

const sleep = function (ms) {
    return new Promise(res => {
        setTimeout(() => res(), ms);
    });
};
 
q
    .add(() => 'Test 1')
    .then(console.log);
 
q
    .add(async () => (await sleep(1000), 'Test 2'))
    .then(console.log);
 
q.addBunch(
    async () => (await sleep(100), '1'),
    async () => (await sleep(100), '2')
).then(console.log);
 
q.addBunch(
    async () => (await sleep(100), '1'),
    async () => {
        await sleep(100);
        throw '2';
    },
    async () => (await sleep(100), '3')
).catch(console.log);
 
console.log('Test 0');

And following output:

Test 0
Test 1
Test 2
[ { result: '1' }, { result: '2' } ]
[ { result: '1' }, { error: '2' }, { result: '3' } ]

Readme

Keywords

Package Sidebar

Install

npm i ueue

Weekly Downloads

1

Version

1.0.2

License

ISC

Unpacked Size

51.3 kB

Total Files

17

Last publish

Collaborators

  • zekfad