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

@kindgi/env-inmemory

v0.8.1

Published

Reference in-memory `EnvBinding` adapter — dev + tests only; refuses to boot in production.

Readme

@kindgi/env-inmemory

Reference in-memory implementation of the EnvBinding contract from @kindgi/api: the store for non-sensitive, per-environment configuration values keyed by (scope, envName, name). Use it in tests and local development. It refuses to start under NODE_ENV=production; deployed environments use a durable EnvBinding implemented by the Kindgi runtime.

Purpose

Give every consumer of EnvBinding a store that needs no database but keeps the contract's semantics: values are partitioned by envName (a staging write is invisible to production reads), every write bumps a revision counter that supports optimistic concurrency, and resolve walks from the most specific scope to the workspace. With an AuditEventBinding attached it also emits the env-* audit events, so evidence trails can be exercised end to end in tests.

Exports

  • createInMemoryEnvBinding(options?) — returns a fresh, isolated EnvBinding backed by process memory. Throws at construction when process.env.NODE_ENV === 'production' and productionSafe is not true. The returned binding:
    • resolve — checks the requested scope, then the workspace scope (project → tenant, org → tenant). Returns { kind: 'ok', value: { name, value, revision } } or an env-not-found error.
    • get / list — exact scope only, no walk. list filters by namePrefix and tagFilter (every pair must match; untagged entries never match), sorts by name and returns at most limit entries. cursor is ignored and nextCursor is never set.
    • set — creates or overwrites; revision starts at 1 and increments on every write. A mismatched ifRevision returns { kind: 'revision-conflict', currentRevision } (0 for a name that does not exist). enqueueTuples is required by the contract but not called.
    • delete — removes the entry and returns { deleted }; a later resolve at that scope falls through to the workspace value.
  • InMemoryEnvBindingOptions:
    • productionSafe?: boolean — default false. Allows construction under NODE_ENV=production, for example in a parity-test container.
    • now?: () => number — clock used for createdAt / updatedAt; defaults to Date.now.
    • auditEvents?: AuditEventBinding, tenantId?: TenantId, projectId?: ProjectId — audit emission is enabled only when all three are set. set emits env-set (outcome failed with env-write-conflict on a revision conflict), resolve emits env-resolved, and a delete that removed something emits env-deleted. Every event is recorded under the configured tenantId / projectId, and payloads never contain the value. Emission is awaited, but a failing audit sink does not fail the operation.
    • log?: Logger (@kindgi/log) — where an audit append that fails or throws is logged, at warn. Without one, a failed append isn't logged anywhere.

Example

import { createInMemoryAuditEventBinding } from '@kindgi/audit-events-inmemory';
import { createInMemoryEnvBinding } from '@kindgi/env-inmemory';
import type { Scope } from '@kindgi/platform';
import { makeEnvName, type ProjectId, type TenantId } from '@kindgi/types';

const tenantId = 'acme' as TenantId;
const projectId = 'acme-support' as ProjectId;
const staging = makeEnvName('staging');
if (staging === null) throw new Error('invalid env name');

const tenant: Scope = { kind: 'tenant', tenantId };
const project: Scope = { kind: 'project', tenantId, projectId };

const audit = createInMemoryAuditEventBinding();
const env = createInMemoryEnvBinding({ auditEvents: audit, tenantId, projectId });

const kbUrl = { envName: staging, name: 'KB_URL' } as const;
await env.set({ scope: tenant, ...kbUrl, value: 'https://kb.acme.test', enqueueTuples: () => [] });

// The project has no value of its own, so resolution falls back to the workspace.
const resolved = await env.resolve({
  scope: project,
  ...kbUrl,
  resolveContext: { caller: 'dispatch', runId: 'run-1' },
});
if (resolved.kind === 'ok') console.log(resolved.value.value, resolved.value.revision); // https://kb.acme.test 1

// Optimistic concurrency: this write applies only while the workspace value is at revision 1.
const updated = await env.set({
  scope: tenant,
  ...kbUrl,
  value: 'https://kb-v2.acme.test',
  ifRevision: 1,
  enqueueTuples: () => [],
});
if (updated.kind === 'revision-conflict') console.warn('stale write', updated.currentRevision);

const events = await audit.query({ tenantId }); // env-set, env-resolved, env-set

Non-goals

  • Durability or cross-process sharing. State lives in one process and is lost on exit.
  • Org-level resolution for project scopes. The in-memory store has no project → org relation, so a project scope falls back straight to the workspace. Durable implementations walk project → org → tenant.
  • Secrets. Values are stored and returned in plaintext; sensitive values belong in a SecretBinding.
  • Soft delete. delete removes the entry; the contract defines env as a plain overwrite-shaped store.

Related