1 | # side-channel-list <sup>[![Version Badge][npm-version-svg]][package-url]</sup>
|
---|
2 |
|
---|
3 | [![github actions][actions-image]][actions-url]
|
---|
4 | [![coverage][codecov-image]][codecov-url]
|
---|
5 | [![License][license-image]][license-url]
|
---|
6 | [![Downloads][downloads-image]][downloads-url]
|
---|
7 |
|
---|
8 | [![npm badge][npm-badge-png]][package-url]
|
---|
9 |
|
---|
10 | Store information about any JS value in a side channel, using a linked list.
|
---|
11 |
|
---|
12 | Warning: this implementation will leak memory until you `delete` the `key`.
|
---|
13 | Use [`side-channel`](https://npmjs.com/side-channel) for the best available strategy.
|
---|
14 |
|
---|
15 | ## Getting started
|
---|
16 |
|
---|
17 | ```sh
|
---|
18 | npm install --save side-channel-list
|
---|
19 | ```
|
---|
20 |
|
---|
21 | ## Usage/Examples
|
---|
22 |
|
---|
23 | ```js
|
---|
24 | const assert = require('assert');
|
---|
25 | const getSideChannelList = require('side-channel-list');
|
---|
26 |
|
---|
27 | const channel = getSideChannelList();
|
---|
28 |
|
---|
29 | const key = {};
|
---|
30 | assert.equal(channel.has(key), false);
|
---|
31 | assert.throws(() => channel.assert(key), TypeError);
|
---|
32 |
|
---|
33 | channel.set(key, 42);
|
---|
34 |
|
---|
35 | channel.assert(key); // does not throw
|
---|
36 | assert.equal(channel.has(key), true);
|
---|
37 | assert.equal(channel.get(key), 42);
|
---|
38 |
|
---|
39 | channel.delete(key);
|
---|
40 | assert.equal(channel.has(key), false);
|
---|
41 | assert.throws(() => channel.assert(key), TypeError);
|
---|
42 | ```
|
---|
43 |
|
---|
44 | ## Tests
|
---|
45 |
|
---|
46 | Clone the repo, `npm install`, and run `npm test`
|
---|
47 |
|
---|
48 | [package-url]: https://npmjs.org/package/side-channel-list
|
---|
49 | [npm-version-svg]: https://versionbadg.es/ljharb/side-channel-list.svg
|
---|
50 | [deps-svg]: https://david-dm.org/ljharb/side-channel-list.svg
|
---|
51 | [deps-url]: https://david-dm.org/ljharb/side-channel-list
|
---|
52 | [dev-deps-svg]: https://david-dm.org/ljharb/side-channel-list/dev-status.svg
|
---|
53 | [dev-deps-url]: https://david-dm.org/ljharb/side-channel-list#info=devDependencies
|
---|
54 | [npm-badge-png]: https://nodei.co/npm/side-channel-list.png?downloads=true&stars=true
|
---|
55 | [license-image]: https://img.shields.io/npm/l/side-channel-list.svg
|
---|
56 | [license-url]: LICENSE
|
---|
57 | [downloads-image]: https://img.shields.io/npm/dm/side-channel-list.svg
|
---|
58 | [downloads-url]: https://npm-stat.com/charts.html?package=side-channel-list
|
---|
59 | [codecov-image]: https://codecov.io/gh/ljharb/side-channel-list/branch/main/graphs/badge.svg
|
---|
60 | [codecov-url]: https://app.codecov.io/gh/ljharb/side-channel-list/
|
---|
61 | [actions-image]: https://img.shields.io/endpoint?url=https://github-actions-badge-u3jn4tfpocch.runkit.sh/ljharb/side-channel-list
|
---|
62 | [actions-url]: https://github.com/ljharb/side-channel-list/actions
|
---|