🔧 npm update
This commit is contained in:
9
node_modules/side-channel/.editorconfig
generated
vendored
Normal file
9
node_modules/side-channel/.editorconfig
generated
vendored
Normal file
@@ -0,0 +1,9 @@
|
||||
root = true
|
||||
|
||||
[*]
|
||||
charset = utf-8
|
||||
end_of_line = lf
|
||||
insert_final_newline = true
|
||||
indent_style = tab
|
||||
indent_size = 2
|
||||
trim_trailing_whitespace = true
|
||||
1
node_modules/side-channel/.eslintignore
generated
vendored
1
node_modules/side-channel/.eslintignore
generated
vendored
@@ -1 +0,0 @@
|
||||
coverage/
|
||||
3
node_modules/side-channel/.eslintrc
generated
vendored
3
node_modules/side-channel/.eslintrc
generated
vendored
@@ -4,8 +4,9 @@
|
||||
"extends": "@ljharb",
|
||||
|
||||
"rules": {
|
||||
"id-length": 0,
|
||||
"max-lines-per-function": 0,
|
||||
"max-params": 0,
|
||||
"multiline-comment-style": 1,
|
||||
"new-cap": [2, { "capIsNewExceptions": ["GetIntrinsic"] }],
|
||||
},
|
||||
}
|
||||
|
||||
45
node_modules/side-channel/CHANGELOG.md
generated
vendored
45
node_modules/side-channel/CHANGELOG.md
generated
vendored
@@ -5,6 +5,51 @@ All notable changes to this project will be documented in this file.
|
||||
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
|
||||
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
||||
|
||||
## [v1.1.0](https://github.com/ljharb/side-channel/compare/v1.0.6...v1.1.0) - 2024-12-11
|
||||
|
||||
### Commits
|
||||
|
||||
- [Refactor] extract implementations to `side-channel-weakmap`, `side-channel-map`, `side-channel-list` [`ada5955`](https://github.com/ljharb/side-channel/commit/ada595549a5c4c6c853756d598846b180941c6da)
|
||||
- [New] add `channel.delete` [`c01d2d3`](https://github.com/ljharb/side-channel/commit/c01d2d3fd51dbb1ce6da72ad7916e61bd6172aad)
|
||||
- [types] improve types [`0c54356`](https://github.com/ljharb/side-channel/commit/0c5435651417df41b8cc1a5f7cdce8bffae68cde)
|
||||
- [readme] add content [`be24868`](https://github.com/ljharb/side-channel/commit/be248682ac294b0e22c883092c45985aa91c490a)
|
||||
- [actions] split out node 10-20, and 20+ [`c4488e2`](https://github.com/ljharb/side-channel/commit/c4488e241ef3d49a19fe266ac830a2e644305911)
|
||||
- [types] use shared tsconfig [`0e0d57c`](https://github.com/ljharb/side-channel/commit/0e0d57c2ff17c7b45c6cbd43ebcf553edc9e3adc)
|
||||
- [Dev Deps] update `@ljharb/eslint-config`, `@ljharb/tsconfig`, `@types/get-intrinsic`, `@types/object-inspect`, `@types/tape`, `auto-changelog`, `tape` [`fb4f622`](https://github.com/ljharb/side-channel/commit/fb4f622e64a99a1e40b6e5cd7691674a9dc429e4)
|
||||
- [Deps] update `call-bind`, `get-intrinsic`, `object-inspect` [`b78336b`](https://github.com/ljharb/side-channel/commit/b78336b886172d1b457d414ac9e28de8c5fecc78)
|
||||
- [Tests] replace `aud` with `npm audit` [`ee3ab46`](https://github.com/ljharb/side-channel/commit/ee3ab4690d954311c35115651bcfd45edd205aa1)
|
||||
- [Dev Deps] add missing peer dep [`c03e21a`](https://github.com/ljharb/side-channel/commit/c03e21a7def3b67cdc15ae22316884fefcb2f6a8)
|
||||
|
||||
## [v1.0.6](https://github.com/ljharb/side-channel/compare/v1.0.5...v1.0.6) - 2024-02-29
|
||||
|
||||
### Commits
|
||||
|
||||
- add types [`9beef66`](https://github.com/ljharb/side-channel/commit/9beef6643e6d717ea57bedabf86448123a7dd9e9)
|
||||
- [meta] simplify `exports` [`4334cf9`](https://github.com/ljharb/side-channel/commit/4334cf9df654151504c383b62a2f9ebdc8d9d5ac)
|
||||
- [Deps] update `call-bind` [`d6043c4`](https://github.com/ljharb/side-channel/commit/d6043c4d8f4d7be9037dd0f0419c7a2e0e39ec6a)
|
||||
- [Dev Deps] update `tape` [`6aca376`](https://github.com/ljharb/side-channel/commit/6aca3761868dc8cd5ff7fd9799bf6b95e09a6eb0)
|
||||
|
||||
## [v1.0.5](https://github.com/ljharb/side-channel/compare/v1.0.4...v1.0.5) - 2024-02-06
|
||||
|
||||
### Commits
|
||||
|
||||
- [actions] reuse common workflows [`3d2e1ff`](https://github.com/ljharb/side-channel/commit/3d2e1ffd16dd6eaaf3e40ff57951f840d2d63c04)
|
||||
- [meta] use `npmignore` to autogenerate an npmignore file [`04296ea`](https://github.com/ljharb/side-channel/commit/04296ea17d1544b0a5d20fd5bfb31aa4f6513eb9)
|
||||
- [meta] add `.editorconfig`; add `eclint` [`130f0a6`](https://github.com/ljharb/side-channel/commit/130f0a6adbc04d385c7456a601d38344dce3d6a9)
|
||||
- [Dev Deps] update `eslint`, `@ljharb/eslint-config`, `aud`, `auto-changelog`, `safe-publish-latest`, `tape` [`d480c2f`](https://github.com/ljharb/side-channel/commit/d480c2fbe757489ae9b4275491ffbcc3ac4725e9)
|
||||
- [Dev Deps] update `eslint`, `@ljharb/eslint-config`, `aud`, `auto-changelog`, `tape` [`ecbe70e`](https://github.com/ljharb/side-channel/commit/ecbe70e53a418234081a77971fec1fdfae20c841)
|
||||
- [actions] update rebase action [`75240b9`](https://github.com/ljharb/side-channel/commit/75240b9963b816e8846400d2287cb68f88c7fba7)
|
||||
- [Dev Deps] update `@ljharb/eslint-config`, `aud`, `npmignore`, `tape` [`ae8d281`](https://github.com/ljharb/side-channel/commit/ae8d281572430099109870fd9430d2ca3f320b8d)
|
||||
- [Dev Deps] update `@ljharb/eslint-config`, `aud`, `tape` [`7125b88`](https://github.com/ljharb/side-channel/commit/7125b885fd0eacad4fee9b073b72d14065ece278)
|
||||
- [Deps] update `call-bind`, `get-intrinsic`, `object-inspect` [`82577c9`](https://github.com/ljharb/side-channel/commit/82577c9796304519139a570f82a317211b5f3b86)
|
||||
- [Deps] update `call-bind`, `get-intrinsic`, `object-inspect` [`550aadf`](https://github.com/ljharb/side-channel/commit/550aadf20475a6081fd70304cc54f77259a5c8a8)
|
||||
- [Tests] increase coverage [`5130877`](https://github.com/ljharb/side-channel/commit/5130877a7b27c862e64e6d1c12a178b28808859d)
|
||||
- [Deps] update `get-intrinsic`, `object-inspect` [`ba0194c`](https://github.com/ljharb/side-channel/commit/ba0194c505b1a8a0427be14cadd5b8a46d4d01b8)
|
||||
- [meta] add missing `engines.node` [`985fd24`](https://github.com/ljharb/side-channel/commit/985fd249663cb06617a693a94fe08cad12f5cb70)
|
||||
- [Refactor] use `es-errors`, so things that only need those do not need `get-intrinsic` [`40227a8`](https://github.com/ljharb/side-channel/commit/40227a87b01709ad2c0eebf87eb4223a800099b9)
|
||||
- [Deps] update `get-intrinsic` [`a989b40`](https://github.com/ljharb/side-channel/commit/a989b4024958737ae7be9fbffdeff2078f33a0fd)
|
||||
- [Deps] update `object-inspect` [`aec42d2`](https://github.com/ljharb/side-channel/commit/aec42d2ec541a31aaa02475692c87d489237d9a3)
|
||||
|
||||
## [v1.0.4](https://github.com/ljharb/side-channel/compare/v1.0.3...v1.0.4) - 2020-12-29
|
||||
|
||||
### Commits
|
||||
|
||||
61
node_modules/side-channel/README.md
generated
vendored
61
node_modules/side-channel/README.md
generated
vendored
@@ -1,2 +1,61 @@
|
||||
# side-channel
|
||||
# side-channel <sup>[![Version Badge][npm-version-svg]][package-url]</sup>
|
||||
|
||||
[![github actions][actions-image]][actions-url]
|
||||
[![coverage][codecov-image]][codecov-url]
|
||||
[![License][license-image]][license-url]
|
||||
[![Downloads][downloads-image]][downloads-url]
|
||||
|
||||
[![npm badge][npm-badge-png]][package-url]
|
||||
|
||||
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
|
||||
|
||||
```sh
|
||||
npm install --save side-channel
|
||||
```
|
||||
|
||||
## Usage/Examples
|
||||
|
||||
```js
|
||||
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`
|
||||
|
||||
[package-url]: https://npmjs.org/package/side-channel
|
||||
[npm-version-svg]: https://versionbadg.es/ljharb/side-channel.svg
|
||||
[deps-svg]: https://david-dm.org/ljharb/side-channel.svg
|
||||
[deps-url]: https://david-dm.org/ljharb/side-channel
|
||||
[dev-deps-svg]: https://david-dm.org/ljharb/side-channel/dev-status.svg
|
||||
[dev-deps-url]: https://david-dm.org/ljharb/side-channel#info=devDependencies
|
||||
[npm-badge-png]: https://nodei.co/npm/side-channel.png?downloads=true&stars=true
|
||||
[license-image]: https://img.shields.io/npm/l/side-channel.svg
|
||||
[license-url]: LICENSE
|
||||
[downloads-image]: https://img.shields.io/npm/dm/side-channel.svg
|
||||
[downloads-url]: https://npm-stat.com/charts.html?package=side-channel
|
||||
[codecov-image]: https://codecov.io/gh/ljharb/side-channel/branch/main/graphs/badge.svg
|
||||
[codecov-url]: https://app.codecov.io/gh/ljharb/side-channel/
|
||||
[actions-image]: https://img.shields.io/endpoint?url=https://github-actions-badge-u3jn4tfpocch.runkit.sh/ljharb/side-channel
|
||||
[actions-url]: https://github.com/ljharb/side-channel/actions
|
||||
|
||||
14
node_modules/side-channel/index.d.ts
generated
vendored
Normal file
14
node_modules/side-channel/index.d.ts
generated
vendored
Normal file
@@ -0,0 +1,14 @@
|
||||
import getSideChannelList from 'side-channel-list';
|
||||
import getSideChannelMap from 'side-channel-map';
|
||||
import getSideChannelWeakMap from 'side-channel-weakmap';
|
||||
|
||||
declare namespace getSideChannel {
|
||||
type Channel<K, V> =
|
||||
| getSideChannelList.Channel<K, V>
|
||||
| ReturnType<Exclude<typeof getSideChannelMap<K, V>, false>>
|
||||
| ReturnType<Exclude<typeof getSideChannelWeakMap<K, V>, false>>;
|
||||
}
|
||||
|
||||
declare function getSideChannel<K, V>(): getSideChannel.Channel<K, V>;
|
||||
|
||||
export = getSideChannel;
|
||||
125
node_modules/side-channel/index.js
generated
vendored
125
node_modules/side-channel/index.js
generated
vendored
@@ -1,124 +1,43 @@
|
||||
'use strict';
|
||||
|
||||
var GetIntrinsic = require('get-intrinsic');
|
||||
var callBound = require('call-bind/callBound');
|
||||
var $TypeError = require('es-errors/type');
|
||||
var inspect = require('object-inspect');
|
||||
var getSideChannelList = require('side-channel-list');
|
||||
var getSideChannelMap = require('side-channel-map');
|
||||
var getSideChannelWeakMap = require('side-channel-weakmap');
|
||||
|
||||
var $TypeError = GetIntrinsic('%TypeError%');
|
||||
var $WeakMap = GetIntrinsic('%WeakMap%', true);
|
||||
var $Map = GetIntrinsic('%Map%', true);
|
||||
|
||||
var $weakMapGet = callBound('WeakMap.prototype.get', true);
|
||||
var $weakMapSet = callBound('WeakMap.prototype.set', true);
|
||||
var $weakMapHas = callBound('WeakMap.prototype.has', true);
|
||||
var $mapGet = callBound('Map.prototype.get', true);
|
||||
var $mapSet = callBound('Map.prototype.set', true);
|
||||
var $mapHas = callBound('Map.prototype.has', true);
|
||||
|
||||
/*
|
||||
* This function traverses the list returning the node corresponding to the
|
||||
* given key.
|
||||
*
|
||||
* That node is also moved to the head of the list, so that if it's accessed
|
||||
* again we don't need to traverse the whole list. By doing so, all the recently
|
||||
* used nodes can be accessed relatively quickly.
|
||||
*/
|
||||
var listGetNode = function (list, key) { // eslint-disable-line consistent-return
|
||||
for (var prev = list, curr; (curr = prev.next) !== null; prev = curr) {
|
||||
if (curr.key === key) {
|
||||
prev.next = curr.next;
|
||||
curr.next = list.next;
|
||||
list.next = curr; // eslint-disable-line no-param-reassign
|
||||
return curr;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
var listGet = function (objects, key) {
|
||||
var node = listGetNode(objects, key);
|
||||
return node && node.value;
|
||||
};
|
||||
var listSet = function (objects, key, value) {
|
||||
var node = listGetNode(objects, key);
|
||||
if (node) {
|
||||
node.value = value;
|
||||
} else {
|
||||
// Prepend the new node to the beginning of the list
|
||||
objects.next = { // eslint-disable-line no-param-reassign
|
||||
key: key,
|
||||
next: objects.next,
|
||||
value: value
|
||||
};
|
||||
}
|
||||
};
|
||||
var listHas = function (objects, key) {
|
||||
return !!listGetNode(objects, key);
|
||||
};
|
||||
var makeChannel = getSideChannelWeakMap || getSideChannelMap || getSideChannelList;
|
||||
|
||||
/** @type {import('.')} */
|
||||
module.exports = function getSideChannel() {
|
||||
var $wm;
|
||||
var $m;
|
||||
var $o;
|
||||
/** @typedef {ReturnType<typeof getSideChannel>} Channel */
|
||||
|
||||
/** @type {Channel | undefined} */ var $channelData;
|
||||
|
||||
/** @type {Channel} */
|
||||
var channel = {
|
||||
assert: function (key) {
|
||||
if (!channel.has(key)) {
|
||||
throw new $TypeError('Side channel does not contain ' + inspect(key));
|
||||
}
|
||||
},
|
||||
get: function (key) { // eslint-disable-line consistent-return
|
||||
if ($WeakMap && key && (typeof key === 'object' || typeof key === 'function')) {
|
||||
if ($wm) {
|
||||
return $weakMapGet($wm, key);
|
||||
}
|
||||
} else if ($Map) {
|
||||
if ($m) {
|
||||
return $mapGet($m, key);
|
||||
}
|
||||
} else {
|
||||
if ($o) { // eslint-disable-line no-lonely-if
|
||||
return listGet($o, key);
|
||||
}
|
||||
}
|
||||
'delete': function (key) {
|
||||
return !!$channelData && $channelData['delete'](key);
|
||||
},
|
||||
get: function (key) {
|
||||
return $channelData && $channelData.get(key);
|
||||
},
|
||||
has: function (key) {
|
||||
if ($WeakMap && key && (typeof key === 'object' || typeof key === 'function')) {
|
||||
if ($wm) {
|
||||
return $weakMapHas($wm, key);
|
||||
}
|
||||
} else if ($Map) {
|
||||
if ($m) {
|
||||
return $mapHas($m, key);
|
||||
}
|
||||
} else {
|
||||
if ($o) { // eslint-disable-line no-lonely-if
|
||||
return listHas($o, key);
|
||||
}
|
||||
}
|
||||
return false;
|
||||
return !!$channelData && $channelData.has(key);
|
||||
},
|
||||
set: function (key, value) {
|
||||
if ($WeakMap && key && (typeof key === 'object' || typeof key === 'function')) {
|
||||
if (!$wm) {
|
||||
$wm = new $WeakMap();
|
||||
}
|
||||
$weakMapSet($wm, key, value);
|
||||
} else if ($Map) {
|
||||
if (!$m) {
|
||||
$m = new $Map();
|
||||
}
|
||||
$mapSet($m, key, value);
|
||||
} else {
|
||||
if (!$o) {
|
||||
/*
|
||||
* Initialize the linked list as an empty node, so that we don't have
|
||||
* to special-case handling of the first node: we can always refer to
|
||||
* it as (previous node).next, instead of something like (list).head
|
||||
*/
|
||||
$o = { key: {}, next: null };
|
||||
}
|
||||
listSet($o, key, value);
|
||||
if (!$channelData) {
|
||||
$channelData = makeChannel();
|
||||
}
|
||||
|
||||
$channelData.set(key, value);
|
||||
}
|
||||
};
|
||||
// @ts-expect-error TODO: figure out why this is erroring
|
||||
return channel;
|
||||
};
|
||||
|
||||
64
node_modules/side-channel/package.json
generated
vendored
64
node_modules/side-channel/package.json
generated
vendored
@@ -1,24 +1,24 @@
|
||||
{
|
||||
"name": "side-channel",
|
||||
"version": "1.0.4",
|
||||
"version": "1.1.0",
|
||||
"description": "Store information about any JS value in a side channel. Uses WeakMap if available.",
|
||||
"main": "index.js",
|
||||
"exports": {
|
||||
"./package.json": "./package.json",
|
||||
".": [
|
||||
{
|
||||
"default": "./index.js"
|
||||
},
|
||||
"./index.js"
|
||||
]
|
||||
".": "./index.js",
|
||||
"./package.json": "./package.json"
|
||||
},
|
||||
"types": "./index.d.ts",
|
||||
"scripts": {
|
||||
"prepublish": "safe-publish-latest",
|
||||
"lint": "eslint .",
|
||||
"prepack": "npmignore --auto --commentLines=autogenerated",
|
||||
"prepublishOnly": "safe-publish-latest",
|
||||
"prepublish": "not-in-publish || npm run prepublishOnly",
|
||||
"prelint": "eclint check $(git ls-files | xargs find 2> /dev/null | grep -vE 'node_modules|\\.git')",
|
||||
"lint": "eslint --ext=js,mjs .",
|
||||
"postlint": "tsc -p . && attw -P",
|
||||
"pretest": "npm run lint",
|
||||
"tests-only": "nyc tape 'test/**/*.js'",
|
||||
"test": "npm run tests-only",
|
||||
"posttest": "npx aud --production",
|
||||
"posttest": "npx npm@'>=10.2' audit --production",
|
||||
"version": "auto-changelog && git add CHANGELOG.md",
|
||||
"postversion": "auto-changelog && git add CHANGELOG.md && git commit --no-edit --amend && git tag -f \"v$(node -e \"console.log(require('./package.json').version)\")\""
|
||||
},
|
||||
@@ -42,19 +42,29 @@
|
||||
"url": "https://github.com/ljharb/side-channel/issues"
|
||||
},
|
||||
"homepage": "https://github.com/ljharb/side-channel#readme",
|
||||
"devDependencies": {
|
||||
"@ljharb/eslint-config": "^17.3.0",
|
||||
"aud": "^1.1.3",
|
||||
"auto-changelog": "^2.2.1",
|
||||
"eslint": "^7.16.0",
|
||||
"nyc": "^10.3.2",
|
||||
"safe-publish-latest": "^1.1.4",
|
||||
"tape": "^5.0.1"
|
||||
},
|
||||
"dependencies": {
|
||||
"call-bind": "^1.0.0",
|
||||
"get-intrinsic": "^1.0.2",
|
||||
"object-inspect": "^1.9.0"
|
||||
"es-errors": "^1.3.0",
|
||||
"object-inspect": "^1.13.3",
|
||||
"side-channel-list": "^1.0.0",
|
||||
"side-channel-map": "^1.0.1",
|
||||
"side-channel-weakmap": "^1.0.2"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@arethetypeswrong/cli": "^0.17.1",
|
||||
"@ljharb/eslint-config": "^21.1.1",
|
||||
"@ljharb/tsconfig": "^0.2.2",
|
||||
"@types/object-inspect": "^1.13.0",
|
||||
"@types/tape": "^5.6.5",
|
||||
"auto-changelog": "^2.5.0",
|
||||
"eclint": "^2.8.1",
|
||||
"encoding": "^0.1.13",
|
||||
"eslint": "=8.8.0",
|
||||
"in-publish": "^2.0.1",
|
||||
"npmignore": "^0.3.1",
|
||||
"nyc": "^10.3.2",
|
||||
"safe-publish-latest": "^2.0.0",
|
||||
"tape": "^5.9.0",
|
||||
"typescript": "next"
|
||||
},
|
||||
"auto-changelog": {
|
||||
"output": "CHANGELOG.md",
|
||||
@@ -63,5 +73,13 @@
|
||||
"commitLimit": false,
|
||||
"backfillLimit": false,
|
||||
"hideCredit": true
|
||||
},
|
||||
"publishConfig": {
|
||||
"ignore": [
|
||||
".github/workflows"
|
||||
]
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 0.4"
|
||||
}
|
||||
}
|
||||
|
||||
162
node_modules/side-channel/test/index.js
generated
vendored
162
node_modules/side-channel/test/index.js
generated
vendored
@@ -4,75 +4,101 @@ var test = require('tape');
|
||||
|
||||
var getSideChannel = require('../');
|
||||
|
||||
test('export', function (t) {
|
||||
t.equal(typeof getSideChannel, 'function', 'is a function');
|
||||
t.equal(getSideChannel.length, 0, 'takes no arguments');
|
||||
test('getSideChannel', function (t) {
|
||||
t.test('export', function (st) {
|
||||
st.equal(typeof getSideChannel, 'function', 'is a function');
|
||||
|
||||
var channel = getSideChannel();
|
||||
t.ok(channel, 'is truthy');
|
||||
t.equal(typeof channel, 'object', 'is an object');
|
||||
|
||||
t.end();
|
||||
});
|
||||
|
||||
test('assert', function (t) {
|
||||
var channel = getSideChannel();
|
||||
t['throws'](
|
||||
function () { channel.assert({}); },
|
||||
TypeError,
|
||||
'nonexistent value throws'
|
||||
);
|
||||
|
||||
var o = {};
|
||||
channel.set(o, 'data');
|
||||
t.doesNotThrow(function () { channel.assert(o); }, 'existent value noops');
|
||||
|
||||
t.end();
|
||||
});
|
||||
|
||||
test('has', function (t) {
|
||||
var channel = getSideChannel();
|
||||
var o = [];
|
||||
|
||||
t.equal(channel.has(o), false, 'nonexistent value yields false');
|
||||
|
||||
channel.set(o, 'foo');
|
||||
t.equal(channel.has(o), true, 'existent value yields true');
|
||||
|
||||
t.end();
|
||||
});
|
||||
|
||||
test('get', function (t) {
|
||||
var channel = getSideChannel();
|
||||
var o = {};
|
||||
t.equal(channel.get(o), undefined, 'nonexistent value yields undefined');
|
||||
|
||||
var data = {};
|
||||
channel.set(o, data);
|
||||
t.equal(channel.get(o), data, '"get" yields data set by "set"');
|
||||
|
||||
t.end();
|
||||
});
|
||||
|
||||
test('set', function (t) {
|
||||
var channel = getSideChannel();
|
||||
var o = function () {};
|
||||
t.equal(channel.get(o), undefined, 'value not set');
|
||||
|
||||
channel.set(o, 42);
|
||||
t.equal(channel.get(o), 42, 'value was set');
|
||||
|
||||
channel.set(o, Infinity);
|
||||
t.equal(channel.get(o), Infinity, 'value was set again');
|
||||
|
||||
var o2 = {};
|
||||
channel.set(o2, 17);
|
||||
t.equal(channel.get(o), Infinity, 'o is not modified');
|
||||
t.equal(channel.get(o2), 17, 'o2 is set');
|
||||
|
||||
channel.set(o, 14);
|
||||
t.equal(channel.get(o), 14, 'o is modified');
|
||||
t.equal(channel.get(o2), 17, 'o2 is not modified');
|
||||
st.equal(getSideChannel.length, 0, 'takes no arguments');
|
||||
|
||||
var channel = getSideChannel();
|
||||
st.ok(channel, 'is truthy');
|
||||
st.equal(typeof channel, 'object', 'is an object');
|
||||
st.end();
|
||||
});
|
||||
|
||||
t.test('assert', function (st) {
|
||||
var channel = getSideChannel();
|
||||
st['throws'](
|
||||
function () { channel.assert({}); },
|
||||
TypeError,
|
||||
'nonexistent value throws'
|
||||
);
|
||||
|
||||
var o = {};
|
||||
channel.set(o, 'data');
|
||||
st.doesNotThrow(function () { channel.assert(o); }, 'existent value noops');
|
||||
|
||||
st.end();
|
||||
});
|
||||
|
||||
t.test('has', function (st) {
|
||||
var channel = getSideChannel();
|
||||
/** @type {unknown[]} */ var o = [];
|
||||
|
||||
st.equal(channel.has(o), false, 'nonexistent value yields false');
|
||||
|
||||
channel.set(o, 'foo');
|
||||
st.equal(channel.has(o), true, 'existent value yields true');
|
||||
|
||||
st.equal(channel.has('abc'), false, 'non object value non existent yields false');
|
||||
|
||||
channel.set('abc', 'foo');
|
||||
st.equal(channel.has('abc'), true, 'non object value that exists yields true');
|
||||
|
||||
st.end();
|
||||
});
|
||||
|
||||
t.test('get', function (st) {
|
||||
var channel = getSideChannel();
|
||||
var o = {};
|
||||
st.equal(channel.get(o), undefined, 'nonexistent value yields undefined');
|
||||
|
||||
var data = {};
|
||||
channel.set(o, data);
|
||||
st.equal(channel.get(o), data, '"get" yields data set by "set"');
|
||||
|
||||
st.end();
|
||||
});
|
||||
|
||||
t.test('set', function (st) {
|
||||
var channel = getSideChannel();
|
||||
var o = function () {};
|
||||
st.equal(channel.get(o), undefined, 'value not set');
|
||||
|
||||
channel.set(o, 42);
|
||||
st.equal(channel.get(o), 42, 'value was set');
|
||||
|
||||
channel.set(o, Infinity);
|
||||
st.equal(channel.get(o), Infinity, 'value was set again');
|
||||
|
||||
var o2 = {};
|
||||
channel.set(o2, 17);
|
||||
st.equal(channel.get(o), Infinity, 'o is not modified');
|
||||
st.equal(channel.get(o2), 17, 'o2 is set');
|
||||
|
||||
channel.set(o, 14);
|
||||
st.equal(channel.get(o), 14, 'o is modified');
|
||||
st.equal(channel.get(o2), 17, 'o2 is not modified');
|
||||
|
||||
st.end();
|
||||
});
|
||||
|
||||
t.test('delete', function (st) {
|
||||
var channel = getSideChannel();
|
||||
var o = {};
|
||||
st.equal(channel['delete']({}), false, 'nonexistent value yields false');
|
||||
|
||||
channel.set(o, 42);
|
||||
st.equal(channel.has(o), true, 'value is set');
|
||||
|
||||
st.equal(channel['delete']({}), false, 'nonexistent value still yields false');
|
||||
|
||||
st.equal(channel['delete'](o), true, 'deleted value yields true');
|
||||
|
||||
st.equal(channel.has(o), false, 'value is no longer set');
|
||||
|
||||
st.end();
|
||||
});
|
||||
|
||||
t.end();
|
||||
});
|
||||
|
||||
9
node_modules/side-channel/tsconfig.json
generated
vendored
Normal file
9
node_modules/side-channel/tsconfig.json
generated
vendored
Normal file
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"extends": "@ljharb/tsconfig",
|
||||
"compilerOptions": {
|
||||
"target": "es2021",
|
||||
},
|
||||
"exclude": [
|
||||
"coverage",
|
||||
],
|
||||
}
|
||||
Reference in New Issue
Block a user