side-channel-weakmap <sup>Version Badge</sup>

github actions coverage License Downloads

npm badge

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

Warning: this implementation will leak memory until you delete the key. Use side-channel for the best available strategy.

Getting started

npm install --save side-channel-weakmap

Usage/Examples

const assert = require('assert');
const getSideChannelList = require('side-channel-weakmap');

const channel = getSideChannelList();

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

side-channel-weakmap - Installation

To install side-channel-weakmap via this registry, you'll need to install via the --registry parameter with your package manager.

n

NPM

npm install side-channel-weakmap --registry https://js.registry.sudovanilla.org

Learn more about the --registry parameter.

Yarn

yarn config set registry https://js.registry.sudovanilla.org
yarn install side-channel-weakmap

Learn more about the config option.

PNPM

pnpm install side-channel-weakmap --registry https://js.registry.sudovanilla.org

Learn more about the --registry parameter.

Bun Logo

Bun

bun install side-channel-weakmap --registry https://js.registry.sudovanilla.org

Learn more about the --registry parameter.

Learn more about setting this up in your bunfig.toml configuration.


For Deno, add the following to your .npmrc file in your directory:

registry="https://js.registry.sudovanilla.org"

Then run the deno install command.

side-channel-weakmap - Download

Download Tarball (v1.0.2)

Integrity sha512-WPS/HvHQTYnHisLo9McqBHOJk2FkHO/tlpvldyrnem4aeQp4hai3gythswg6p01oSoTl58rcpiFAjF2br2Ak2A==
SHASUM 11dda19d5368e40ce9ec2bdc1fb0ecbc0790ecea
Tarball https://js.registry.sudovanilla.org/side-channel-weakmap/-/side-channel-weakmap-1.0.2.tgz