
Security News
Browserslist-rs Gets Major Refactor, Cutting Binary Size by Over 1MB
Browserslist-rs now uses static data to reduce binary size by over 1MB, improving memory use and performance for Rust-based frontend tools.
tiny-async-task-queue
Advanced tools
Here is a tiny async task queue, for several standalone task executing in order, with just one API.
npm i -S tiny-async-task-queue
const Queue = require('tiny-async-task-queue')
const queue = new Queue()
And the only API is add
.
queue.add(task1)
queue.add(task2)
queue.add(task3)
task1
, task2
, task3
, will executing one by one.
Tasks need according with ONE OF the rules below.
Function
, invoke it when the task is finished.Promise
.If your code satisfied with two rules, first finished rule will be triggered, and the second will be ignored.
For example:
your task can write like this
function task(next) {
setTimeout(() => {
// do something...
next()
}, 500)
}
or this
function task() {
return new Promise(resolve => {
setTimeout(() => {
// do something...
resolve()
}, 500)
})
}
If the task added to the empty queue, it will run immediately, otherwise it will be executed after other tasks finished.
And the internal queue based on
tiny-linked-queue
, if you want to manipulate the internal queue you can use thequeue
property.
const queue = new Queue()
queue.queue // => this property pint to the `tiny-linked-queue`.
function task1(next) {
setTimeout(() => {
console.log('task1 running.')
next()
}, 100)
}
function task2() {
return new Promise(resolve => {
setTimeout(() => {
console.log('task2 running.')
resolve()
}, 50)
})
}
function task3() {
console.log('task3 running.')
}
const Queue = require('tiny-async-task-queue')
const queue = new Queue()
queue.add(task1)
queue.add(task2)
queue.add(task3)
// console will logs as below:
// task1 running.
// task2 running.
// task3 running.
yarn test
FAQs
A tiny async task queue with one API.
The npm package tiny-async-task-queue receives a total of 6 weekly downloads. As such, tiny-async-task-queue popularity was classified as not popular.
We found that tiny-async-task-queue demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Browserslist-rs now uses static data to reduce binary size by over 1MB, improving memory use and performance for Rust-based frontend tools.
Research
Security News
Eight new malicious Firefox extensions impersonate games, steal OAuth tokens, hijack sessions, and exploit browser permissions to spy on users.
Security News
The official Go SDK for the Model Context Protocol is in development, with a stable, production-ready release expected by August 2025.