Installations
npm install @ex1st/tiny-queue
Developer Guide
Typescript
No
Module System
CommonJS
Min. Node Version
>= v16.0.0
Node Version
18.16.1
NPM Version
9.5.1
Score
69.6
Supply Chain
98.7
Quality
75.5
Maintenance
100
Vulnerability
100
License
Releases
Unable to fetch releases
Contributors
Unable to fetch Contributors
Languages
JavaScript (100%)
Love this project? Help keep it running — sponsor us today! 🚀
Developer
ex1st
Download Statistics
Total Downloads
4,775
Last Day
5
Last Week
5
Last Month
24
Last Year
1,545
GitHub Statistics
2 Stars
17 Commits
3 Watching
1 Branches
1 Contributors
Bundle Size
1.34 kB
Minified
675.00 B
Minified + Gzipped
Package Meta Information
Latest Version
3.0.0
Package Id
@ex1st/tiny-queue@3.0.0
Unpacked Size
7.46 kB
Size
2.98 kB
File Count
5
NPM Version
9.5.1
Node Version
18.16.1
Publised On
19 Jul 2023
Total Downloads
Cumulative downloads
Total Downloads
4,775
Last day
0%
5
Compared to previous day
Last week
0%
5
Compared to previous week
Last month
4.3%
24
Compared to previous month
Last year
150%
1,545
Compared to previous year
Daily Downloads
Weekly Downloads
Monthly Downloads
Yearly Downloads
Dev Dependencies
3
Asynchronous (asyn-await/promise) function queue.
Example
1import { Queue } from '@ex1st/tiny-queue'; 2 3const queue = new Queue(async function (task) { 4 const r = await task; 5 return r; 6}, { timeout: 2000 }); 7 8const result = []; 9 10// add task to the queue 11queue.push(new Promise(resolve => { 12 setTimeout(() => { 13 resolve(1); 14 }, 1000); 15})); 16 17// add task to the queue 18queue.push(new Promise(resolve => { 19 setTimeout(() => { 20 resolve(2); 21 }, 500); 22})); 23 24// add task to the queue 25queue.push(new Promise(resolve => { 26 setTimeout(() => { 27 resolve(3); 28 }, 100); 29}), new Promise(resolve => { 30 setTimeout(() => { 31 resolve(4); 32 }, 50); 33})); 34 35// add task to the queue 36queue.push(new Promise(resolve => { 37 setTimeout(() => { 38 resolve(5); 39 }, 2500); 40})); 41 42queue.on('done', function (res, task) { 43 result.push(res); 44}); 45 46queue.on('timeout', function (task) { 47 console.log('task timed out:', task); 48}); 49 50console.log(queue.running()); // true 51console.log(queue.length()); // 4 52 53queue.on('drain', function () { 54 console.log(result); // [1,2,3,4] 55});
Install
npm install @ex1st/tiny-queue
API
const queue = new Queue(worker, { timeout, filter })
worker
functiontimeout
integer, is optionalfilter
function, is optional
Instance methods
queue.push(...tasks)
add new task(s) to the queue.
queue.pause()
a function that pauses the processing of tasks.
queue.resume()
a function that resumes the processing of the queued tasks.
queue.kill()
a function that empties remaining tasks from the queue
queue.running()
a function returning execution state of the queue
queue.length()
a function returning the queue's size
queue.setFilter(fn)
a function set a custom filter
Events
queue.on('done', (result, task) => {})
When a task is done.
queue.on('error', (error, task) => {})
When a task throws an error.
queue.on('timeout', (task) => {})
When timeout params milliseconds have elapsed.
queue.on('drain', () => {})
When a last task from a queue
has returned from a worker
queue.on('empty', () => {})
When a last task from a queue
is given to a worker
![Empty State](/_next/static/media/empty.e5fae2e5.png)
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
license file detected
Details
- Info: project has a license file: LICENSE:0
- Info: FSF or OSI recognized license: MIT License: LICENSE:0
Reason
1 existing vulnerabilities detected
Details
- Warn: Project is vulnerable to: GHSA-3xgq-45jj-v275
Reason
Found 0/17 approved changesets -- score normalized to 0
Reason
no SAST tool detected
Details
- Warn: no pull requests merged into dev branch
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
project is not fuzzed
Details
- Warn: no fuzzer integrations found
Reason
security policy file not detected
Details
- Warn: no security policy file detected
- Warn: no security file to analyze
- Warn: no security file to analyze
- Warn: no security file to analyze
Reason
branch protection not enabled on development/release branches
Details
- Warn: branch protection not enabled for branch 'master'
Score
2.9
/10
Last Scanned on 2025-02-03
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More