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

alleviate

v0.2.3

Published

A collection of tiny caching and promise utilities

Readme

alleviate

Open on npmx.dev Open on npmx.dev Open on npmx.dev

Usage

  • createLRU - A simple, fast LRU cache.
  • createTTLMap - A more complex promise queue/limiter. Supports more advanced rate limiting than Queue.
  • memoize - Memoize a function, i.e. cache its results based on its parameters to skip re-computation.
  • createQueue - A simple FIFO promise queue.
  • createLimiter - A more complex promise queue/limiter. Supports more advanced rate limiting than Queue.
  • createDataLoader - DataLoader implementation similar to dataloader

LRU

An ever so slightly modified version of flru by lukeed, the fastest and smallest LRU cache I've benchmarked.

Note: It will keep store (and return) the last max * 2 items in memory. When the cache reaches max * 2 + 1 it will evict the current stale entries.

import { createLRU } from "alleviate"

const lru = createLRU({ max: 3 })

lru.set("foo", "bar")
lru.has("foo") // true
lru.get("foo") // "bar", marks "foo" as most recently used
lru.peek("foo") // "bar", does not affect LRU order

lru.setMany({
	biz: "baz",
	lorem: "ipsum",
})
lru.setMany([
	["0", "0"],
	["1", "1"],
	["2", "3"],
])

lru.clear()

TTL Map

A simple TTL Map that evicts entries after a given expiration time.

import { createTTLMap } from "alleviate"

const cache = createTTLMap({ ttl: 60_000 })

cache.set("foo", "bar")
cache.has("foo") // true, does not affect TTL
cache.get("foo") // "bar", refreshes TTL unless `getRefreshesTTL` is false
cache.peek("foo") // "bar", does not affect TTL
cache.clear()

Memoize

Memoize a function, i.e. cache its results based on its parameters to skip re-computation.

import { memoize } from "alleviate"

const fibonacci = memoize((num: number) => {
	/* ... */
})
fibonacci(100)
fibonacci(100) // skips executing function, returns cached result

const memoized = memoize(fn, {
	max: 100, // number of cached results to keep before evicting the oldest
	keepNullish: true, // whether to cache nullish results (null, undefined). Defaults to `false`
	serialize: (params) => {}, // custom parameter serialization for the cache key. Defaults to `fnv1a-64(object-identity(data))`
})

Queue

An intentionally simple promise queue that only accepts a concurrency option.

For more advanced promise limiting (timeouts, pools, etc.), see Limiter.

import { createQueue } from "alleviate"

const queue = createQueue({ concurrency: 4 })

// run a function asap
const response = await queue.run(() => fetch("https://example.com"))

// wrap a function to run it later, or multiple times
const callExample = queue.wrap((path: string) => fetch(`https://example.com/${path}`))
await callExample("foo")

Limiter

Intended as a replacement for bottleneck, p-queue.

import { createLimiter } from "alleviate"

const limiter = createLimiter({
	concurrency: 4, // How many promises can be running at once (defaults to 3/4ths of available threads)
	pool: 4, // Max number of calls before blocking (defaults to `concurrency`)
	initial: 16, // How much the pool starts with (defaults to `pool`)
	refill: 60, // How much the pool increases per `refillInterval` (defaults to `pool`)
	refillInterval: 1000, // How often the pool is refilled in ms
	refillOverLimit: false, // Whether the pool should be refilled over its limit
	timeout: null, // How long to wait in ms for a call to resolve before rejecting
})

const response = await limiter.run(() => fetch("https://example.com"))

const callExample = limiter.wrap((path: string) => fetch(`https://example.com/${path}`))
await callExample("foo")

// If `timeout` is set, `.run()` will receive an AbortSignal.
const limiter = createLimiter({ timeout: 100 })
const response = await limiter.run((signal) => fetch("https://example.com", { signal }))

/* -- Examples -- */

// 60 requests per minute
const limiter = createLimiter({
	concurrency: 16,
	pool: 60,
	refillInterval: 60_000,
})

// 60 requests per minute, more spread out
const limiter = createLimiter({
	concurrency: 16,
	pool: 60,
	initial: 16,
	refill: 10,
	refillInterval: 10_000,
})

updated 2026-06-22

| library | install size | bundle size | external sync (e.g. redis) | reservoir-style limiting | | ------------ | -------------- | ------------- | -------------------------- | ------------------------ | | alleviate | 22kB | 1.1kB | ❌ | ✅ | | p-queue | 171kB (+777%) | 12kB (+1091%) | ❌ | ❌ | | bottleneck | 629kB (+2859%) | 61kb (+5545%) | ✅ | ✅ |

DataLoader

Easily batch and cache async function calls (e.g. requests).

const dataloader = createDataLoader<string, number>({
	// The loader function receives a batch of keys passed into `load` and `loadMany`
	// and must returns an array where the items must match the order of the keys.
	loader: async (keys: string[]): Promise<number[]> => {
		const result = await fetchData(keys)
		return keys.map((key) => result[key])
	},
	// Whether to cache results. Also accepts `Map`s.
	cache: true,
	// Allows customizing how the keys are serialized for caching. Defaults to `object-identity`.
	cacheKeyFn: (key): string => key,
	// Whether to cache errors *returned* by the loader (not the loader throwing)
	cacheErrors: true,
	// Whether to limit batch sizes and by how much. Defaults to no max batch size.
	maxBatchSize: 25,
})