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

@earthos/providers

v0.2.0

Published

EarthOS data provider framework: SWR caching, polling, streaming, rate limits

Readme

@earthos/providers

The EarthOS data layer: base classes that turn a plain fetch into a resilient, cache-backed feed for a globe layer.

A provider owns one dataset. You implement how to fetch and parse it; the base class owns the runtime around that call: stale-while-revalidate emits (cached data first, fresh data on arrival), jittered polling, exponential backoff with Retry-After honored, per-origin token-bucket rate limiting, viewport-scoped refetch, pause-when-hidden, and teardown on stop/abort. Providers are plain classes with no React or Three dependency, driven by the engine through the @earthos/core ProviderInstance contract.

Install

pnpm add @earthos/providers

Pulls in @earthos/core (the runtime types and MemoryCache) as a dependency. No single-instance peers.

Usage

Subclass the variant that matches the source, set a policy, implement that variant's abstract member (see Variants below). For an HTTP feed that is fetch:

import { DataProvider, type FetchIO } from '@earthos/providers';

interface Quakes {
  /* your parsed shape */
}

export class UsgsQuakesProvider extends DataProvider<Quakes> {
  readonly id = 'usgs/quakes';

  constructor() {
    super();
    this.policyOverrides = {
      refresh: { intervalMs: 60_000, jitterMs: 5_000, pauseWhenHidden: true },
      cache: { staleAfterMs: 5 * 60_000, maxAgeMs: 60 * 60_000 },
      rateLimit: { tokensPerMinute: 30, scope: 'origin' },
    };
  }

  // `fetch` here is instrumented: it throws HttpError / RetryAfterError on bad status.
  async fetch({ fetch, signal }: FetchIO): Promise<Quakes> {
    const res = await fetch('https://earthquake.usgs.gov/.../all_hour.geojson', { signal });
    return res.json();
  }
}

Override cacheKey(settings) when the payload depends on a setting, and merge(prev, next) for incremental feeds.

Variants

| Export | For | You implement | | ---------------- | ---------------------------------------------------------------- | -------------------------- | | DataProvider | polling HTTP sources with the full SWR runtime | fetch(io: FetchIO) | | StaticProvider | fetch-once datasets (bundled files, user uploads) | fetch(io: FetchIO) | | StreamProvider | WebSocket/SSE feeds; capped-backoff reconnect, snapshot to cache | connect(io: StreamIO<T>) | | TileProvider | raster/vector tile layers; emits a TileDescriptor, no fetch | describe(settings) |

Every variant also needs a readonly id. StreamProvider.connect returns a Disposer (or a promise of one) and pushes updates through io.push; TileProvider.describe returns the descriptor synchronously and is re-run on refresh().

Also exported

  • createDefaultCache, LayeredCache, IdbCache: memory LRU in front of IndexedDB (memory-only under SSR/tests), all failures degrade to cache misses.
  • DEFAULT_POLICY, mergePolicy, and the ProviderPolicy / RefreshPolicy / CachePolicy / RetryPolicy / RateLimitPolicy types.
  • HttpError, RetryAfterError, parseRetryAfterMs, rateLimitWaitMs, resetRateLimiters.
  • The per-variant IO types: FetchIO (DataProvider / StaticProvider) and StreamIO (StreamProvider), plus TileDescriptor.

See docs/PLUGIN_GUIDE.md for wiring a provider into a layer and docs/ARCHITECTURE.md for how the engine drives it.

Part of EarthOS. MIT licensed.