# @abraham/reflection

> Lightweight ES Module implementation of reflect-metadata

Latest version **0.13.0** (published 2025-03-08) · MIT license · 0 weekly downloads

## Install

```sh
npm install @abraham/reflection
pnpm add @abraham/reflection
yarn add @abraham/reflection
bun add @abraham/reflection
```

## Health

**Score 55/100 (C)** — status: stable.

Positive: has types; esm support; no vulnerabilities; has provenance; high quality score.

Warnings: low downloads; pre 1.0.

Negative: stale.

## Facts

| | |
|---|---|
| Version | 0.13.0 |
| Published | 2025-03-08 |
| First published | 2018-07-23 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 0 |
| Unpacked size | 30.3 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Provenance | attested (GitHub Actions) |
| GitHub stars | 284 |
| Author | Abraham Williams |
| Maintainers | abraham |
| Keywords | typescript, reflect, reflect-metadata, metadata, lightweight, micro, library, decorator |

## Links

- npm: https://www.npmjs.com/package/@abraham/reflection
- Repository: https://github.com/abraham/reflection
- Homepage: https://github.com/abraham/reflection#readme
- Issues: https://github.com/abraham/reflection/issues
- npm.io page: https://npm.io/package/@abraham/reflection

## Alternatives

- [@openai/codex-sdk](https://npm.io/package/@openai/codex-sdk.md) — 731.4K weekly downloads
- [babel-plugin-transform-react-jsx](https://npm.io/package/babel-plugin-transform-react-jsx.md) — 565.0K weekly downloads
- [babel-helper-remove-or-void](https://npm.io/package/babel-helper-remove-or-void.md) — 508.5K weekly downloads
- [@pnpm/store-controller-types](https://npm.io/package/@pnpm/store-controller-types.md) — 186.9K weekly downloads
- [react-native-signature-canvas](https://npm.io/package/react-native-signature-canvas.md) — 155.6K weekly downloads

## Recent versions

- 0.13.0 (latest) — 2025-03-08
- 0.12.0 — 2023-02-06
- 0.11.0 — 2022-10-05
- 0.10.0 — 2022-03-22
- 0.9.1 — 2022-02-19
- 0.9.0 — 2022-02-19
- 0.8.0 — 2021-05-10
- 0.7.0 — 2019-10-30
- 0.6.0 — 2019-10-06
- 0.5.1 — 2019-01-29
- 0.5.0 — 2019-01-22
- 0.4.2 — 2018-08-02
- 0.4.1 — 2018-07-26
- 0.4.0 — 2018-07-26
- 0.3.0 — 2018-07-24
- … 5 more at https://npm.io/package/@abraham/reflection/versions

## README

[![Version Status](https://img.shields.io/npm/v/@abraham/reflection.svg?style=flat&label=version&colorB=4bc524)](https://npmjs.com/package/@abraham/reflection)
[![Build Status](https://github.com/abraham/reflection/workflows/Index/badge.svg)](https://github.com/abraham/reflection/actions)
[![npm bundle size (minified + gzip)](https://img.shields.io/bundlephobia/minzip/@abraham/reflection.svg?style=flat&colorB=4bc524)](https://bundlephobia.com/result?p=@abraham/reflection)
[![Coverage Status](https://coveralls.io/repos/github/abraham/reflection/badge.svg?branch=master)](https://coveralls.io/github/abraham/reflection?branch=master)

# Reflection

Lightweight ES Module implementation of [reflect-metadata](https://github.com/rbuckton/reflect-metadata/) to work with TypeScript's [experimental decorator support](https://www.typescriptlang.org/docs/handbook/decorators.html).

## 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)
  - [`reflect-metadata`](https://github.com/rbuckton/reflect-metadata) is ~50K
  - [`core-js/es7/reflect`](https://github.com/zloirock/core-js) is ~80K
  - `@abraham/reflection` is ~3K

Read about how to [drop 20K from your production Angular app](https://bendyworks.com/blog/drop-20k-from-your-production-angular-app) by switching to this.

## Install

```sh
npm install @abraham/reflection
```

## Usage

```ts
import '@abraham/reflection';
Reflect.defineMetadata(metadataKey, metadataValue, target);
```

You can also import `Reflection`:

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

## API

Reflection does not currently cover the complete API surface of reflect-metadata. The following methods are available:

```ts
Reflect.decorate(...);
Reflect.defineMetadata(...);
Reflect.getMetadata(...);
Reflect.hasMetadata(...);
Reflect.getOwnMetadata(...);
Reflect.hasOwnMetadata(...);
Reflect.metadata(...);
```

---
_Source: https://npm.io/package/@abraham/reflection · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
