![Namecheap Takes Down Polyfill.io Service Following Supply Chain Attack](https://cdn.sanity.io/images/cgdhsj6q/production/6af25114feaaac7179b18127c83327568ff592d1-1024x1024.webp?w=800&fit=max&auto=format)
Security News
Namecheap Takes Down Polyfill.io Service Following Supply Chain Attack
Polyfill.io has been serving malware for months via its CDN, after the project's open source maintainer sold the service to a company based in China.
queue-promise
Advanced tools
Readme
queue-promise
is a small, dependency-free library for promise-based queues. It will resolve enqueued functions concurrently at a given speed. When a task is being resolved or rejected, an event will be emitted.
$ npm install queue-promise
import Queue from "queue-promise";
const queue = new Queue({
concurrent: 1, // resolve 1 task at a time
interval: 2000 // resolve a new task once in 2000ms
});
queue.on("resolve", data => console.log(data));
queue.on("reject", error => console.error(error));
queue.push(asyncTaskA); // resolved/rejected after 0s
queue.push(asyncTaskB); // resolved/rejected after 2s
queue.push(asyncTaskC); // resolved/rejected after 4s
queue.push(asyncTaskD); // resolved/rejected after 6s
queue.start();
new Queue(options)
Create a new Queue
instance.
Option | Default | Description |
---|---|---|
concurrent | 5 | How many tasks can be handled at the same time |
interval | 500 | How often should new tasks be handled (in ms) |
.add(task)
/.push(task)
Puts a new task on the stack. Throws an error if the provided task
is not a valid function.
.start()
Starts the queue. Queue
will use global Promises.
.started
Whether the queue has been started or not.
.stop()
Stops the queue.
.on(event, callback)
Sets a callback
for an event
. You can set callback for those events: start
, stop
, tick
, resolve
, reject
, end
.
.next()
Goes to the next request and stops the loop if there is no requests left.
.remove(key)
/.pop(key)
/.shift(key)
Removes a task from the queue.
$ npm test
FAQs
A simple, dependency-free library for concurrent promise-based queues. Comes with with concurrency and timeout control.
The npm package queue-promise receives a total of 6,809 weekly downloads. As such, queue-promise popularity was classified as popular.
We found that queue-promise 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
Polyfill.io has been serving malware for months via its CDN, after the project's open source maintainer sold the service to a company based in China.
Security News
OpenSSF is warning open source maintainers to stay vigilant against reputation farming on GitHub, where users artificially inflate their status by manipulating interactions on closed issues and PRs.
Security News
A JavaScript library maintainer is under fire after merging a controversial PR to support legacy versions of Node.js.