@nocobase/plugin-multi-keyword-filter 2.2.17 → 2.2.18
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/client/103.b39ee70786cb13a7.js +10 -0
- package/dist/client/index.js +1 -1
- package/dist/client-v2/103.dfed67c95bcd8a1d.js +10 -0
- package/dist/client-v2/index.js +1 -1
- package/dist/externalVersion.js +4 -4
- package/dist/node_modules/qs/.editorconfig +4 -1
- package/dist/node_modules/qs/.github/SECURITY.md +11 -0
- package/dist/node_modules/qs/.github/THREAT_MODEL.md +78 -0
- package/dist/node_modules/qs/dist/qs.js +90 -2036
- package/dist/node_modules/qs/lib/index.js +1 -1
- package/dist/node_modules/qs/lib/parse.js +215 -66
- package/dist/node_modules/qs/lib/stringify.js +90 -32
- package/dist/node_modules/qs/lib/utils.js +189 -53
- package/dist/node_modules/qs/node_modules/es-define-property/.eslintrc +13 -0
- package/dist/node_modules/qs/node_modules/es-define-property/.github/FUNDING.yml +12 -0
- package/dist/node_modules/qs/node_modules/es-define-property/.nycrc +9 -0
- package/dist/node_modules/qs/node_modules/es-define-property/index.d.ts +3 -0
- package/dist/node_modules/qs/node_modules/es-define-property/index.js +14 -0
- package/dist/node_modules/qs/node_modules/es-define-property/package.json +81 -0
- package/dist/node_modules/qs/node_modules/es-define-property/test/index.js +56 -0
- package/dist/node_modules/qs/node_modules/side-channel/.editorconfig +9 -0
- package/dist/node_modules/qs/node_modules/side-channel/.eslintrc +12 -0
- package/dist/node_modules/qs/node_modules/side-channel/.github/FUNDING.yml +12 -0
- package/dist/node_modules/qs/node_modules/side-channel/.nycrc +13 -0
- package/dist/node_modules/qs/node_modules/side-channel/index.d.ts +14 -0
- package/dist/node_modules/qs/node_modules/side-channel/index.js +46 -0
- package/dist/node_modules/qs/node_modules/side-channel/package.json +85 -0
- package/dist/node_modules/qs/node_modules/side-channel/test/index.js +120 -0
- package/dist/node_modules/qs/node_modules/side-channel-list/.editorconfig +9 -0
- package/dist/node_modules/qs/node_modules/side-channel-list/.eslintrc +11 -0
- package/dist/node_modules/qs/node_modules/side-channel-list/.github/FUNDING.yml +12 -0
- package/dist/node_modules/qs/node_modules/side-channel-list/.nycrc +13 -0
- package/dist/node_modules/qs/node_modules/side-channel-list/index.d.ts +13 -0
- package/dist/node_modules/qs/node_modules/side-channel-list/index.js +111 -0
- package/dist/node_modules/qs/node_modules/side-channel-list/list.d.ts +14 -0
- package/dist/node_modules/qs/node_modules/side-channel-list/package.json +77 -0
- package/dist/node_modules/qs/node_modules/side-channel-list/test/index.js +154 -0
- package/dist/node_modules/qs/package.json +1 -1
- package/dist/node_modules/qs/test/empty-keys-cases.js +261 -31
- package/dist/node_modules/qs/test/parse.js +1281 -57
- package/dist/node_modules/qs/test/stringify.js +851 -58
- package/dist/node_modules/qs/test/utils.js +505 -3
- package/package.json +5 -2
- package/dist/client/103.513149b773e262dc.js +0 -10
- package/dist/client-v2/103.8bcbf628d0af8457.js +0 -10
- package/dist/node_modules/qs/.eslintrc +0 -38
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
/** @type {import('.')} */
|
|
4
|
+
var $defineProperty = Object.defineProperty || false;
|
|
5
|
+
if ($defineProperty) {
|
|
6
|
+
try {
|
|
7
|
+
$defineProperty({}, 'a', { value: 1 });
|
|
8
|
+
} catch (e) {
|
|
9
|
+
// IE 8 has a broken defineProperty
|
|
10
|
+
$defineProperty = false;
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
module.exports = $defineProperty;
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "es-define-property",
|
|
3
|
+
"version": "1.0.1",
|
|
4
|
+
"description": "`Object.defineProperty`, but not IE 8's broken one.",
|
|
5
|
+
"main": "index.js",
|
|
6
|
+
"types": "./index.d.ts",
|
|
7
|
+
"exports": {
|
|
8
|
+
".": "./index.js",
|
|
9
|
+
"./package.json": "./package.json"
|
|
10
|
+
},
|
|
11
|
+
"sideEffects": false,
|
|
12
|
+
"scripts": {
|
|
13
|
+
"prepack": "npmignore --auto --commentLines=autogenerated",
|
|
14
|
+
"prepublish": "not-in-publish || npm run prepublishOnly",
|
|
15
|
+
"prepublishOnly": "safe-publish-latest",
|
|
16
|
+
"prelint": "evalmd README.md",
|
|
17
|
+
"lint": "eslint --ext=js,mjs .",
|
|
18
|
+
"postlint": "tsc -p .",
|
|
19
|
+
"pretest": "npm run lint",
|
|
20
|
+
"tests-only": "nyc tape 'test/**/*.js'",
|
|
21
|
+
"test": "npm run tests-only",
|
|
22
|
+
"posttest": "npx npm@'>= 10.2' audit --production",
|
|
23
|
+
"version": "auto-changelog && git add CHANGELOG.md",
|
|
24
|
+
"postversion": "auto-changelog && git add CHANGELOG.md && git commit --no-edit --amend && git tag -f \"v$(node -e \"console.log(require('./package.json').version)\")\""
|
|
25
|
+
},
|
|
26
|
+
"repository": {
|
|
27
|
+
"type": "git",
|
|
28
|
+
"url": "git+https://github.com/ljharb/es-define-property.git"
|
|
29
|
+
},
|
|
30
|
+
"keywords": [
|
|
31
|
+
"javascript",
|
|
32
|
+
"ecmascript",
|
|
33
|
+
"object",
|
|
34
|
+
"define",
|
|
35
|
+
"property",
|
|
36
|
+
"defineProperty",
|
|
37
|
+
"Object.defineProperty"
|
|
38
|
+
],
|
|
39
|
+
"author": "Jordan Harband <ljharb@gmail.com>",
|
|
40
|
+
"license": "MIT",
|
|
41
|
+
"bugs": {
|
|
42
|
+
"url": "https://github.com/ljharb/es-define-property/issues"
|
|
43
|
+
},
|
|
44
|
+
"homepage": "https://github.com/ljharb/es-define-property#readme",
|
|
45
|
+
"devDependencies": {
|
|
46
|
+
"@ljharb/eslint-config": "^21.1.1",
|
|
47
|
+
"@ljharb/tsconfig": "^0.2.2",
|
|
48
|
+
"@types/gopd": "^1.0.3",
|
|
49
|
+
"@types/tape": "^5.6.5",
|
|
50
|
+
"auto-changelog": "^2.5.0",
|
|
51
|
+
"encoding": "^0.1.13",
|
|
52
|
+
"eslint": "^8.8.0",
|
|
53
|
+
"evalmd": "^0.0.19",
|
|
54
|
+
"gopd": "^1.2.0",
|
|
55
|
+
"in-publish": "^2.0.1",
|
|
56
|
+
"npmignore": "^0.3.1",
|
|
57
|
+
"nyc": "^10.3.2",
|
|
58
|
+
"safe-publish-latest": "^2.0.0",
|
|
59
|
+
"tape": "^5.9.0",
|
|
60
|
+
"typescript": "next"
|
|
61
|
+
},
|
|
62
|
+
"engines": {
|
|
63
|
+
"node": ">= 0.4"
|
|
64
|
+
},
|
|
65
|
+
"testling": {
|
|
66
|
+
"files": "test/index.js"
|
|
67
|
+
},
|
|
68
|
+
"auto-changelog": {
|
|
69
|
+
"output": "CHANGELOG.md",
|
|
70
|
+
"template": "keepachangelog",
|
|
71
|
+
"unreleased": false,
|
|
72
|
+
"commitLimit": false,
|
|
73
|
+
"backfillLimit": false,
|
|
74
|
+
"hideCredit": true
|
|
75
|
+
},
|
|
76
|
+
"publishConfig": {
|
|
77
|
+
"ignore": [
|
|
78
|
+
".github/workflows"
|
|
79
|
+
]
|
|
80
|
+
}
|
|
81
|
+
}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var $defineProperty = require('../');
|
|
4
|
+
|
|
5
|
+
var test = require('tape');
|
|
6
|
+
var gOPD = require('gopd');
|
|
7
|
+
|
|
8
|
+
test('defineProperty: supported', { skip: !$defineProperty }, function (t) {
|
|
9
|
+
t.plan(4);
|
|
10
|
+
|
|
11
|
+
t.equal(typeof $defineProperty, 'function', 'defineProperty is supported');
|
|
12
|
+
if ($defineProperty && gOPD) { // this `if` check is just to shut TS up
|
|
13
|
+
/** @type {{ a: number, b?: number, c?: number }} */
|
|
14
|
+
var o = { a: 1 };
|
|
15
|
+
|
|
16
|
+
$defineProperty(o, 'b', { enumerable: true, value: 2 });
|
|
17
|
+
t.deepEqual(
|
|
18
|
+
gOPD(o, 'b'),
|
|
19
|
+
{
|
|
20
|
+
configurable: false,
|
|
21
|
+
enumerable: true,
|
|
22
|
+
value: 2,
|
|
23
|
+
writable: false
|
|
24
|
+
},
|
|
25
|
+
'property descriptor is as expected'
|
|
26
|
+
);
|
|
27
|
+
|
|
28
|
+
$defineProperty(o, 'c', { enumerable: false, value: 3, writable: true });
|
|
29
|
+
t.deepEqual(
|
|
30
|
+
gOPD(o, 'c'),
|
|
31
|
+
{
|
|
32
|
+
configurable: false,
|
|
33
|
+
enumerable: false,
|
|
34
|
+
value: 3,
|
|
35
|
+
writable: true
|
|
36
|
+
},
|
|
37
|
+
'property descriptor is as expected'
|
|
38
|
+
);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
t.equal($defineProperty, Object.defineProperty, 'defineProperty is Object.defineProperty');
|
|
42
|
+
|
|
43
|
+
t.end();
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
test('defineProperty: not supported', { skip: !!$defineProperty }, function (t) {
|
|
47
|
+
t.notOk($defineProperty, 'defineProperty is not supported');
|
|
48
|
+
|
|
49
|
+
t.match(
|
|
50
|
+
typeof $defineProperty,
|
|
51
|
+
/^(?:undefined|boolean)$/,
|
|
52
|
+
'`typeof defineProperty` is `undefined` or `boolean`'
|
|
53
|
+
);
|
|
54
|
+
|
|
55
|
+
t.end();
|
|
56
|
+
});
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
# These are supported funding model platforms
|
|
2
|
+
|
|
3
|
+
github: [ljharb]
|
|
4
|
+
patreon: # Replace with a single Patreon username
|
|
5
|
+
open_collective: # Replace with a single Open Collective username
|
|
6
|
+
ko_fi: # Replace with a single Ko-fi username
|
|
7
|
+
tidelift: npm/side-channel
|
|
8
|
+
community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry
|
|
9
|
+
liberapay: # Replace with a single Liberapay username
|
|
10
|
+
issuehunt: # Replace with a single IssueHunt username
|
|
11
|
+
otechie: # Replace with a single Otechie username
|
|
12
|
+
custom: # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2']
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import getSideChannelList from 'side-channel-list';
|
|
2
|
+
import getSideChannelMap from 'side-channel-map';
|
|
3
|
+
import getSideChannelWeakMap from 'side-channel-weakmap';
|
|
4
|
+
|
|
5
|
+
declare namespace getSideChannel {
|
|
6
|
+
type Channel<K, V> =
|
|
7
|
+
| getSideChannelList.Channel<K, V>
|
|
8
|
+
| ReturnType<Exclude<typeof getSideChannelMap<K, V>, false>>
|
|
9
|
+
| ReturnType<Exclude<typeof getSideChannelWeakMap<K, V>, false>>;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
declare function getSideChannel<K, V>(): getSideChannel.Channel<K, V>;
|
|
13
|
+
|
|
14
|
+
export = getSideChannel;
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var $TypeError = require('es-errors/type');
|
|
4
|
+
var inspect = require('object-inspect');
|
|
5
|
+
var getSideChannelList = require('side-channel-list');
|
|
6
|
+
var getSideChannelMap = require('side-channel-map');
|
|
7
|
+
var getSideChannelWeakMap = require('side-channel-weakmap');
|
|
8
|
+
|
|
9
|
+
var makeChannel = getSideChannelWeakMap || getSideChannelMap || getSideChannelList;
|
|
10
|
+
|
|
11
|
+
/** @type {import('.')} */
|
|
12
|
+
module.exports = function getSideChannel() {
|
|
13
|
+
/** @typedef {ReturnType<typeof getSideChannel>} Channel */
|
|
14
|
+
|
|
15
|
+
/** @type {Channel | undefined} */ var $channelData;
|
|
16
|
+
|
|
17
|
+
/** @type {Channel} */
|
|
18
|
+
var channel = {
|
|
19
|
+
assert: function (key) {
|
|
20
|
+
if (!channel.has(key)) {
|
|
21
|
+
var keyDesc = key && Object(key) === key
|
|
22
|
+
? 'the given object key'
|
|
23
|
+
: inspect(key);
|
|
24
|
+
throw new $TypeError('Side channel does not contain ' + keyDesc);
|
|
25
|
+
}
|
|
26
|
+
},
|
|
27
|
+
'delete': function (key) {
|
|
28
|
+
return !!$channelData && $channelData['delete'](key);
|
|
29
|
+
},
|
|
30
|
+
get: function (key) {
|
|
31
|
+
return $channelData && $channelData.get(key);
|
|
32
|
+
},
|
|
33
|
+
has: function (key) {
|
|
34
|
+
return !!$channelData && $channelData.has(key);
|
|
35
|
+
},
|
|
36
|
+
set: function (key, value) {
|
|
37
|
+
if (!$channelData) {
|
|
38
|
+
$channelData = makeChannel();
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
$channelData.set(key, value);
|
|
42
|
+
}
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
return channel;
|
|
46
|
+
};
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "side-channel",
|
|
3
|
+
"version": "1.1.1",
|
|
4
|
+
"description": "Store information about any JS value in a side channel. Uses WeakMap if available.",
|
|
5
|
+
"main": "index.js",
|
|
6
|
+
"exports": {
|
|
7
|
+
".": "./index.js",
|
|
8
|
+
"./package.json": "./package.json"
|
|
9
|
+
},
|
|
10
|
+
"types": "./index.d.ts",
|
|
11
|
+
"scripts": {
|
|
12
|
+
"prepack": "npmignore --auto --commentLines=autogenerated",
|
|
13
|
+
"prepublishOnly": "safe-publish-latest",
|
|
14
|
+
"prepublish": "not-in-publish || npm run prepublishOnly",
|
|
15
|
+
"prelint": "eclint check $(git ls-files | xargs find 2> /dev/null | grep -vE 'node_modules|\\.git')",
|
|
16
|
+
"lint": "eslint --ext=js,mjs .",
|
|
17
|
+
"postlint": "tsc -p . && attw -P",
|
|
18
|
+
"pretest": "npm run lint",
|
|
19
|
+
"tests-only": "nyc tape 'test/**/*.js'",
|
|
20
|
+
"test": "npm run tests-only",
|
|
21
|
+
"posttest": "npx npm@'>=10.2' audit --production",
|
|
22
|
+
"version": "auto-changelog && git add CHANGELOG.md",
|
|
23
|
+
"postversion": "auto-changelog && git add CHANGELOG.md && git commit --no-edit --amend && git tag -f \"v$(node -e \"console.log(require('./package.json').version)\")\""
|
|
24
|
+
},
|
|
25
|
+
"repository": {
|
|
26
|
+
"type": "git",
|
|
27
|
+
"url": "git+https://github.com/ljharb/side-channel.git"
|
|
28
|
+
},
|
|
29
|
+
"keywords": [
|
|
30
|
+
"weakmap",
|
|
31
|
+
"map",
|
|
32
|
+
"side",
|
|
33
|
+
"channel",
|
|
34
|
+
"metadata"
|
|
35
|
+
],
|
|
36
|
+
"author": "Jordan Harband <ljharb@gmail.com>",
|
|
37
|
+
"funding": {
|
|
38
|
+
"url": "https://github.com/sponsors/ljharb"
|
|
39
|
+
},
|
|
40
|
+
"license": "MIT",
|
|
41
|
+
"bugs": {
|
|
42
|
+
"url": "https://github.com/ljharb/side-channel/issues"
|
|
43
|
+
},
|
|
44
|
+
"homepage": "https://github.com/ljharb/side-channel#readme",
|
|
45
|
+
"dependencies": {
|
|
46
|
+
"es-errors": "^1.3.0",
|
|
47
|
+
"object-inspect": "^1.13.4",
|
|
48
|
+
"side-channel-list": "^1.0.1",
|
|
49
|
+
"side-channel-map": "^1.0.1",
|
|
50
|
+
"side-channel-weakmap": "^1.0.2"
|
|
51
|
+
},
|
|
52
|
+
"devDependencies": {
|
|
53
|
+
"@arethetypeswrong/cli": "^0.18.3",
|
|
54
|
+
"@ljharb/eslint-config": "^22.2.3",
|
|
55
|
+
"@ljharb/tsconfig": "^0.3.2",
|
|
56
|
+
"@types/object-inspect": "^1.13.0",
|
|
57
|
+
"@types/tape": "^5.8.1",
|
|
58
|
+
"auto-changelog": "^2.6.0",
|
|
59
|
+
"eclint": "^2.8.1",
|
|
60
|
+
"encoding": "^0.1.13",
|
|
61
|
+
"eslint": "^8.57.1",
|
|
62
|
+
"in-publish": "^2.0.1",
|
|
63
|
+
"npmignore": "^0.3.5",
|
|
64
|
+
"nyc": "^10.3.2",
|
|
65
|
+
"safe-publish-latest": "^2.0.0",
|
|
66
|
+
"tape": "^5.9.0",
|
|
67
|
+
"typescript": "next"
|
|
68
|
+
},
|
|
69
|
+
"auto-changelog": {
|
|
70
|
+
"output": "CHANGELOG.md",
|
|
71
|
+
"template": "keepachangelog",
|
|
72
|
+
"unreleased": false,
|
|
73
|
+
"commitLimit": false,
|
|
74
|
+
"backfillLimit": false,
|
|
75
|
+
"hideCredit": true
|
|
76
|
+
},
|
|
77
|
+
"publishConfig": {
|
|
78
|
+
"ignore": [
|
|
79
|
+
".github/workflows"
|
|
80
|
+
]
|
|
81
|
+
},
|
|
82
|
+
"engines": {
|
|
83
|
+
"node": ">= 0.4"
|
|
84
|
+
}
|
|
85
|
+
}
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var test = require('tape');
|
|
4
|
+
|
|
5
|
+
var getSideChannel = require('../');
|
|
6
|
+
|
|
7
|
+
test('getSideChannel', function (t) {
|
|
8
|
+
t.test('export', function (st) {
|
|
9
|
+
st.equal(typeof getSideChannel, 'function', 'is a function');
|
|
10
|
+
|
|
11
|
+
st.equal(getSideChannel.length, 0, 'takes no arguments');
|
|
12
|
+
|
|
13
|
+
var channel = getSideChannel();
|
|
14
|
+
st.ok(channel, 'is truthy');
|
|
15
|
+
st.equal(typeof channel, 'object', 'is an object');
|
|
16
|
+
st.end();
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
t.test('assert', function (st) {
|
|
20
|
+
var channel = getSideChannel();
|
|
21
|
+
st['throws'](
|
|
22
|
+
function () { channel.assert({}); },
|
|
23
|
+
TypeError,
|
|
24
|
+
'nonexistent value throws'
|
|
25
|
+
);
|
|
26
|
+
|
|
27
|
+
var o = {};
|
|
28
|
+
channel.set(o, 'data');
|
|
29
|
+
st.doesNotThrow(function () { channel.assert(o); }, 'existent value noops');
|
|
30
|
+
|
|
31
|
+
var accessed = false;
|
|
32
|
+
var trap = {};
|
|
33
|
+
Object.defineProperty(trap, 'foo', {
|
|
34
|
+
enumerable: true,
|
|
35
|
+
get: function () {
|
|
36
|
+
accessed = true;
|
|
37
|
+
return 1;
|
|
38
|
+
}
|
|
39
|
+
});
|
|
40
|
+
st['throws'](
|
|
41
|
+
function () { channel.assert(trap); },
|
|
42
|
+
TypeError,
|
|
43
|
+
'missing object key throws'
|
|
44
|
+
);
|
|
45
|
+
st.equal(accessed, false, 'a missing object key is not observably accessed');
|
|
46
|
+
|
|
47
|
+
st.end();
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
t.test('has', function (st) {
|
|
51
|
+
var channel = getSideChannel();
|
|
52
|
+
/** @type {unknown[]} */ var o = [];
|
|
53
|
+
|
|
54
|
+
st.equal(channel.has(o), false, 'nonexistent value yields false');
|
|
55
|
+
|
|
56
|
+
channel.set(o, 'foo');
|
|
57
|
+
st.equal(channel.has(o), true, 'existent value yields true');
|
|
58
|
+
|
|
59
|
+
st.equal(channel.has('abc'), false, 'non object value non existent yields false');
|
|
60
|
+
|
|
61
|
+
channel.set('abc', 'foo');
|
|
62
|
+
st.equal(channel.has('abc'), true, 'non object value that exists yields true');
|
|
63
|
+
|
|
64
|
+
st.end();
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
t.test('get', function (st) {
|
|
68
|
+
var channel = getSideChannel();
|
|
69
|
+
var o = {};
|
|
70
|
+
st.equal(channel.get(o), undefined, 'nonexistent value yields undefined');
|
|
71
|
+
|
|
72
|
+
var data = {};
|
|
73
|
+
channel.set(o, data);
|
|
74
|
+
st.equal(channel.get(o), data, '"get" yields data set by "set"');
|
|
75
|
+
|
|
76
|
+
st.end();
|
|
77
|
+
});
|
|
78
|
+
|
|
79
|
+
t.test('set', function (st) {
|
|
80
|
+
var channel = getSideChannel();
|
|
81
|
+
var o = function () {};
|
|
82
|
+
st.equal(channel.get(o), undefined, 'value not set');
|
|
83
|
+
|
|
84
|
+
channel.set(o, 42);
|
|
85
|
+
st.equal(channel.get(o), 42, 'value was set');
|
|
86
|
+
|
|
87
|
+
channel.set(o, Infinity);
|
|
88
|
+
st.equal(channel.get(o), Infinity, 'value was set again');
|
|
89
|
+
|
|
90
|
+
var o2 = {};
|
|
91
|
+
channel.set(o2, 17);
|
|
92
|
+
st.equal(channel.get(o), Infinity, 'o is not modified');
|
|
93
|
+
st.equal(channel.get(o2), 17, 'o2 is set');
|
|
94
|
+
|
|
95
|
+
channel.set(o, 14);
|
|
96
|
+
st.equal(channel.get(o), 14, 'o is modified');
|
|
97
|
+
st.equal(channel.get(o2), 17, 'o2 is not modified');
|
|
98
|
+
|
|
99
|
+
st.end();
|
|
100
|
+
});
|
|
101
|
+
|
|
102
|
+
t.test('delete', function (st) {
|
|
103
|
+
var channel = getSideChannel();
|
|
104
|
+
var o = {};
|
|
105
|
+
st.equal(channel['delete']({}), false, 'nonexistent value yields false');
|
|
106
|
+
|
|
107
|
+
channel.set(o, 42);
|
|
108
|
+
st.equal(channel.has(o), true, 'value is set');
|
|
109
|
+
|
|
110
|
+
st.equal(channel['delete']({}), false, 'nonexistent value still yields false');
|
|
111
|
+
|
|
112
|
+
st.equal(channel['delete'](o), true, 'deleted value yields true');
|
|
113
|
+
|
|
114
|
+
st.equal(channel.has(o), false, 'value is no longer set');
|
|
115
|
+
|
|
116
|
+
st.end();
|
|
117
|
+
});
|
|
118
|
+
|
|
119
|
+
t.end();
|
|
120
|
+
});
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
# These are supported funding model platforms
|
|
2
|
+
|
|
3
|
+
github: [ljharb]
|
|
4
|
+
patreon: # Replace with a single Patreon username
|
|
5
|
+
open_collective: # Replace with a single Open Collective username
|
|
6
|
+
ko_fi: # Replace with a single Ko-fi username
|
|
7
|
+
tidelift: npm/side-channel-list
|
|
8
|
+
community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry
|
|
9
|
+
liberapay: # Replace with a single Liberapay username
|
|
10
|
+
issuehunt: # Replace with a single IssueHunt username
|
|
11
|
+
otechie: # Replace with a single Otechie username
|
|
12
|
+
custom: # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2']
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
declare namespace getSideChannelList {
|
|
2
|
+
type Channel<K, V> = {
|
|
3
|
+
assert: (key: K) => void;
|
|
4
|
+
has: (key: K) => boolean;
|
|
5
|
+
get: (key: K) => V | undefined;
|
|
6
|
+
set: (key: K, value: V) => void;
|
|
7
|
+
delete: (key: K) => boolean;
|
|
8
|
+
};
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
declare function getSideChannelList<V, K>(): getSideChannelList.Channel<K, V>;
|
|
12
|
+
|
|
13
|
+
export = getSideChannelList;
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var inspect = require('object-inspect');
|
|
4
|
+
|
|
5
|
+
var $TypeError = require('es-errors/type');
|
|
6
|
+
|
|
7
|
+
/*
|
|
8
|
+
* This function traverses the list returning the node corresponding to the given key.
|
|
9
|
+
*
|
|
10
|
+
* 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.
|
|
11
|
+
* By doing so, all the recently used nodes can be accessed relatively quickly.
|
|
12
|
+
*/
|
|
13
|
+
/** @type {import('./list.d.ts').listGetNode} */
|
|
14
|
+
// eslint-disable-next-line consistent-return
|
|
15
|
+
var listGetNode = function (list, key, isDelete) {
|
|
16
|
+
/** @type {typeof list | NonNullable<(typeof list)['next']>} */
|
|
17
|
+
var prev = list;
|
|
18
|
+
/** @type {(typeof list)['next']} */
|
|
19
|
+
var curr;
|
|
20
|
+
// eslint-disable-next-line eqeqeq
|
|
21
|
+
for (; (curr = prev.next) != null; prev = curr) {
|
|
22
|
+
if (curr.key === key) {
|
|
23
|
+
prev.next = curr.next;
|
|
24
|
+
if (!isDelete) {
|
|
25
|
+
// eslint-disable-next-line no-extra-parens
|
|
26
|
+
curr.next = /** @type {NonNullable<typeof list.next>} */ (list.next);
|
|
27
|
+
list.next = curr; // eslint-disable-line no-param-reassign
|
|
28
|
+
}
|
|
29
|
+
return curr;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
/** @type {import('./list.d.ts').listGet} */
|
|
35
|
+
var listGet = function (objects, key) {
|
|
36
|
+
if (!objects) {
|
|
37
|
+
return void undefined;
|
|
38
|
+
}
|
|
39
|
+
var node = listGetNode(objects, key);
|
|
40
|
+
return node && node.value;
|
|
41
|
+
};
|
|
42
|
+
/** @type {import('./list.d.ts').listSet} */
|
|
43
|
+
var listSet = function (objects, key, value) {
|
|
44
|
+
var node = listGetNode(objects, key);
|
|
45
|
+
if (node) {
|
|
46
|
+
node.value = value;
|
|
47
|
+
} else {
|
|
48
|
+
// Prepend the new node to the beginning of the list
|
|
49
|
+
objects.next = /** @type {import('./list.d.ts').ListNode<typeof value, typeof key>} */ ({ // eslint-disable-line no-param-reassign, no-extra-parens
|
|
50
|
+
key: key,
|
|
51
|
+
next: objects.next,
|
|
52
|
+
value: value
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
};
|
|
56
|
+
/** @type {import('./list.d.ts').listHas} */
|
|
57
|
+
var listHas = function (objects, key) {
|
|
58
|
+
if (!objects) {
|
|
59
|
+
return false;
|
|
60
|
+
}
|
|
61
|
+
return !!listGetNode(objects, key);
|
|
62
|
+
};
|
|
63
|
+
/** @type {import('./list.d.ts').listDelete} */
|
|
64
|
+
// eslint-disable-next-line consistent-return
|
|
65
|
+
var listDelete = function (objects, key) {
|
|
66
|
+
if (objects) {
|
|
67
|
+
return listGetNode(objects, key, true);
|
|
68
|
+
}
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
/** @type {import('.')} */
|
|
72
|
+
module.exports = function getSideChannelList() {
|
|
73
|
+
/** @typedef {ReturnType<typeof getSideChannelList>} Channel */
|
|
74
|
+
/** @typedef {Parameters<Channel['get']>[0]} K */
|
|
75
|
+
/** @typedef {Parameters<Channel['set']>[1]} V */
|
|
76
|
+
|
|
77
|
+
/** @type {import('./list.d.ts').RootNode<V, K> | undefined} */ var $o;
|
|
78
|
+
|
|
79
|
+
/** @type {Channel} */
|
|
80
|
+
var channel = {
|
|
81
|
+
assert: function (key) {
|
|
82
|
+
if (!channel.has(key)) {
|
|
83
|
+
throw new $TypeError('Side channel does not contain ' + inspect(key));
|
|
84
|
+
}
|
|
85
|
+
},
|
|
86
|
+
'delete': function (key) {
|
|
87
|
+
var deletedNode = listDelete($o, key);
|
|
88
|
+
if (deletedNode && $o && !$o.next) {
|
|
89
|
+
$o = void undefined;
|
|
90
|
+
}
|
|
91
|
+
return !!deletedNode;
|
|
92
|
+
},
|
|
93
|
+
get: function (key) {
|
|
94
|
+
return listGet($o, key);
|
|
95
|
+
},
|
|
96
|
+
has: function (key) {
|
|
97
|
+
return listHas($o, key);
|
|
98
|
+
},
|
|
99
|
+
set: function (key, value) {
|
|
100
|
+
if (!$o) {
|
|
101
|
+
// 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
|
|
102
|
+
$o = {
|
|
103
|
+
next: void undefined
|
|
104
|
+
};
|
|
105
|
+
}
|
|
106
|
+
// eslint-disable-next-line no-extra-parens
|
|
107
|
+
listSet(/** @type {NonNullable<typeof $o>} */ ($o), key, value);
|
|
108
|
+
}
|
|
109
|
+
};
|
|
110
|
+
return channel;
|
|
111
|
+
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
type ListNode<T, K> = {
|
|
2
|
+
key: K;
|
|
3
|
+
next: undefined | ListNode<T, K>;
|
|
4
|
+
value: T;
|
|
5
|
+
};
|
|
6
|
+
type RootNode<T, K> = {
|
|
7
|
+
next: undefined | ListNode<T, K>;
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
export function listGetNode<T, K>(list: RootNode<T, K>, key: ListNode<T, K>['key'], isDelete?: boolean): ListNode<T, K> | undefined;
|
|
11
|
+
export function listGet<T, K>(objects: undefined | RootNode<T, K>, key: ListNode<T, K>['key']): T | undefined;
|
|
12
|
+
export function listSet<T, K>(objects: RootNode<T, K>, key: ListNode<T, K>['key'], value: T): void;
|
|
13
|
+
export function listHas<T, K>(objects: undefined | RootNode<T, K>, key: ListNode<T, K>['key']): boolean;
|
|
14
|
+
export function listDelete<T, K>(objects: undefined | RootNode<T, K>, key: ListNode<T, K>['key']): ListNode<T, K> | undefined;
|