source: imaps-frontend/node_modules/side-channel-weakmap/README.md

main
Last change on this file was 79a0317, checked in by stefan toskovski <stefantoska84@…>, 3 days ago

F4 Finalna Verzija

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