
Security News
Axios Supply Chain Attack Reaches OpenAI macOS Signing Pipeline, Forces Certificate Rotation
OpenAI rotated macOS signing certificates after a malicious Axios package reached its CI pipeline in a broader software supply chain attack.
A queue with custom concurrency and time limits. Inspired by async/queue, but also with variable number of arguments in the worker, events, and with optional time limits.
const TimeQueue = require('timequeue');
const worker = (arg1, arg2, callback) => {
someAsyncFunction(calculation(arg1, arg2), callback);
};
// Worker can be an async function.
const worker = async (arg1) => {
let result1 = await anotherSyncFunction(arg1);
return andAnotherOne(result1);
};
// create a queue with max 5 concurrency every second
let q = new TimeQueue(worker, { concurrency: 5, every: 1000 });
// Push tasks onto the queue.
q.push(42, 24);
q.push(2, 74);
// Optional callback when pushing tasks.
q.push(2, 2, (err, result) => {
// task finished
});
// Can use promise/await syntax instead.
let result = await q.push(3, 5);
Creates a new instance of a queue. Worker must be a function with a callback for its last argument. The callback must be called in order for the queue to know when the worker has finished a task. options defaults to the following
{
// Maximum tasks to execute concurrently.
concurrency: 1
// How much time in milliseconds to allow no more than
// the max number of concurrent tasks to run.
// If the max amount of concurrent tasks finish faster than this time limit,
// additional tasks will wait until enough time has passed before starting.
, every: 0
// Maximum number of tasks to keep in the queue.
// While full, pushed tasks will be ignored.
, maxQueued: Infinity
// If set, tasks will error if they take too much time.
// if callback was given to that task, it will be called with the error,
// otherwise, the returned promise should be `caught`.
, timeout: 0
// You can pass a custom store to share tasks between several queues.
// Default is MemoryStore from `src/mem-store.ts`.
// Look at `example/redis-store.ts` for an example that saves tasks onto redis.
, store: MemoryStore
}
All of these options can later be edited on the queue instance.
How many tasks are currently active.
If you use the every option to queue up tasks, this property will be delayed from being updated until there are free spots open for new tasks to begin. active will be updated as soon as a task finishes, even if the next one is just a timeout around the corner.
How many tasks have finished in total.
Pushes a new task to the queue. Any number of arguments can be given. An optional callback can also be given as the last parameter. The callback will be called when the task is finished or if there was any error running the worker.
If the queue is full, pushed tasks will be ignored.
How many tasks are currently in the queue.
Returns true if queue is full.
Empties queue and clears the timeouts TimeQueue sets to keep track of running tasks. Currently running tasks will still complete.
Queue is full.
Queue is empty, with tasks still running.
Queue is empty and last task has finished.
npm install timequeue
Tests are written with mocha
npm test
FAQs
A queue with custom concurrency and time limits.
The npm package timequeue receives a total of 53 weekly downloads. As such, timequeue popularity was classified as not popular.
We found that timequeue 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
OpenAI rotated macOS signing certificates after a malicious Axios package reached its CI pipeline in a broader software supply chain attack.

Security News
Open source is under attack because of how much value it creates. It has been the foundation of every major software innovation for the last three decades. This is not the time to walk away from it.

Security News
Socket CEO Feross Aboukhadijeh breaks down how North Korea hijacked Axios and what it means for the future of software supply chain security.