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

@streetjs/store

v1.0.0

Published

StreetJS backing-store abstractions: pluggable KeyValueStore, CounterStore, and RateLimitStore interfaces with deterministic, clock-injectable in-memory sliding-window implementations for rate limiting and abuse counters. Zero runtime dependencies.

Readme

@streetjs/store

The StreetJS backing-store abstractions: small, pluggable KeyValueStore, CounterStore, and RateLimitStore interfaces plus deterministic, clock-injectable in-memory implementations. The sliding-window stores back rate limiting and abuse counters and are drop-in interchangeable with future shared (e.g. Redis) implementations. Zero runtime dependencies, ESM.

This is the standalone home of the stores that also back the streetjs framework's rate limiter and abuse engine. The framework re-exports this package, so there is a single source of truth.

Install

npm install @streetjs/store

Usage

import { InMemoryRateLimitStore } from '@streetjs/store';

const store = new InMemoryRateLimitStore();
const now = Date.now();
const hits = await store.hit('ip:1.2.3.4', now, 60_000); // hits in the last 60s
if (hits > 100) reject();

All timing is driven by explicit nowMs arguments and an optional injected clock, so window behavior is fully deterministic in tests.

Interfaces

  • RateLimitStore — hit(key, nowMs, windowMs) records a hit and returns the count in the window; count(...) reads without recording.
  • CounterStore — increment/count/reset for abuse-style counters.
  • KeyValueStore — get/set(…, ttlMs?)/delete for small opaque values.
  • Clock — () => number now-provider; systemClock is the default.

In-memory implementations

InMemoryRateLimitStore

A bounded sliding window over a Map<string, number[]> of timestamps. Options:

| Option | Default | Description | | ------ | ------- | ----------- | | clock | systemClock | Injected now-provider. | | maxKeys | 100000 | Distinct keys before oldest-key eviction. | | maxRequestsPerKey | 1000 | Cap on stored timestamps per key. | | sweepIntervalMs | — | Enables a periodic memory sweep (with retentionMs). | | retentionMs | — | Retention horizon for the sweep. |

Also exposes count, reset, size, now, and destroy. When at maxRequestsPerKey, it stops storing but still reports the capped count so the limiter rejects correctly.

InMemoryCounterStore

CounterStore built on the same window logic — the default for abuse counters.

InMemoryKeyValueStore

KeyValueStore with optional per-entry TTL evaluated lazily on read against the injected clock, plus clear().

Example

A complete runnable example lives in src/examples/integration.ts:

npm run example -w packages/store

License

MIT — see LICENSE.