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

@abraham/reflection

v0.14.0

Published

Lightweight ES Module implementation of reflect-metadata

Readme

Version Status Build Status npm bundle size (minified + gzip)

Reflection

Lightweight ES Module implementation of reflect-metadata to work with TypeScript's experimental decorator support, plus a matching API for standard decorators and decorator metadata.

Why?

The main reason for this library is to provide a much smaller implementation that can be included as a module.

  • ES module
    • reflection can be loaded with <script type="module" src="..."></script>
  • Size (uncompressed)

Read about how to drop 20K from your production Angular app by switching to this.

Install

npm install @abraham/reflection

Which import?

Use the one that matches how your project compiles decorators. A project uses one or the other, not both.

| | @abraham/reflection/legacy (default) | @abraham/reflection/standard | | -------------------- | ------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------- | | Decorators | Legacy: experimentalDecorators: true | Standard: TypeScript 5.2+ without experimentalDecorators, or Babel | | Type metadata | design:type, design:paramtypes, design:returntype with emitDecoratorMetadata | Not available | | Parameter decorators | Yes | No | | Globals | Adds methods to Reflect | Defines Symbol.metadata and Function.prototype[Symbol.metadata] (null) if missing, as in the spec | | Module formats | ES module and UMD/CommonJS | ES module |

Use @abraham/reflection/legacy for code written for reflect-metadata, including frameworks that rely on emitDecoratorMetadata for dependency injection. The bare @abraham/reflection import is the same module, so existing imports keep working and both can be mixed.

Use @abraham/reflection/standard for new code on standard decorators. They don't pass the class to member decorators, so Reflect.defineMetadata can't be used; metadata goes through the decorator's context.metadata instead.

Usage

Experimental decorators

tsconfig.json:

{
  "compilerOptions": {
    "experimentalDecorators": true,
    // Only needed for design:type, design:paramtypes, and design:returntype
    "emitDecoratorMetadata": true,
    // Needed for the ./legacy subpath; the bare import resolves with any setting
    "moduleResolution": "bundler", // or "nodenext"
  },
}
import '@abraham/reflection/legacy'; // or '@abraham/reflection'
Reflect.defineMetadata(metadataKey, metadataValue, target);

You can also import Reflection:

import { Reflection as Reflect } from '@abraham/reflection/legacy';
Reflect.defineMetadata(metadataKey, metadataValue, target);

Standard decorators

Requires TypeScript 5.2 or later. tsconfig.json:

{
  "compilerOptions": {
    // Leave experimentalDecorators and emitDecoratorMetadata unset or false
    // Any target except ESNext, which leaves @decorator syntax untransformed
    "target": "ES2022",
    // Needed to resolve the ./standard subpath export
    "moduleResolution": "bundler", // or "nodenext"
    // Only needed to type Symbol.metadata in your own code; add to your existing lib
    "lib": ["ES2022", "ESNext.Decorators"],
  },
}

Import it before any decorated class is defined, so Symbol.metadata exists when the class is created.

import { metadata, getMetadata } from '@abraham/reflection/standard';

@metadata('role', 'admin')
class User {
  @metadata('column', 'email')
  email = '';

  @metadata('route', '/users')
  static list() {}
}

getMetadata('role', User); // 'admin'
getMetadata('column', User.prototype, 'email'); // 'email'
getMetadata('column', new User(), 'email'); // 'email'
getMetadata('route', User, 'list'); // '/users'

Targets follow reflect-metadata: the class for class and static member metadata, and the prototype or an instance for instance member metadata. Subclasses inherit metadata and can override it. Values are stored privately, so the class's shared Symbol.metadata object is left for other libraries.

API

@abraham/reflection/legacy

The following methods are available:

Reflect.decorate(...);
Reflect.defineMetadata(...);
Reflect.deleteMetadata(...);
Reflect.getMetadata(...);
Reflect.getMetadataKeys(...);
Reflect.getOwnMetadata(...);
Reflect.getOwnMetadataKeys(...);
Reflect.hasMetadata(...);
Reflect.hasOwnMetadata(...);
Reflect.metadata(...);

@abraham/reflection/standard

metadata(metadataKey, metadataValue); // decorator for classes, methods, getters, setters, fields, and accessors
getMetadata(metadataKey, target, memberKey?);
getMetadataKeys(target, memberKey?);
getOwnMetadata(metadataKey, target, memberKey?);
getOwnMetadataKeys(target, memberKey?);
hasMetadata(metadataKey, target, memberKey?);
hasOwnMetadata(metadataKey, target, memberKey?);