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

delegates-modern

v0.1.2

Published

Modern, dependency-free TypeScript-first implementation of the [email protected] core API, with ESM/CJS, first-party types, symbol support, and additive auto() delegation.

Readme

delegates-modern

CI npm version

A tiny, dependency-free, TypeScript-first object and method delegation library for Node.js.

A maintained modern implementation of the published [email protected] core API: delegate methods, getters, setters, accessors, and fluent properties. It also adds modern ESM/TypeScript packaging, symbol support, and an additive auto() helper.

Why this exists

delegates is a very small and useful primitive, but the published package has remained at 1.0.0 for more than a decade and the runtime is still a legacy CommonJS implementation. It is nevertheless still widely installed and used by Node.js projects. The goal here is not to make a larger framework; it is to keep the same focused primitive while modernizing the implementation and distribution surface.

delegates-modern provides:

  • the established method(), getter(), setter(), access(), and fluent() operations
  • ESM and CommonJS
  • first-party TypeScript declarations
  • symbol property support
  • standards-based Object.defineProperty descriptors
  • explicit descriptor behavior and legacy-compatible runtime semantics
  • zero runtime dependencies

Install

npm install delegates-modern

Basic usage

import delegate from 'delegates-modern'

const context = {
  request: {
    path: '/users',
    accepts(type) {
      return `${type}:${this.path}`
    },
  },
}

delegate(context, 'request')
  .method('accepts')
  .getter('path')

context.path // '/users'
context.accepts('json') // 'json:/users'

API

delegate(proto, target)

Creates a Delegator that forwards members from proto[target].

.method(name)

Delegates a method. The target object is preserved as the method's this value.

.getter(name)

Delegates property reads.

.setter(name)

Delegates property writes.

.access(name)

Creates both a getter and setter.

.fluent(name)

Creates a method-like accessor. With no defined value it reads the target property; with a defined value it writes the target property and returns the host object for chaining. This preserves the established delegates behavior where undefined is treated as a read.

Delegator.auto(proto, targetProto, targetProp)

Modern additive API. [email protected] does not expose auto(). The helper inspects the target object's own property descriptors and delegates methods, getters, setters, and data properties automatically. It additionally discovers symbol keys.

TypeScript

The package ships its own declarations and generic host/target types:

interface Request {
  path: string
  accepts(type: string): boolean
}

interface Context {
  request: Request
}

delegate<Context, Request>(Context.prototype, 'request')
  .method('accepts')
  .getter('path')

Compatibility

The published [email protected] core API and its observable behavior are the compatibility target. Modern additions such as auto() and symbol discovery are explicitly additive.

See COMPATIBILITY.md for the exact compatibility surface and intentional improvements.

Quality

  • compatibility and edge-case tests
  • symbol tests
  • auto() descriptor classification tests
  • CommonJS/ESM verification
  • differential compatibility tests against [email protected]
  • type-level tests
  • benchmarks
  • Node 18/20/22/24/26 CI across Linux, Windows, and macOS (ARM64 primary; Intel smoke test)
  • zero runtime dependencies
npm install
npm run check
npm run coverage
npm run bench
npm run pack:check

License

MIT