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

side-channel-weakmap Version Badge

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

Current Tags

  • 1.0.2                                ...           latest (2 years ago)

3 Versions

  • 1.0.2                                ...           2 years ago
  • 1.0.1                                ...           2 years ago
  • 1.0.0                                ...           2 years ago
Maintainers (1)
Downloads
Total 8
Today 0
This Week 0
This Month 4
Last Day 0
Last Week 0
Last Month 0
Dependencies (5)
Dev Dependencies (17)
Dependents (1)

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