# side-channel

> Store information about any JS value in a side channel. Uses WeakMap if available.

Latest version **1.1.1** (published 2026-06-08) · MIT license · 0 weekly downloads

## Install

```sh
npm install side-channel
pnpm add side-channel
yarn add side-channel
bun add side-channel
```

## Health

**Score 60/100 (C)** — status: active.

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

Warnings: low downloads.

## Facts

| | |
|---|---|
| Version | 1.1.1 |
| Published | 2026-06-08 |
| First published | 2019-12-02 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Node | >= 0.4 |
| Dependencies | 5 |
| Unpacked size | 22.3 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 17 |
| Author | Jordan Harband |
| Maintainers | ljharb |
| Keywords | weakmap, map, side, channel, metadata |

## Links

- npm: https://www.npmjs.com/package/side-channel
- Repository: https://github.com/ljharb/side-channel
- Homepage: https://github.com/ljharb/side-channel#readme
- Issues: https://github.com/ljharb/side-channel/issues
- Funding: https://github.com/sponsors/ljharb
- npm.io page: https://npm.io/package/side-channel

## Dependencies (5)

- [es-errors](https://npm.io/package/es-errors.md) ^1.3.0
- [object-inspect](https://npm.io/package/object-inspect.md) ^1.13.4
- [side-channel-map](https://npm.io/package/side-channel-map.md) ^1.0.1
- [side-channel-list](https://npm.io/package/side-channel-list.md) ^1.0.1
- [side-channel-weakmap](https://npm.io/package/side-channel-weakmap.md) ^1.0.2

## Alternatives

- [@sindresorhus/slugify](https://npm.io/package/@sindresorhus/slugify.md) — 3.7M weekly downloads
- [solid-js](https://npm.io/package/solid-js.md) — 2.7M weekly downloads
- [expo-glass-effect](https://npm.io/package/expo-glass-effect.md) — 2.5M weekly downloads
- [nanoassert](https://npm.io/package/nanoassert.md) — 780.8K weekly downloads
- [@ffmpeg/ffmpeg](https://npm.io/package/@ffmpeg/ffmpeg.md) — 529.5K weekly downloads

## Recent versions

- 1.1.1 (latest) — 2026-06-08
- 1.1.0 — 2024-12-11
- 1.0.6 — 2024-02-29
- 1.0.5 — 2024-02-06
- 1.0.4 — 2020-12-29
- 1.0.3 — 2020-08-23
- 1.0.2 — 2019-12-20
- 1.0.1 — 2019-12-02

## README

# side-channel <sup>[![Version Badge][npm-version-svg]][package-url]</sup>

[![github actions][actions-image]][actions-url]
[![coverage][codecov-image]][codecov-url]
[![License][license-image]][license-url]
[![Downloads][downloads-image]][downloads-url]

[![npm badge][npm-badge-png]][package-url]

Store information about any JS value in a side channel. Uses WeakMap if available.

Warning: in an environment that lacks `WeakMap`, this implementation will leak memory until you `delete` the `key`.

## Getting started

```sh
npm install --save side-channel
```

## Usage/Examples

```js
const assert = require('assert');
const getSideChannel = require('side-channel');

const channel = getSideChannel();

const key = {};
assert.equal(channel.has(key), false);
assert.throws(() => channel.assert(key), TypeError);

channel.set(key, 42);

channel.assert(key); // does not throw
assert.equal(channel.has(key), true);
assert.equal(channel.get(key), 42);

channel.delete(key);
assert.equal(channel.has(key), false);
assert.throws(() => channel.assert(key), TypeError);
```

## Tests

Clone the repo, `npm install`, and run `npm test`

[package-url]: https://npmjs.org/package/side-channel
[npm-version-svg]: https://versionbadg.es/ljharb/side-channel.svg
[deps-svg]: https://david-dm.org/ljharb/side-channel.svg
[deps-url]: https://david-dm.org/ljharb/side-channel
[dev-deps-svg]: https://david-dm.org/ljharb/side-channel/dev-status.svg
[dev-deps-url]: https://david-dm.org/ljharb/side-channel#info=devDependencies
[npm-badge-png]: https://nodei.co/npm/side-channel.png?downloads=true&stars=true
[license-image]: https://img.shields.io/npm/l/side-channel.svg
[license-url]: LICENSE
[downloads-image]: https://img.shields.io/npm/dm/side-channel.svg
[downloads-url]: https://npm-stat.com/charts.html?package=side-channel
[codecov-image]: https://codecov.io/gh/ljharb/side-channel/branch/main/graphs/badge.svg
[codecov-url]: https://app.codecov.io/gh/ljharb/side-channel/
[actions-image]: https://img.shields.io/github/check-runs/ljharb/side-channel/main
[actions-url]: https://github.com/ljharb/side-channel/actions

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