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 🙏

© 2024 – Pkg Stats / Ryan Hefner

@sovpro/gazillionth-queue

v1.3.2

Published

One in gazillions of task queue implementations

Downloads

6

Readme

Gazillionth Queue

One in gazillions of task queue implementations.

Build status for Node.js 8.x and newer

Constructor

The constructor accepts a (optional) configuration to set concurrency and active_wait values at instantiation.

// instantiate a queue to have up to 2
// dequeued functions active at a time and
// an active wait time of 50 milliseconds
const queue = new GazillionthQueue ({
  concurrency: 2 ,
  active_wait: 50
})

Add to queue

Functions in the queue are executed with a "done" callback argument that should be invoked once the function has completed its work.

Push

Add a function to the end of the queue:

queue.push ((done) => {
  // do stuff
  done ()
})

Unshift

Put a function at the start of the queue:

queue.unshift ((done) => {
  // do stuff
  done ()
})

Clear the queue

Clear the queue and return the number of functions cleared. The cleared event will be emitted if there were functions in the queue.

let num_cleared = queue.clear ()

Properties

concurrency

The maximum number of callbacks that should be active at a time.

concurrency is an unsigned integer with a default value of 1.

Setting concurrency to a number value less than 1 pauses the queue. To resume the queue, concurrency should be set to a number value greater than 0.

active_wait

The suggested amount of time to wait, in milliseconds, before dequeueing more functions.

Each time the number of active functions drops below the configured concurrency the queue will wait the time specified by active_wait before filling the concurrency quota.

active_wait is an unsigned integer value with a default value of 16 milliseconds.

started

A read-only boolean flag indicating whether there are functions in the queue or dequeued functions that are still active. Each time done is emitted started will become false again.

length

A read-only count of functions in the queue that are not active.

active

A read-only count of dequeued functions that have been invoked and that have not finished their work by calling done ().

Events

activated

Emitted with an integer representing the count of functions that are dequeued to be invoked, each time functions are dequeued.

cleared

Emitted with an integer representing the count of uncalled functions that were remaining in the queue before clear was called.

done

Emitted each time the queue becomes empty and is not active.

error

Emitted with an error each time a queued function throws an uncaught error.