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

@c9up/eclipse

v0.1.2

Published

Eclipse — distributed locks for the Ream framework: pluggable store contract with memory + Redis drivers

Readme

@c9up/eclipse

Distributed locks for the Ream framework. One name, one holder — everything else is a store detail.

pnpm add @c9up/eclipse

Why

Without a shared lock, every instance of an application does everything: a nightly invoice run goes out N times, a cache miss recomputes N times, a job is processed N times. Nothing in the logs says so.

Configure

// config/lock.ts
import { defineConfig, stores } from "@c9up/eclipse"

export default defineConfig({
  default: "redis",
  stores: {
    memory: stores.memory(),
    redis: stores.redis({ connection: "main" }),
  },
})
// reamrc.ts
providers: [() => import("@c9up/eclipse/provider")]

stores.redis({ connection }) names a @c9up/quasar connection, resolved on the first lock — quasar is an optional peer, so an app locking in memory never installs it. Pass { client } instead to hand over a client directly.

Use

import locks from "@c9up/eclipse/services/main"

// run once across every replica; the losers do nothing
const [ran, invoices] = await locks
  .createLock("invoices:nightly", "5m")
  .runImmediately(async () => generateInvoices())

// wait for whoever holds it, then proceed — the cache-stampede shape
const [, user] = await locks
  .createLock(`user:${id}`, "30s")
  .run(async () => loadAndCacheUser(id))

run returns [true, result] or [false, null], so "ran and returned undefined" is distinguishable from "never ran".

For work whose length is genuinely unknown, take a short lease and push it out rather than taking a long one — a lease sized for the worst case is also how long the key stays stuck after a crash:

const lock = locks.createLock("import", "30s")
if (await lock.acquireImmediately()) {
  try {
    for (const batch of batches) {
      await process(batch)
      await lock.extend("30s")
    }
  } finally {
    await lock.release()
  }
}

Durations

A bare number is milliseconds (@c9up/echo is seconds-native; each is native to its own layer). Strings take the usual units: "500ms", "30s", "5m", "2h". null never expires.

With the scheduler

// config/scheduler.ts
import { defineConfig } from "@c9up/ream/scheduler/config"
import locks from "@c9up/eclipse/services/main"
import { schedulerBackend } from "@c9up/eclipse/scheduler"

export default defineConfig({ lock: schedulerBackend(() => locks) })

@c9up/ream does not depend on eclipse — the scheduler declares a narrow two-method contract and eclipse satisfies it, so the core works with no lock package installed.

Safety

Every lease carries a random owner token, and release and extend compare it inside the store — on Redis, in a Lua script, so the check and the delete are one atomic step. Without that, work that outlives its own TTL deletes the lease a different instance has since taken, freeing the name while work is still running under it.

Losing a lease mid-work is reported as E_LOCK_NOT_OWNED, uniformly across stores. Lock.run absorbs it on the way out so it cannot replace whatever your callback was throwing; a direct release() reports it.

Testing

import { fakeLocks } from "@c9up/eclipse/testing"

const restore = fakeLocks()
afterEach(restore)

License

MIT