npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

parallel-queue

v3.0.1

Published

Queue for parallel tasks that can cancel and is destoryable

Readme

parallel-queue

Build Status

Queue for parallel tasks that can cancel and is destoryable

Usage

var parallelQueue = require('parallel-queue')

var pq = parallelQueue(4, function (args, done) {
  setTimeout(done, args.wait)
})

pq.push({wait: 30000})

// Cancel all pending tasks, and invoke callback on all running tasks with error
pq.destroy()

API

var queue = parallelQueue(parallel, worker)

Create a queue that is limited to parallel concurrent workers. worker will be invoked with (task, next), where task is whatever is pushed onto the queue and next is a normal callback function, passed an optional error as the first argument and up to three return values from succeeding arguments. These arguments will be passed on to the done callback in push.

var cancel = queue.push(task, done)

Queue task and call cb when done. queue.push will return a function that you can invoke to cancel the task, which in turn will invoke cb with a Error with err.cancel === true. If the task has already started, there is no way to cancel it, and it will not release a slot in the queue until done. If the queue has been destroyed, tasks will not be queued and done will be invoked immediately with an error.

Note: The task will not be executed before the nextTick as to avoid the worker function from plugging the event loop. This means you can .push and cancel as many tasks as you want synchronously, also from within the callback.

Note 2: You can cancel a running task, but that does not mean the actual work done by the worker is stopped, just that the cb supplied to .push is removed from the queue and called with an Error. The slot in the queue will be released as soon as the running worker calls the supplied next callback.

queue.destroy([err])

Cancel all pending tasks, and call the callback of all running tasks with an error. If err is not given, the default error will be used (see above).

queue.parallel

Number of tasks that can run in parallel. This is read-only

queue.pending

Number of tasks pending in the queue. This is excluding the current task if accessed from within the worker function

queue.running

Number of tasks running in the queue. This is including the current task if accessed from within the worker function.

queue.destroyed

Boolean set after destroy has finished

Install

npm install parallel-queue

License

ISC