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

@youneed/core

v0.1.0

Published

Foundational primitives shared across @youneed packages: shared types, the class-metadata registry (TC39 addInitializer + WeakMap, esbuild/tsx-safe), and disposal helpers.

Readme

@youneed/core

Foundational primitives shared across the @youneed/* packages. Three tiny, zero-dependency pieces that every other framework in the monorepo builds on:

  1. Shared types — common type aliases that were independently re-declared in @youneed/dom, @youneed/server and @youneed/test.
  2. The class-metadata registry — the decorator pattern every @youneed framework is built on, and the reason they all work under esbuild/tsx (where Symbol.metadata is never emitted).
  3. Disposal helpers — bridge plain cleanup functions to JS using / await using and the TC39 explicit-resource-management protocol.

You rarely import this directly — @youneed/dom, -server, -ssr, -test, -cli re-export or consume it. Reach for it when authoring your own decorator-driven base class (a Component/Controller/Test-style factory).

Install

pnpm add @youneed/core

The class-metadata registry

Component (dom), Controller (server), Page (ssr) and Test/Fixture (test) all share one mechanism: a TC39 decorator records what a member is into a per-class store, and the runtime reads it back at construction. The store is a WeakMap keyed by the class constructor (garbage-collected with the class) and is populated from a decorator's ctx.addInitializer callback — where this is the instance being constructed, so its .constructor is the user's most-derived class. This is the esbuild/tsx-safe alternative to decorator metadata.

import { createRegistry, ctorOf, classChain } from "@youneed/core";

interface FieldMeta { name: string; prop: string; }
const FIELDS = createRegistry<FieldMeta[]>(() => []);

// A field decorator that records itself into the most-derived class's entry.
function field(name: string) {
  return function (_v: unknown, ctx: ClassFieldDecoratorContext) {
    ctx.addInitializer(function (this: object) {
      FIELDS.for(ctorOf(this)).push({ name, prop: String(ctx.name) });
    });
  };
}

// The runtime reads it back, walking the inheritance chain most-derived first.
function fieldsOf(instance: object): FieldMeta[] {
  const all: FieldMeta[] = [];
  for (const c of classChain(ctorOf(instance))) all.push(...(FIELDS.read(c) ?? []));
  return all;
}
  • createRegistry<T>(create)Registry<T>for(ctor) lazily creates the entry (decorators write into it), read(ctor) returns it without creating one (the runtime reads it back), has(ctor).
  • ctorOf(self) — the constructor of this, for use inside an addInitializer callback (the user's concrete subclass).
  • classChain(ctor, stopAt?) — generator over the constructor chain, most-derived first, stopping before Object (and before stopAt, e.g. HTMLElement for custom elements, so the walk covers only user classes).

Disposal helpers

Turn a plain cleanup function into a disposable, and call disposers uniformly — sync or async. Originated in @youneed/test fixture teardown.

import { dispose, isDisposable, disposeValue } from "@youneed/core";

// Make a value disposable in place (e.g. returned from a setup function):
const conn = dispose(openConnection(), async () => closeConnection());
{
  await using c = conn; // closed on scope exit
}

// Or call a disposer manually (no-op if the value carries none):
await disposeValue(conn);

dispose(cleanup) returns a bare Disposable/AsyncDisposable; dispose(value, cleanup) attaches the disposer to value and returns it. An async cleanup gets [Symbol.asyncDispose], a sync one [Symbol.dispose] — so both using and await using work. isDisposable(v) tests for either disposer; disposeValue(v) awaits whichever is present.

Shared types

MaybePromise<T>, Constructor<T>, AbstractConstructor<T>, AnyConstructor<T> — the one definition the other packages key class-level metadata by.