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

minilru

v1.0.2

Published

An extremely tiny LRU cache

Readme

minilru

A very minimal LRU cache implementation, with hardly any features and very little code.

This implementation is basically just a JavaScript Map object that relies on the fact that insertion order matches iteration order, to prune the least recently used items out when it hits a certain size.

There is no support for TTL, async fetching, stale-while-revalidate, storing to a back end, or anything else fancy. If you're interested in those types of features, I'd recommend checking out lru-cache or @isaacs/ttlcache.

USAGE

import { MiniLRU } from 'minilru'

// MiniLRU<K, V> just like Map<K, V>
const cache = new MiniLRU<string, number>({ max: 100 })
// you can also seed it with stuff if you want
const cacheSeeded = new MiniLRU<string, number>({ max: 100 }, [
  ['key', 123],
  ['otherkey', 234],
])

// Iteration order is based on use recency
// As new items are added, old ones are removed if needed,
// to stay below the size limit.

Caveats and Performance

Because this is basically a thin wrapper around a JavaScript Map, it has some caveats.

First of all, you can't put more than 2**22 (4_194_304) items in this cache, or else it blows up. So the max option is capped at that value.

Second, you really wouldn't want to put that many objects in it, because JavaScript Map objects are really tuned for best performance with relatively small numbers of entries, like on the order of thousands, not millions.

Basically, this is a good choice if your max is somewhere in the neighborhood of 2**10 to 2**12, where this library will be about as fast as anything else you can get in JS. After that, especially when you get around 2**18 or so, the performance falls off a cliff, badly.

If you need to store more things, I recommend using something that does its own memory management, like lru-cache.