side-channel
Store information about any JS value in a side channel. Uses WeakMap if available.
Last updated a year ago by ljharb .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm 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.0                                ...           latest (a year ago)

7 Versions

  • 1.1.0                                ...           a year ago
  • 1.0.6                                ...           2 years ago
  • 1.0.5                                ...           2 years ago
  • 1.0.4                                ...           5 years ago
  • 1.0.3                                ...           6 years ago
  • 1.0.2                                ...           6 years ago
  • 1.0.1                                ...           6 years ago
Maintainers (1)
Downloads
Today 1
This Week 93
This Month 154
Last Day 16
Last Week 111
Last Month 705
Dependencies (5)
Dev Dependencies (15)

Copyright 2013 - present © cnpmjs.org | Home |