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

promise-pc

v1.1.0

Published

Promise implementation of a producer-consumer queue

Downloads

4

Readme

promise-pc

New functionality! - Tree notify, see below

A Promise implementation of the producer-consumer problem.

Basically a queue in which you can keep adding promises. Consumer(s) consume promises and notify the producer. Uses the then/promise implementation.

Number of consumers is dynamic. (Coming soon. Currently changing the maxParallel after initialization does not do anything)

Usage

  • Require the module and initialize a PCQueue
var PCQueue = require("promise-pc").PCQueue;
var pcqueue = new PCQueue(opts);

See below for available options

  • When an item is ready to be consumed, a producer pushes it onto the queue using the produce method.
var promise = pcqueue.produce(function() {
  //This is a consumer function
  
  //Must return a promise object
});

promise.then(function(result){  //Use 'done' instead of 'then' if you wish to propagate errors
//Producer is notified after a consumer consumes an item
//Results of consumption are available here
});

Note that the consumer function is not immediately invoked. Only when a consumer is free (as indicated by the maxParallel option).

Tree Notify

Many a times processing of a tree or tree like structure requires async processing. On a node per node basis there is no difference in production and consumption. But at a tree level, it may be needed to be notified when tree processing is complete. The treeNotify event can be used to be notified once all the nodes of a tree are finished being processed by the consumer.

This is done by

  1. Declaring tree option as true
  2. Using treeNotify event to be notified of tree processing completion
  3. During producer/consumer processing, using children method to declare number of children current node has.

See tree test in tests.js

pcqueue.treeNotify(function() {/*Do something*/});

//Inside producer/consumer processing
pcqueue.children(node.children.length);

Options

  • maxParallel : Maximum number of consumers. If not specified, assumes inifite number of consumers
  • tree : Enables tree mode wherein treeNotify event is available