iching-broker-level3/node_modules/side-channel
2025-04-09 11:10:36 +02:00
..
.github add http-server part 5 2025-04-09 11:10:36 +02:00
test add http-server part 5 2025-04-09 11:10:36 +02:00
.editorconfig add http-server part 5 2025-04-09 11:10:36 +02:00
.eslintrc add http-server part 5 2025-04-09 11:10:36 +02:00
.nycrc add http-server part 5 2025-04-09 11:10:36 +02:00
CHANGELOG.md add http-server part 5 2025-04-09 11:10:36 +02:00
index.d.ts add http-server part 5 2025-04-09 11:10:36 +02:00
index.js add http-server part 5 2025-04-09 11:10:36 +02:00
LICENSE add http-server part 5 2025-04-09 11:10:36 +02:00
package.json add http-server part 5 2025-04-09 11:10:36 +02:00
README.md add http-server part 5 2025-04-09 11:10:36 +02:00
tsconfig.json add http-server part 5 2025-04-09 11:10:36 +02:00

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