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

@bybrave/node-cache2

v6.0.1

Published

Maintained node-cache fork: rewritten from CoffeeScript to modern ESM, zero runtime dependencies, Map-backed storage, generic TypeScript types. Drop-in for node-cache.

Readme

@bybrave/node-cache2

Maintained fork of node-cache — simple and fast in-memory caching.

Rewritten from CoffeeScript to modern ESM, zero runtime dependencies, Map-backed storage, dual ESM + CommonJS, and generic TypeScript types. Same API.

Install

npm install @bybrave/node-cache2

Usage

import NodeCache from '@bybrave/node-cache2';

const cache = new NodeCache({ stdTTL: 100, checkperiod: 120 });

cache.set('myKey', { any: 'value' });
cache.get('myKey'); // { any: 'value' }

CommonJS works too — require returns the class directly:

const NodeCache = require('@bybrave/node-cache2');

Typed cache (#273)

The class takes an optional type parameter, so a typed cache infers get/set/take without per-call generics:

import NodeCache from '@bybrave/node-cache2';

interface User { id: number; name: string; }

const users = new NodeCache<User>();
users.set('u1', { id: 1, name: 'Ann' });
const u = users.get('u1'); // User | undefined

The full API — get, mget, set, mset, fetch, del, take, ttl, getTtl, keys, has, getStats, flushAll, flushStats, close, and the set/del/expired/flush/flush_stats events — is unchanged from node-cache.

Options

stdTTL, checkperiod, useClones, deleteOnExpire, forceString, maxKeys, enableLegacyCallbacks — same defaults and meaning as node-cache.

What's changed vs [email protected]

| Issue | Change | |---|---| | #69 | Rewritten from CoffeeScript to modern ESM. Ships native ESM with a CommonJS build via the exports map. | | #212, #286 | Storage is backed by a Map instead of a plain object — prototype-safe (a __proto__ key is just a key) and faster for churny caches. | | #273 | The class is generic: new NodeCache<MyType>() types get/set/take/mget. Per-call type parameters still work. | | #230 | Zero runtime dependencies — clone is vendored and maintained in-tree, so there is no transitive dependency to audit. |

Migration from node-cache

Drop-in — replace the import:

- const NodeCache = require('node-cache');
+ const NodeCache = require('@bybrave/node-cache2');

The public API and option defaults are unchanged. Notes for edge cases:

  • keys() still returns strings, and numeric/string keys still address the same entry (set(5, …) then get('5')), matching the original object-backed behaviour.
  • With useClones: true (the default), values are deep-cloned with the vendored clone, so objects with methods, circular references, Map/Set/Date/RegExp/Buffer all clone the same way as before.

Support

If this package saves you time, you can support maintenance:

Ko-fi Bitcoin

Bitcoin (BTC): bc1q37557q5jpeaxqydzwvf3jgj7zhnfpn2td3q40q

License

MIT. Copyright © mpneuried; vendored clone © Paul Vorbach, Blake Miner; fork © bybrave.