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

@jacben/deco

v0.1.6

Published

Zero dependency collection of composable asynchronous decorators.

Downloads

11

Readme

Deco

Coverage Status npm version

Zero dependency collection of composable asynchronous decorators.

Roadmap

  • [x] Request coalescing
  • [x] Concurrency limiting
  • [ ] In-memory caching
  • [ ] Jitter
  • [ ] Rate limiting / Throttling
  • [ ] Retry mechanism

💡 Have a feature idea? Raise an issue.

Install

npm install @jacben/deco

Decorators

Request Coalescing

Deduplicate identical in-flight requests by combining them into one call.

import {coalesce} from "@jacben/deco";

// Example async function
const getUserById = async (id) => {}

// Wrap the original function so requests with the same values are coalesced
const coalescedGetUserById = coalesce(getUserById);

// Only one call to getUserById occurs, even though it is called twice.
await Promise.all([
    coalescedGetUserById(1),
    coalescedGetUserById(1),
]); 

Generating coalesce keys

If the values passed to the coalesced function are not strings, numbers or booleans, you'll need to provide a generateKey callback.

// Example async function, which takes an object as its input
const getPackage = async (pkg) => {}

// Return a key which uniquely identifies this input
const generateKey = (pkg) => `${pkg.name}@${pkg.version}`;

// Provide generateKey as an argument
const coalescedGetPackage = coalesce(getPackage, generateKey); 

// You can now pass in the full pkg object
await coalescedGetPackage(pkg);

⚠️ Beware of collisions when dealing with user input.
For example, if your generateKey function is implemented as (...args) => args.map(arg).join('|'),
then generateKey("a", "a") would have the same output as generateKey("a|a").

Concurrency Limiting

Limit how many requests can run concurrently.

import {limit} from "@jacben/deco";

// Example async function
const getUserById = async (id) => {}

// Allow a maximum of 2 concurrent requests to getUserById
const limitedGetUserById = limit(getUserById, 2);

// The third request will not start until the first or second finishes
await Promise.all([
    limitedGetUserById(1),
    limitedGetUserById(2),
    limitedGetUserById(3),
]);

Combining decorators

If you want to limit concurrent requests but allow identical requests to bypass this limit, you can combine decorators:

import {coalesce, limit} from '@jacben/deco'

let fn = async () => {}
fn = limit(fn, 5)
fn = coalesce(fn)

The resulting chain would be: Request -> coalesce -> limit -> original function.
Any duplicate requests to coalesce do not hit to the next function in the chain. Therefore, the concurrency limit does not apply to identical requests.

In reverse, if you want to limit calls and then dedupe identical request, you would decorate in the reverse order:

import {coalesce, limit} from '@jacben/deco'

let fn = async () => {}
fn = coalesce(fn)
fn = limit(fn, 5)

Contact

If you'd like to suggest a feature, report an issue or ask a question, feel free to raise an issue.