side-channel
Store information about any JS value in a side channel. Uses WeakMap if available.
Last updated 6 months ago by ljharb .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ npm install side-channel 
SYNC missed versions from official npm registry.

side-channel Version Badge

github actions coverage License Downloads

npm badge

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

npm install --save side-channel

Usage/Examples

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

Current Tags

  • 1.1.1                                ...           latest (6 months ago)

8 Versions

  • 1.1.1                                ...           6 months ago
  • 1.1.0                                ...           2 years ago
  • 1.0.6                                ...           3 years ago
  • 1.0.5                                ...           3 years ago
  • 1.0.4                                ...           6 years ago
  • 1.0.3                                ...           6 years ago
  • 1.0.2                                ...           7 years ago
  • 1.0.1                                ...           7 years ago
Maintainers (1)
Downloads
Total 46
Today 0
This Week 4
This Month 19
Last Day 0
Last Week 1
Last Month 18
Dependencies (5)
Dev Dependencies (15)

© 2010 - cnpmjs.org x YWFE | Home | YWFE