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

attq

v0.2.0

Published

Async Tiny Task Queue

Downloads

208

Readme

Attq!

An async tiny task queue (and related utilities), with zero dependencies. Attq provides a data structure that executes an asynchronous callback sequentially on a flexible list. It is generally designed to facilitate replaying ordered events from a client to a server and comes with bells and whistles including batching, throttling, and configurable retries.

Installation

npm install --save attq

Examples

Basic Task Queue

The AsyncTaskQueue constructor takes a task handler callback, and items are added to the queue object with the .push() method. Additional options may be configured with methods such as .onError(), .batchSize(), and .throttleMs().

import { AsyncTaskQueue } from "attq";

const q = new AsyncTaskQueue<number>(
  (nums: number[]) => fetch(`/refine?macrodata=${nums.join(",")}`),
)
  // Handler will receive up to 4 items per batch.
  .batchSize(4)
  // Handler will be called at most once per 100 milliseconds.
  .throttleMs(100);

// Add items to the queue.
for (let n = 0; n < 1000; n++) {
  q.push(n);
}

await new Promise((resolve) => setTimeout(resolve, 5000));

console.log(q.size()); // Should display >=800 items remaining.

// Stop processing items if any causes an exception.
q.onError(() => {
  q.drain();
});

Retries

Rather than build retry logic into the queue itself, Attq provides a withRetry() higher-order function which can be wrapped around the task handler. (If desired, withRetry() may be used independently of the task queue as well!)

import { AsyncTaskQueue, withRetry } from "attq";

let q = new AsyncTaskQueue<number>(
  // Defaults to 6 attempts with binary exponential backoff.
  withRetry((nums) => fetch(`/refine?macrodata=${nums.join(",")}`)),
);

// To specify, for example, up to 3 attempts with a linear backoff:
q = new AsyncTaskQueue<number>(
  withRetry(
    (nums) => fetch(`/refine?macrodata=${nums.join(",")}`),
    {
      attempts: 3,
      backoffMs: (attempt) => 1000 * attempt,
    },
  ),
);