initial commit
migrate files over from github
This commit is contained in:
15
node_modules/side-channel-weakmap/index.d.ts
generated
vendored
Normal file
15
node_modules/side-channel-weakmap/index.d.ts
generated
vendored
Normal file
@ -0,0 +1,15 @@
|
||||
declare namespace getSideChannelWeakMap {
|
||||
type Channel<K, V> = {
|
||||
assert: (key: K) => void;
|
||||
has: (key: K) => boolean;
|
||||
get: (key: K) => V | undefined;
|
||||
set: (key: K, value: V) => void;
|
||||
delete: (key: K) => boolean;
|
||||
}
|
||||
}
|
||||
|
||||
declare function getSideChannelWeakMap<K, V>(): getSideChannelWeakMap.Channel<K, V>;
|
||||
|
||||
declare const x: false | typeof getSideChannelWeakMap;
|
||||
|
||||
export = x;
|
84
node_modules/side-channel-weakmap/index.js
generated
vendored
Normal file
84
node_modules/side-channel-weakmap/index.js
generated
vendored
Normal file
@ -0,0 +1,84 @@
|
||||
'use strict';
|
||||
|
||||
var GetIntrinsic = require('get-intrinsic');
|
||||
var callBound = require('call-bound');
|
||||
var inspect = require('object-inspect');
|
||||
var getSideChannelMap = require('side-channel-map');
|
||||
|
||||
var $TypeError = require('es-errors/type');
|
||||
var $WeakMap = GetIntrinsic('%WeakMap%', true);
|
||||
|
||||
/** @type {<K extends object, V>(thisArg: WeakMap<K, V>, key: K) => V} */
|
||||
var $weakMapGet = callBound('WeakMap.prototype.get', true);
|
||||
/** @type {<K extends object, V>(thisArg: WeakMap<K, V>, key: K, value: V) => void} */
|
||||
var $weakMapSet = callBound('WeakMap.prototype.set', true);
|
||||
/** @type {<K extends object, V>(thisArg: WeakMap<K, V>, key: K) => boolean} */
|
||||
var $weakMapHas = callBound('WeakMap.prototype.has', true);
|
||||
/** @type {<K extends object, V>(thisArg: WeakMap<K, V>, key: K) => boolean} */
|
||||
var $weakMapDelete = callBound('WeakMap.prototype.delete', true);
|
||||
|
||||
/** @type {import('.')} */
|
||||
module.exports = $WeakMap
|
||||
? /** @type {Exclude<import('.'), false>} */ function getSideChannelWeakMap() {
|
||||
/** @typedef {ReturnType<typeof getSideChannelWeakMap>} Channel */
|
||||
/** @typedef {Parameters<Channel['get']>[0]} K */
|
||||
/** @typedef {Parameters<Channel['set']>[1]} V */
|
||||
|
||||
/** @type {WeakMap<K & object, V> | undefined} */ var $wm;
|
||||
/** @type {Channel | undefined} */ var $m;
|
||||
|
||||
/** @type {Channel} */
|
||||
var channel = {
|
||||
assert: function (key) {
|
||||
if (!channel.has(key)) {
|
||||
throw new $TypeError('Side channel does not contain ' + inspect(key));
|
||||
}
|
||||
},
|
||||
'delete': function (key) {
|
||||
if ($WeakMap && key && (typeof key === 'object' || typeof key === 'function')) {
|
||||
if ($wm) {
|
||||
return $weakMapDelete($wm, key);
|
||||
}
|
||||
} else if (getSideChannelMap) {
|
||||
if ($m) {
|
||||
return $m['delete'](key);
|
||||
}
|
||||
}
|
||||
return false;
|
||||
},
|
||||
get: function (key) {
|
||||
if ($WeakMap && key && (typeof key === 'object' || typeof key === 'function')) {
|
||||
if ($wm) {
|
||||
return $weakMapGet($wm, key);
|
||||
}
|
||||
}
|
||||
return $m && $m.get(key);
|
||||
},
|
||||
has: function (key) {
|
||||
if ($WeakMap && key && (typeof key === 'object' || typeof key === 'function')) {
|
||||
if ($wm) {
|
||||
return $weakMapHas($wm, key);
|
||||
}
|
||||
}
|
||||
return !!$m && $m.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 (getSideChannelMap) {
|
||||
if (!$m) {
|
||||
$m = getSideChannelMap();
|
||||
}
|
||||
// eslint-disable-next-line no-extra-parens
|
||||
/** @type {NonNullable<typeof $m>} */ ($m).set(key, value);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
// @ts-expect-error TODO: figure out why this is erroring
|
||||
return channel;
|
||||
}
|
||||
: getSideChannelMap;
|
87
node_modules/side-channel-weakmap/package.json
generated
vendored
Normal file
87
node_modules/side-channel-weakmap/package.json
generated
vendored
Normal file
@ -0,0 +1,87 @@
|
||||
{
|
||||
"name": "side-channel-weakmap",
|
||||
"version": "1.0.2",
|
||||
"description": "Store information about any JS value in a side channel. Uses WeakMap if available.",
|
||||
"main": "index.js",
|
||||
"exports": {
|
||||
".": "./index.js",
|
||||
"./package.json": "./package.json"
|
||||
},
|
||||
"types": "./index.d.ts",
|
||||
"scripts": {
|
||||
"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 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)\")\""
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/ljharb/side-channel-weakmap.git"
|
||||
},
|
||||
"keywords": [
|
||||
"weakmap",
|
||||
"map",
|
||||
"side",
|
||||
"channel",
|
||||
"metadata"
|
||||
],
|
||||
"author": "Jordan Harband <ljharb@gmail.com>",
|
||||
"funding": {
|
||||
"url": "https://github.com/sponsors/ljharb"
|
||||
},
|
||||
"license": "MIT",
|
||||
"bugs": {
|
||||
"url": "https://github.com/ljharb/side-channel-weakmap/issues"
|
||||
},
|
||||
"homepage": "https://github.com/ljharb/side-channel-weakmap#readme",
|
||||
"dependencies": {
|
||||
"call-bound": "^1.0.2",
|
||||
"es-errors": "^1.3.0",
|
||||
"get-intrinsic": "^1.2.5",
|
||||
"object-inspect": "^1.13.3",
|
||||
"side-channel-map": "^1.0.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@arethetypeswrong/cli": "^0.17.1",
|
||||
"@ljharb/eslint-config": "^21.1.1",
|
||||
"@ljharb/tsconfig": "^0.2.2",
|
||||
"@types/call-bind": "^1.0.5",
|
||||
"@types/get-intrinsic": "^1.2.3",
|
||||
"@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",
|
||||
"template": "keepachangelog",
|
||||
"unreleased": false,
|
||||
"commitLimit": false,
|
||||
"backfillLimit": false,
|
||||
"hideCredit": true
|
||||
},
|
||||
"publishConfig": {
|
||||
"ignore": [
|
||||
".github/workflows"
|
||||
]
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 0.4"
|
||||
}
|
||||
}
|
9
node_modules/side-channel-weakmap/tsconfig.json
generated
vendored
Normal file
9
node_modules/side-channel-weakmap/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