mirror of
https://code.forgejo.org/actions/setup-node.git
synced 2025-05-20 21:14:45 +00:00
.
This commit is contained in:
parent
9fff29ba6c
commit
00c3b50fca
7278 changed files with 0 additions and 1778943 deletions
217
node_modules/whatwg-url/lib/URL-impl.js
generated
vendored
217
node_modules/whatwg-url/lib/URL-impl.js
generated
vendored
|
@ -1,217 +0,0 @@
|
|||
"use strict";
|
||||
const usm = require("./url-state-machine");
|
||||
const urlencoded = require("./urlencoded");
|
||||
const URLSearchParams = require("./URLSearchParams");
|
||||
|
||||
exports.implementation = class URLImpl {
|
||||
constructor(constructorArgs) {
|
||||
const url = constructorArgs[0];
|
||||
const base = constructorArgs[1];
|
||||
|
||||
let parsedBase = null;
|
||||
if (base !== undefined) {
|
||||
parsedBase = usm.basicURLParse(base);
|
||||
if (parsedBase === null) {
|
||||
throw new TypeError("Invalid base URL");
|
||||
}
|
||||
}
|
||||
|
||||
const parsedURL = usm.basicURLParse(url, { baseURL: parsedBase });
|
||||
if (parsedURL === null) {
|
||||
throw new TypeError("Invalid URL");
|
||||
}
|
||||
|
||||
const query = parsedURL.query !== null ? parsedURL.query : "";
|
||||
|
||||
this._url = parsedURL;
|
||||
|
||||
// We cannot invoke the "new URLSearchParams object" algorithm without going through the constructor, which strips
|
||||
// question mark by default. Therefore the doNotStripQMark hack is used.
|
||||
this._query = URLSearchParams.createImpl([query], { doNotStripQMark: true });
|
||||
this._query._url = this;
|
||||
}
|
||||
|
||||
get href() {
|
||||
return usm.serializeURL(this._url);
|
||||
}
|
||||
|
||||
set href(v) {
|
||||
const parsedURL = usm.basicURLParse(v);
|
||||
if (parsedURL === null) {
|
||||
throw new TypeError("Invalid URL");
|
||||
}
|
||||
|
||||
this._url = parsedURL;
|
||||
|
||||
this._query._list.splice(0);
|
||||
const { query } = parsedURL;
|
||||
if (query !== null) {
|
||||
this._query._list = urlencoded.parseUrlencoded(query);
|
||||
}
|
||||
}
|
||||
|
||||
get origin() {
|
||||
return usm.serializeURLOrigin(this._url);
|
||||
}
|
||||
|
||||
get protocol() {
|
||||
return this._url.scheme + ":";
|
||||
}
|
||||
|
||||
set protocol(v) {
|
||||
usm.basicURLParse(v + ":", { url: this._url, stateOverride: "scheme start" });
|
||||
}
|
||||
|
||||
get username() {
|
||||
return this._url.username;
|
||||
}
|
||||
|
||||
set username(v) {
|
||||
if (usm.cannotHaveAUsernamePasswordPort(this._url)) {
|
||||
return;
|
||||
}
|
||||
|
||||
usm.setTheUsername(this._url, v);
|
||||
}
|
||||
|
||||
get password() {
|
||||
return this._url.password;
|
||||
}
|
||||
|
||||
set password(v) {
|
||||
if (usm.cannotHaveAUsernamePasswordPort(this._url)) {
|
||||
return;
|
||||
}
|
||||
|
||||
usm.setThePassword(this._url, v);
|
||||
}
|
||||
|
||||
get host() {
|
||||
const url = this._url;
|
||||
|
||||
if (url.host === null) {
|
||||
return "";
|
||||
}
|
||||
|
||||
if (url.port === null) {
|
||||
return usm.serializeHost(url.host);
|
||||
}
|
||||
|
||||
return usm.serializeHost(url.host) + ":" + usm.serializeInteger(url.port);
|
||||
}
|
||||
|
||||
set host(v) {
|
||||
if (this._url.cannotBeABaseURL) {
|
||||
return;
|
||||
}
|
||||
|
||||
usm.basicURLParse(v, { url: this._url, stateOverride: "host" });
|
||||
}
|
||||
|
||||
get hostname() {
|
||||
if (this._url.host === null) {
|
||||
return "";
|
||||
}
|
||||
|
||||
return usm.serializeHost(this._url.host);
|
||||
}
|
||||
|
||||
set hostname(v) {
|
||||
if (this._url.cannotBeABaseURL) {
|
||||
return;
|
||||
}
|
||||
|
||||
usm.basicURLParse(v, { url: this._url, stateOverride: "hostname" });
|
||||
}
|
||||
|
||||
get port() {
|
||||
if (this._url.port === null) {
|
||||
return "";
|
||||
}
|
||||
|
||||
return usm.serializeInteger(this._url.port);
|
||||
}
|
||||
|
||||
set port(v) {
|
||||
if (usm.cannotHaveAUsernamePasswordPort(this._url)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (v === "") {
|
||||
this._url.port = null;
|
||||
} else {
|
||||
usm.basicURLParse(v, { url: this._url, stateOverride: "port" });
|
||||
}
|
||||
}
|
||||
|
||||
get pathname() {
|
||||
if (this._url.cannotBeABaseURL) {
|
||||
return this._url.path[0];
|
||||
}
|
||||
|
||||
if (this._url.path.length === 0) {
|
||||
return "";
|
||||
}
|
||||
|
||||
return "/" + this._url.path.join("/");
|
||||
}
|
||||
|
||||
set pathname(v) {
|
||||
if (this._url.cannotBeABaseURL) {
|
||||
return;
|
||||
}
|
||||
|
||||
this._url.path = [];
|
||||
usm.basicURLParse(v, { url: this._url, stateOverride: "path start" });
|
||||
}
|
||||
|
||||
get search() {
|
||||
if (this._url.query === null || this._url.query === "") {
|
||||
return "";
|
||||
}
|
||||
|
||||
return "?" + this._url.query;
|
||||
}
|
||||
|
||||
set search(v) {
|
||||
const url = this._url;
|
||||
|
||||
if (v === "") {
|
||||
url.query = null;
|
||||
this._query._list = [];
|
||||
return;
|
||||
}
|
||||
|
||||
const input = v[0] === "?" ? v.substring(1) : v;
|
||||
url.query = "";
|
||||
usm.basicURLParse(input, { url, stateOverride: "query" });
|
||||
this._query._list = urlencoded.parseUrlencoded(input);
|
||||
}
|
||||
|
||||
get searchParams() {
|
||||
return this._query;
|
||||
}
|
||||
|
||||
get hash() {
|
||||
if (this._url.fragment === null || this._url.fragment === "") {
|
||||
return "";
|
||||
}
|
||||
|
||||
return "#" + this._url.fragment;
|
||||
}
|
||||
|
||||
set hash(v) {
|
||||
if (v === "") {
|
||||
this._url.fragment = null;
|
||||
return;
|
||||
}
|
||||
|
||||
const input = v[0] === "#" ? v.substring(1) : v;
|
||||
this._url.fragment = "";
|
||||
usm.basicURLParse(input, { url: this._url, stateOverride: "fragment" });
|
||||
}
|
||||
|
||||
toJSON() {
|
||||
return this.href;
|
||||
}
|
||||
};
|
396
node_modules/whatwg-url/lib/URL.js
generated
vendored
396
node_modules/whatwg-url/lib/URL.js
generated
vendored
|
@ -1,396 +0,0 @@
|
|||
"use strict";
|
||||
|
||||
const conversions = require("webidl-conversions");
|
||||
const utils = require("./utils.js");
|
||||
|
||||
const impl = utils.implSymbol;
|
||||
|
||||
function URL(url) {
|
||||
if (!new.target) {
|
||||
throw new TypeError(
|
||||
"Failed to construct 'URL'. Please use the 'new' operator; this constructor " + "cannot be called as a function."
|
||||
);
|
||||
}
|
||||
if (arguments.length < 1) {
|
||||
throw new TypeError(
|
||||
"Failed to construct 'URL': 1 " + "argument required, but only " + arguments.length + " present."
|
||||
);
|
||||
}
|
||||
|
||||
const args = [];
|
||||
for (let i = 0; i < arguments.length && i < 2; ++i) {
|
||||
args[i] = arguments[i];
|
||||
}
|
||||
|
||||
args[0] = conversions["USVString"](args[0], { context: "Failed to construct 'URL': parameter 1" });
|
||||
|
||||
if (args[1] !== undefined) {
|
||||
args[1] = conversions["USVString"](args[1], { context: "Failed to construct 'URL': parameter 2" });
|
||||
}
|
||||
|
||||
iface.setup(this, args);
|
||||
}
|
||||
|
||||
Object.defineProperty(URL, "prototype", {
|
||||
value: URL.prototype,
|
||||
writable: false,
|
||||
enumerable: false,
|
||||
configurable: false
|
||||
});
|
||||
|
||||
URL.prototype.toJSON = function toJSON() {
|
||||
if (!this || !module.exports.is(this)) {
|
||||
throw new TypeError("Illegal invocation");
|
||||
}
|
||||
|
||||
return this[impl].toJSON();
|
||||
};
|
||||
|
||||
Object.defineProperty(URL.prototype, "href", {
|
||||
get() {
|
||||
if (!this || !module.exports.is(this)) {
|
||||
throw new TypeError("Illegal invocation");
|
||||
}
|
||||
|
||||
return this[impl]["href"];
|
||||
},
|
||||
|
||||
set(V) {
|
||||
if (!this || !module.exports.is(this)) {
|
||||
throw new TypeError("Illegal invocation");
|
||||
}
|
||||
|
||||
V = conversions["USVString"](V, { context: "Failed to set the 'href' property on 'URL': The provided value" });
|
||||
|
||||
this[impl]["href"] = V;
|
||||
},
|
||||
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
});
|
||||
|
||||
URL.prototype.toString = function toString() {
|
||||
if (!this || !module.exports.is(this)) {
|
||||
throw new TypeError("Illegal invocation");
|
||||
}
|
||||
return this[impl]["href"];
|
||||
};
|
||||
|
||||
Object.defineProperty(URL.prototype, "origin", {
|
||||
get() {
|
||||
if (!this || !module.exports.is(this)) {
|
||||
throw new TypeError("Illegal invocation");
|
||||
}
|
||||
|
||||
return this[impl]["origin"];
|
||||
},
|
||||
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
});
|
||||
|
||||
Object.defineProperty(URL.prototype, "protocol", {
|
||||
get() {
|
||||
if (!this || !module.exports.is(this)) {
|
||||
throw new TypeError("Illegal invocation");
|
||||
}
|
||||
|
||||
return this[impl]["protocol"];
|
||||
},
|
||||
|
||||
set(V) {
|
||||
if (!this || !module.exports.is(this)) {
|
||||
throw new TypeError("Illegal invocation");
|
||||
}
|
||||
|
||||
V = conversions["USVString"](V, { context: "Failed to set the 'protocol' property on 'URL': The provided value" });
|
||||
|
||||
this[impl]["protocol"] = V;
|
||||
},
|
||||
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
});
|
||||
|
||||
Object.defineProperty(URL.prototype, "username", {
|
||||
get() {
|
||||
if (!this || !module.exports.is(this)) {
|
||||
throw new TypeError("Illegal invocation");
|
||||
}
|
||||
|
||||
return this[impl]["username"];
|
||||
},
|
||||
|
||||
set(V) {
|
||||
if (!this || !module.exports.is(this)) {
|
||||
throw new TypeError("Illegal invocation");
|
||||
}
|
||||
|
||||
V = conversions["USVString"](V, { context: "Failed to set the 'username' property on 'URL': The provided value" });
|
||||
|
||||
this[impl]["username"] = V;
|
||||
},
|
||||
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
});
|
||||
|
||||
Object.defineProperty(URL.prototype, "password", {
|
||||
get() {
|
||||
if (!this || !module.exports.is(this)) {
|
||||
throw new TypeError("Illegal invocation");
|
||||
}
|
||||
|
||||
return this[impl]["password"];
|
||||
},
|
||||
|
||||
set(V) {
|
||||
if (!this || !module.exports.is(this)) {
|
||||
throw new TypeError("Illegal invocation");
|
||||
}
|
||||
|
||||
V = conversions["USVString"](V, { context: "Failed to set the 'password' property on 'URL': The provided value" });
|
||||
|
||||
this[impl]["password"] = V;
|
||||
},
|
||||
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
});
|
||||
|
||||
Object.defineProperty(URL.prototype, "host", {
|
||||
get() {
|
||||
if (!this || !module.exports.is(this)) {
|
||||
throw new TypeError("Illegal invocation");
|
||||
}
|
||||
|
||||
return this[impl]["host"];
|
||||
},
|
||||
|
||||
set(V) {
|
||||
if (!this || !module.exports.is(this)) {
|
||||
throw new TypeError("Illegal invocation");
|
||||
}
|
||||
|
||||
V = conversions["USVString"](V, { context: "Failed to set the 'host' property on 'URL': The provided value" });
|
||||
|
||||
this[impl]["host"] = V;
|
||||
},
|
||||
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
});
|
||||
|
||||
Object.defineProperty(URL.prototype, "hostname", {
|
||||
get() {
|
||||
if (!this || !module.exports.is(this)) {
|
||||
throw new TypeError("Illegal invocation");
|
||||
}
|
||||
|
||||
return this[impl]["hostname"];
|
||||
},
|
||||
|
||||
set(V) {
|
||||
if (!this || !module.exports.is(this)) {
|
||||
throw new TypeError("Illegal invocation");
|
||||
}
|
||||
|
||||
V = conversions["USVString"](V, { context: "Failed to set the 'hostname' property on 'URL': The provided value" });
|
||||
|
||||
this[impl]["hostname"] = V;
|
||||
},
|
||||
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
});
|
||||
|
||||
Object.defineProperty(URL.prototype, "port", {
|
||||
get() {
|
||||
if (!this || !module.exports.is(this)) {
|
||||
throw new TypeError("Illegal invocation");
|
||||
}
|
||||
|
||||
return this[impl]["port"];
|
||||
},
|
||||
|
||||
set(V) {
|
||||
if (!this || !module.exports.is(this)) {
|
||||
throw new TypeError("Illegal invocation");
|
||||
}
|
||||
|
||||
V = conversions["USVString"](V, { context: "Failed to set the 'port' property on 'URL': The provided value" });
|
||||
|
||||
this[impl]["port"] = V;
|
||||
},
|
||||
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
});
|
||||
|
||||
Object.defineProperty(URL.prototype, "pathname", {
|
||||
get() {
|
||||
if (!this || !module.exports.is(this)) {
|
||||
throw new TypeError("Illegal invocation");
|
||||
}
|
||||
|
||||
return this[impl]["pathname"];
|
||||
},
|
||||
|
||||
set(V) {
|
||||
if (!this || !module.exports.is(this)) {
|
||||
throw new TypeError("Illegal invocation");
|
||||
}
|
||||
|
||||
V = conversions["USVString"](V, { context: "Failed to set the 'pathname' property on 'URL': The provided value" });
|
||||
|
||||
this[impl]["pathname"] = V;
|
||||
},
|
||||
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
});
|
||||
|
||||
Object.defineProperty(URL.prototype, "search", {
|
||||
get() {
|
||||
if (!this || !module.exports.is(this)) {
|
||||
throw new TypeError("Illegal invocation");
|
||||
}
|
||||
|
||||
return this[impl]["search"];
|
||||
},
|
||||
|
||||
set(V) {
|
||||
if (!this || !module.exports.is(this)) {
|
||||
throw new TypeError("Illegal invocation");
|
||||
}
|
||||
|
||||
V = conversions["USVString"](V, { context: "Failed to set the 'search' property on 'URL': The provided value" });
|
||||
|
||||
this[impl]["search"] = V;
|
||||
},
|
||||
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
});
|
||||
|
||||
Object.defineProperty(URL.prototype, "searchParams", {
|
||||
get() {
|
||||
if (!this || !module.exports.is(this)) {
|
||||
throw new TypeError("Illegal invocation");
|
||||
}
|
||||
|
||||
return utils.getSameObject(this, "searchParams", () => {
|
||||
return utils.tryWrapperForImpl(this[impl]["searchParams"]);
|
||||
});
|
||||
},
|
||||
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
});
|
||||
|
||||
Object.defineProperty(URL.prototype, "hash", {
|
||||
get() {
|
||||
if (!this || !module.exports.is(this)) {
|
||||
throw new TypeError("Illegal invocation");
|
||||
}
|
||||
|
||||
return this[impl]["hash"];
|
||||
},
|
||||
|
||||
set(V) {
|
||||
if (!this || !module.exports.is(this)) {
|
||||
throw new TypeError("Illegal invocation");
|
||||
}
|
||||
|
||||
V = conversions["USVString"](V, { context: "Failed to set the 'hash' property on 'URL': The provided value" });
|
||||
|
||||
this[impl]["hash"] = V;
|
||||
},
|
||||
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
});
|
||||
|
||||
Object.defineProperty(URL.prototype, Symbol.toStringTag, {
|
||||
value: "URL",
|
||||
writable: false,
|
||||
enumerable: false,
|
||||
configurable: true
|
||||
});
|
||||
|
||||
const iface = {
|
||||
mixedInto: [],
|
||||
is(obj) {
|
||||
if (obj) {
|
||||
if (obj[impl] instanceof Impl.implementation) {
|
||||
return true;
|
||||
}
|
||||
for (let i = 0; i < module.exports.mixedInto.length; ++i) {
|
||||
if (obj instanceof module.exports.mixedInto[i]) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
},
|
||||
isImpl(obj) {
|
||||
if (obj) {
|
||||
if (obj instanceof Impl.implementation) {
|
||||
return true;
|
||||
}
|
||||
|
||||
const wrapper = utils.wrapperForImpl(obj);
|
||||
for (let i = 0; i < module.exports.mixedInto.length; ++i) {
|
||||
if (wrapper instanceof module.exports.mixedInto[i]) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
},
|
||||
convert(obj, { context = "The provided value" } = {}) {
|
||||
if (module.exports.is(obj)) {
|
||||
return utils.implForWrapper(obj);
|
||||
}
|
||||
throw new TypeError(`${context} is not of type 'URL'.`);
|
||||
},
|
||||
|
||||
create(constructorArgs, privateData) {
|
||||
let obj = Object.create(URL.prototype);
|
||||
obj = this.setup(obj, constructorArgs, privateData);
|
||||
return obj;
|
||||
},
|
||||
createImpl(constructorArgs, privateData) {
|
||||
let obj = Object.create(URL.prototype);
|
||||
obj = this.setup(obj, constructorArgs, privateData);
|
||||
return utils.implForWrapper(obj);
|
||||
},
|
||||
_internalSetup(obj) {},
|
||||
setup(obj, constructorArgs, privateData) {
|
||||
if (!privateData) privateData = {};
|
||||
|
||||
privateData.wrapper = obj;
|
||||
|
||||
this._internalSetup(obj);
|
||||
Object.defineProperty(obj, impl, {
|
||||
value: new Impl.implementation(constructorArgs, privateData),
|
||||
writable: false,
|
||||
enumerable: false,
|
||||
configurable: true
|
||||
});
|
||||
|
||||
obj[impl][utils.wrapperSymbol] = obj;
|
||||
if (Impl.init) {
|
||||
Impl.init(obj[impl], privateData);
|
||||
}
|
||||
return obj;
|
||||
},
|
||||
interface: URL,
|
||||
expose: {
|
||||
Window: { URL },
|
||||
Worker: { URL }
|
||||
}
|
||||
}; // iface
|
||||
module.exports = iface;
|
||||
|
||||
const Impl = require(".//URL-impl.js");
|
122
node_modules/whatwg-url/lib/URLSearchParams-impl.js
generated
vendored
122
node_modules/whatwg-url/lib/URLSearchParams-impl.js
generated
vendored
|
@ -1,122 +0,0 @@
|
|||
"use strict";
|
||||
const stableSortBy = require("lodash.sortby");
|
||||
const urlencoded = require("./urlencoded");
|
||||
|
||||
exports.implementation = class URLSearchParamsImpl {
|
||||
constructor(constructorArgs, { doNotStripQMark = false }) {
|
||||
let init = constructorArgs[0];
|
||||
this._list = [];
|
||||
this._url = null;
|
||||
|
||||
if (!doNotStripQMark && typeof init === "string" && init[0] === "?") {
|
||||
init = init.slice(1);
|
||||
}
|
||||
|
||||
if (Array.isArray(init)) {
|
||||
for (const pair of init) {
|
||||
if (pair.length !== 2) {
|
||||
throw new TypeError("Failed to construct 'URLSearchParams': parameter 1 sequence's element does not " +
|
||||
"contain exactly two elements.");
|
||||
}
|
||||
this._list.push([pair[0], pair[1]]);
|
||||
}
|
||||
} else if (typeof init === "object" && Object.getPrototypeOf(init) === null) {
|
||||
for (const name of Object.keys(init)) {
|
||||
const value = init[name];
|
||||
this._list.push([name, value]);
|
||||
}
|
||||
} else {
|
||||
this._list = urlencoded.parseUrlencoded(init);
|
||||
}
|
||||
}
|
||||
|
||||
_updateSteps() {
|
||||
if (this._url !== null) {
|
||||
let query = urlencoded.serializeUrlencoded(this._list);
|
||||
if (query === "") {
|
||||
query = null;
|
||||
}
|
||||
this._url._url.query = query;
|
||||
}
|
||||
}
|
||||
|
||||
append(name, value) {
|
||||
this._list.push([name, value]);
|
||||
this._updateSteps();
|
||||
}
|
||||
|
||||
delete(name) {
|
||||
let i = 0;
|
||||
while (i < this._list.length) {
|
||||
if (this._list[i][0] === name) {
|
||||
this._list.splice(i, 1);
|
||||
} else {
|
||||
i++;
|
||||
}
|
||||
}
|
||||
this._updateSteps();
|
||||
}
|
||||
|
||||
get(name) {
|
||||
for (const tuple of this._list) {
|
||||
if (tuple[0] === name) {
|
||||
return tuple[1];
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
getAll(name) {
|
||||
const output = [];
|
||||
for (const tuple of this._list) {
|
||||
if (tuple[0] === name) {
|
||||
output.push(tuple[1]);
|
||||
}
|
||||
}
|
||||
return output;
|
||||
}
|
||||
|
||||
has(name) {
|
||||
for (const tuple of this._list) {
|
||||
if (tuple[0] === name) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
set(name, value) {
|
||||
let found = false;
|
||||
let i = 0;
|
||||
while (i < this._list.length) {
|
||||
if (this._list[i][0] === name) {
|
||||
if (found) {
|
||||
this._list.splice(i, 1);
|
||||
} else {
|
||||
found = true;
|
||||
this._list[i][1] = value;
|
||||
i++;
|
||||
}
|
||||
} else {
|
||||
i++;
|
||||
}
|
||||
}
|
||||
if (!found) {
|
||||
this._list.push([name, value]);
|
||||
}
|
||||
this._updateSteps();
|
||||
}
|
||||
|
||||
sort() {
|
||||
this._list = stableSortBy(this._list, [0]);
|
||||
this._updateSteps();
|
||||
}
|
||||
|
||||
[Symbol.iterator]() {
|
||||
return this._list[Symbol.iterator]();
|
||||
}
|
||||
|
||||
toString() {
|
||||
return urlencoded.serializeUrlencoded(this._list);
|
||||
}
|
||||
};
|
449
node_modules/whatwg-url/lib/URLSearchParams.js
generated
vendored
449
node_modules/whatwg-url/lib/URLSearchParams.js
generated
vendored
|
@ -1,449 +0,0 @@
|
|||
"use strict";
|
||||
|
||||
const conversions = require("webidl-conversions");
|
||||
const utils = require("./utils.js");
|
||||
|
||||
const impl = utils.implSymbol;
|
||||
|
||||
const IteratorPrototype = Object.create(utils.IteratorPrototype, {
|
||||
next: {
|
||||
value: function next() {
|
||||
const internal = this[utils.iterInternalSymbol];
|
||||
const { target, kind, index } = internal;
|
||||
const values = Array.from(target[impl]);
|
||||
const len = values.length;
|
||||
if (index >= len) {
|
||||
return { value: undefined, done: true };
|
||||
}
|
||||
|
||||
const pair = values[index];
|
||||
internal.index = index + 1;
|
||||
const [key, value] = pair.map(utils.tryWrapperForImpl);
|
||||
|
||||
let result;
|
||||
switch (kind) {
|
||||
case "key":
|
||||
result = key;
|
||||
break;
|
||||
case "value":
|
||||
result = value;
|
||||
break;
|
||||
case "key+value":
|
||||
result = [key, value];
|
||||
break;
|
||||
}
|
||||
return { value: result, done: false };
|
||||
},
|
||||
writable: true,
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
},
|
||||
[Symbol.toStringTag]: {
|
||||
value: "URLSearchParamsIterator",
|
||||
writable: false,
|
||||
enumerable: false,
|
||||
configurable: true
|
||||
}
|
||||
});
|
||||
|
||||
function URLSearchParams() {
|
||||
const args = [];
|
||||
for (let i = 0; i < arguments.length && i < 1; ++i) {
|
||||
args[i] = arguments[i];
|
||||
}
|
||||
|
||||
if (args[0] !== undefined) {
|
||||
if (utils.isObject(args[0])) {
|
||||
if (args[0][Symbol.iterator] !== undefined) {
|
||||
if (!utils.isObject(args[0])) {
|
||||
throw new TypeError(
|
||||
"Failed to construct 'URLSearchParams': parameter 1" + " sequence" + " is not an iterable object."
|
||||
);
|
||||
} else {
|
||||
const V = [];
|
||||
const tmp = args[0];
|
||||
for (let nextItem of tmp) {
|
||||
if (!utils.isObject(nextItem)) {
|
||||
throw new TypeError(
|
||||
"Failed to construct 'URLSearchParams': parameter 1" +
|
||||
" sequence" +
|
||||
"'s element" +
|
||||
" is not an iterable object."
|
||||
);
|
||||
} else {
|
||||
const V = [];
|
||||
const tmp = nextItem;
|
||||
for (let nextItem of tmp) {
|
||||
nextItem = conversions["USVString"](nextItem, {
|
||||
context:
|
||||
"Failed to construct 'URLSearchParams': parameter 1" + " sequence" + "'s element" + "'s element"
|
||||
});
|
||||
|
||||
V.push(nextItem);
|
||||
}
|
||||
nextItem = V;
|
||||
}
|
||||
|
||||
V.push(nextItem);
|
||||
}
|
||||
args[0] = V;
|
||||
}
|
||||
} else {
|
||||
if (!utils.isObject(args[0])) {
|
||||
throw new TypeError("Failed to construct 'URLSearchParams': parameter 1" + " record" + " is not an object.");
|
||||
} else {
|
||||
const result = Object.create(null);
|
||||
for (const key of Reflect.ownKeys(args[0])) {
|
||||
const desc = Object.getOwnPropertyDescriptor(args[0], key);
|
||||
if (desc && desc.enumerable) {
|
||||
let typedKey = key;
|
||||
let typedValue = args[0][key];
|
||||
|
||||
typedKey = conversions["USVString"](typedKey, {
|
||||
context: "Failed to construct 'URLSearchParams': parameter 1" + " record" + "'s key"
|
||||
});
|
||||
|
||||
typedValue = conversions["USVString"](typedValue, {
|
||||
context: "Failed to construct 'URLSearchParams': parameter 1" + " record" + "'s value"
|
||||
});
|
||||
|
||||
result[typedKey] = typedValue;
|
||||
}
|
||||
}
|
||||
args[0] = result;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
args[0] = conversions["USVString"](args[0], { context: "Failed to construct 'URLSearchParams': parameter 1" });
|
||||
}
|
||||
} else {
|
||||
args[0] = "";
|
||||
}
|
||||
|
||||
iface.setup(this, args);
|
||||
}
|
||||
|
||||
Object.defineProperty(URLSearchParams, "prototype", {
|
||||
value: URLSearchParams.prototype,
|
||||
writable: false,
|
||||
enumerable: false,
|
||||
configurable: false
|
||||
});
|
||||
|
||||
Object.defineProperty(URLSearchParams.prototype, Symbol.iterator, {
|
||||
writable: true,
|
||||
enumerable: false,
|
||||
configurable: true,
|
||||
value: function entries() {
|
||||
if (!this || !module.exports.is(this)) {
|
||||
throw new TypeError("Illegal invocation");
|
||||
}
|
||||
return module.exports.createDefaultIterator(this, "key+value");
|
||||
}
|
||||
});
|
||||
URLSearchParams.prototype.forEach = function forEach(callback) {
|
||||
if (!this || !module.exports.is(this)) {
|
||||
throw new TypeError("Illegal invocation");
|
||||
}
|
||||
if (arguments.length < 1) {
|
||||
throw new TypeError(
|
||||
"Failed to execute 'forEach' on 'URLSearchParams': 1 argument required, " + "but only 0 present."
|
||||
);
|
||||
}
|
||||
if (typeof callback !== "function") {
|
||||
throw new TypeError(
|
||||
"Failed to execute 'forEach' on 'URLSearchParams': The callback provided " + "as parameter 1 is not a function."
|
||||
);
|
||||
}
|
||||
const thisArg = arguments[1];
|
||||
let pairs = Array.from(this[impl]);
|
||||
let i = 0;
|
||||
while (i < pairs.length) {
|
||||
const [key, value] = pairs[i].map(utils.tryWrapperForImpl);
|
||||
callback.call(thisArg, value, key, this);
|
||||
pairs = Array.from(this[impl]);
|
||||
i++;
|
||||
}
|
||||
};
|
||||
URLSearchParams.prototype.append = function append(name, value) {
|
||||
if (!this || !module.exports.is(this)) {
|
||||
throw new TypeError("Illegal invocation");
|
||||
}
|
||||
|
||||
if (arguments.length < 2) {
|
||||
throw new TypeError(
|
||||
"Failed to execute 'append' on 'URLSearchParams': 2 " +
|
||||
"arguments required, but only " +
|
||||
arguments.length +
|
||||
" present."
|
||||
);
|
||||
}
|
||||
|
||||
const args = [];
|
||||
for (let i = 0; i < arguments.length && i < 2; ++i) {
|
||||
args[i] = arguments[i];
|
||||
}
|
||||
|
||||
args[0] = conversions["USVString"](args[0], {
|
||||
context: "Failed to execute 'append' on 'URLSearchParams': parameter 1"
|
||||
});
|
||||
|
||||
args[1] = conversions["USVString"](args[1], {
|
||||
context: "Failed to execute 'append' on 'URLSearchParams': parameter 2"
|
||||
});
|
||||
|
||||
return this[impl].append(...args);
|
||||
};
|
||||
|
||||
URLSearchParams.prototype.delete = function _(name) {
|
||||
if (!this || !module.exports.is(this)) {
|
||||
throw new TypeError("Illegal invocation");
|
||||
}
|
||||
|
||||
if (arguments.length < 1) {
|
||||
throw new TypeError(
|
||||
"Failed to execute 'delete' on 'URLSearchParams': 1 " +
|
||||
"argument required, but only " +
|
||||
arguments.length +
|
||||
" present."
|
||||
);
|
||||
}
|
||||
|
||||
const args = [];
|
||||
for (let i = 0; i < arguments.length && i < 1; ++i) {
|
||||
args[i] = arguments[i];
|
||||
}
|
||||
|
||||
args[0] = conversions["USVString"](args[0], {
|
||||
context: "Failed to execute 'delete' on 'URLSearchParams': parameter 1"
|
||||
});
|
||||
|
||||
return this[impl].delete(...args);
|
||||
};
|
||||
|
||||
URLSearchParams.prototype.get = function get(name) {
|
||||
if (!this || !module.exports.is(this)) {
|
||||
throw new TypeError("Illegal invocation");
|
||||
}
|
||||
|
||||
if (arguments.length < 1) {
|
||||
throw new TypeError(
|
||||
"Failed to execute 'get' on 'URLSearchParams': 1 " +
|
||||
"argument required, but only " +
|
||||
arguments.length +
|
||||
" present."
|
||||
);
|
||||
}
|
||||
|
||||
const args = [];
|
||||
for (let i = 0; i < arguments.length && i < 1; ++i) {
|
||||
args[i] = arguments[i];
|
||||
}
|
||||
|
||||
args[0] = conversions["USVString"](args[0], { context: "Failed to execute 'get' on 'URLSearchParams': parameter 1" });
|
||||
|
||||
return this[impl].get(...args);
|
||||
};
|
||||
|
||||
URLSearchParams.prototype.getAll = function getAll(name) {
|
||||
if (!this || !module.exports.is(this)) {
|
||||
throw new TypeError("Illegal invocation");
|
||||
}
|
||||
|
||||
if (arguments.length < 1) {
|
||||
throw new TypeError(
|
||||
"Failed to execute 'getAll' on 'URLSearchParams': 1 " +
|
||||
"argument required, but only " +
|
||||
arguments.length +
|
||||
" present."
|
||||
);
|
||||
}
|
||||
|
||||
const args = [];
|
||||
for (let i = 0; i < arguments.length && i < 1; ++i) {
|
||||
args[i] = arguments[i];
|
||||
}
|
||||
|
||||
args[0] = conversions["USVString"](args[0], {
|
||||
context: "Failed to execute 'getAll' on 'URLSearchParams': parameter 1"
|
||||
});
|
||||
|
||||
return utils.tryWrapperForImpl(this[impl].getAll(...args));
|
||||
};
|
||||
|
||||
URLSearchParams.prototype.has = function has(name) {
|
||||
if (!this || !module.exports.is(this)) {
|
||||
throw new TypeError("Illegal invocation");
|
||||
}
|
||||
|
||||
if (arguments.length < 1) {
|
||||
throw new TypeError(
|
||||
"Failed to execute 'has' on 'URLSearchParams': 1 " +
|
||||
"argument required, but only " +
|
||||
arguments.length +
|
||||
" present."
|
||||
);
|
||||
}
|
||||
|
||||
const args = [];
|
||||
for (let i = 0; i < arguments.length && i < 1; ++i) {
|
||||
args[i] = arguments[i];
|
||||
}
|
||||
|
||||
args[0] = conversions["USVString"](args[0], { context: "Failed to execute 'has' on 'URLSearchParams': parameter 1" });
|
||||
|
||||
return this[impl].has(...args);
|
||||
};
|
||||
|
||||
URLSearchParams.prototype.set = function set(name, value) {
|
||||
if (!this || !module.exports.is(this)) {
|
||||
throw new TypeError("Illegal invocation");
|
||||
}
|
||||
|
||||
if (arguments.length < 2) {
|
||||
throw new TypeError(
|
||||
"Failed to execute 'set' on 'URLSearchParams': 2 " +
|
||||
"arguments required, but only " +
|
||||
arguments.length +
|
||||
" present."
|
||||
);
|
||||
}
|
||||
|
||||
const args = [];
|
||||
for (let i = 0; i < arguments.length && i < 2; ++i) {
|
||||
args[i] = arguments[i];
|
||||
}
|
||||
|
||||
args[0] = conversions["USVString"](args[0], { context: "Failed to execute 'set' on 'URLSearchParams': parameter 1" });
|
||||
|
||||
args[1] = conversions["USVString"](args[1], { context: "Failed to execute 'set' on 'URLSearchParams': parameter 2" });
|
||||
|
||||
return this[impl].set(...args);
|
||||
};
|
||||
|
||||
URLSearchParams.prototype.sort = function sort() {
|
||||
if (!this || !module.exports.is(this)) {
|
||||
throw new TypeError("Illegal invocation");
|
||||
}
|
||||
|
||||
return this[impl].sort();
|
||||
};
|
||||
|
||||
URLSearchParams.prototype.toString = function toString() {
|
||||
if (!this || !module.exports.is(this)) {
|
||||
throw new TypeError("Illegal invocation");
|
||||
}
|
||||
|
||||
return this[impl].toString();
|
||||
};
|
||||
|
||||
URLSearchParams.prototype.entries = URLSearchParams.prototype[Symbol.iterator];
|
||||
|
||||
URLSearchParams.prototype.keys = function keys() {
|
||||
if (!this || !module.exports.is(this)) {
|
||||
throw new TypeError("Illegal invocation");
|
||||
}
|
||||
return module.exports.createDefaultIterator(this, "key");
|
||||
};
|
||||
|
||||
URLSearchParams.prototype.values = function values() {
|
||||
if (!this || !module.exports.is(this)) {
|
||||
throw new TypeError("Illegal invocation");
|
||||
}
|
||||
return module.exports.createDefaultIterator(this, "value");
|
||||
};
|
||||
|
||||
Object.defineProperty(URLSearchParams.prototype, Symbol.toStringTag, {
|
||||
value: "URLSearchParams",
|
||||
writable: false,
|
||||
enumerable: false,
|
||||
configurable: true
|
||||
});
|
||||
|
||||
const iface = {
|
||||
mixedInto: [],
|
||||
is(obj) {
|
||||
if (obj) {
|
||||
if (obj[impl] instanceof Impl.implementation) {
|
||||
return true;
|
||||
}
|
||||
for (let i = 0; i < module.exports.mixedInto.length; ++i) {
|
||||
if (obj instanceof module.exports.mixedInto[i]) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
},
|
||||
isImpl(obj) {
|
||||
if (obj) {
|
||||
if (obj instanceof Impl.implementation) {
|
||||
return true;
|
||||
}
|
||||
|
||||
const wrapper = utils.wrapperForImpl(obj);
|
||||
for (let i = 0; i < module.exports.mixedInto.length; ++i) {
|
||||
if (wrapper instanceof module.exports.mixedInto[i]) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
},
|
||||
convert(obj, { context = "The provided value" } = {}) {
|
||||
if (module.exports.is(obj)) {
|
||||
return utils.implForWrapper(obj);
|
||||
}
|
||||
throw new TypeError(`${context} is not of type 'URLSearchParams'.`);
|
||||
},
|
||||
|
||||
createDefaultIterator(target, kind) {
|
||||
const iterator = Object.create(IteratorPrototype);
|
||||
Object.defineProperty(iterator, utils.iterInternalSymbol, {
|
||||
value: { target, kind, index: 0 },
|
||||
writable: false,
|
||||
enumerable: false,
|
||||
configurable: true
|
||||
});
|
||||
return iterator;
|
||||
},
|
||||
|
||||
create(constructorArgs, privateData) {
|
||||
let obj = Object.create(URLSearchParams.prototype);
|
||||
obj = this.setup(obj, constructorArgs, privateData);
|
||||
return obj;
|
||||
},
|
||||
createImpl(constructorArgs, privateData) {
|
||||
let obj = Object.create(URLSearchParams.prototype);
|
||||
obj = this.setup(obj, constructorArgs, privateData);
|
||||
return utils.implForWrapper(obj);
|
||||
},
|
||||
_internalSetup(obj) {},
|
||||
setup(obj, constructorArgs, privateData) {
|
||||
if (!privateData) privateData = {};
|
||||
|
||||
privateData.wrapper = obj;
|
||||
|
||||
this._internalSetup(obj);
|
||||
Object.defineProperty(obj, impl, {
|
||||
value: new Impl.implementation(constructorArgs, privateData),
|
||||
writable: false,
|
||||
enumerable: false,
|
||||
configurable: true
|
||||
});
|
||||
|
||||
obj[impl][utils.wrapperSymbol] = obj;
|
||||
if (Impl.init) {
|
||||
Impl.init(obj[impl], privateData);
|
||||
}
|
||||
return obj;
|
||||
},
|
||||
interface: URLSearchParams,
|
||||
expose: {
|
||||
Window: { URLSearchParams },
|
||||
Worker: { URLSearchParams }
|
||||
}
|
||||
}; // iface
|
||||
module.exports = iface;
|
||||
|
||||
const Impl = require(".//URLSearchParams-impl.js");
|
24
node_modules/whatwg-url/lib/infra.js
generated
vendored
24
node_modules/whatwg-url/lib/infra.js
generated
vendored
|
@ -1,24 +0,0 @@
|
|||
"use strict";
|
||||
|
||||
function isASCIIDigit(c) {
|
||||
return c >= 0x30 && c <= 0x39;
|
||||
}
|
||||
|
||||
function isASCIIAlpha(c) {
|
||||
return (c >= 0x41 && c <= 0x5A) || (c >= 0x61 && c <= 0x7A);
|
||||
}
|
||||
|
||||
function isASCIIAlphanumeric(c) {
|
||||
return isASCIIAlpha(c) || isASCIIDigit(c);
|
||||
}
|
||||
|
||||
function isASCIIHex(c) {
|
||||
return isASCIIDigit(c) || (c >= 0x41 && c <= 0x46) || (c >= 0x61 && c <= 0x66);
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
isASCIIDigit,
|
||||
isASCIIAlpha,
|
||||
isASCIIAlphanumeric,
|
||||
isASCIIHex
|
||||
};
|
16
node_modules/whatwg-url/lib/public-api.js
generated
vendored
16
node_modules/whatwg-url/lib/public-api.js
generated
vendored
|
@ -1,16 +0,0 @@
|
|||
"use strict";
|
||||
|
||||
exports.URL = require("./URL").interface;
|
||||
exports.URLSearchParams = require("./URLSearchParams").interface;
|
||||
|
||||
exports.parseURL = require("./url-state-machine").parseURL;
|
||||
exports.basicURLParse = require("./url-state-machine").basicURLParse;
|
||||
exports.serializeURL = require("./url-state-machine").serializeURL;
|
||||
exports.serializeHost = require("./url-state-machine").serializeHost;
|
||||
exports.serializeInteger = require("./url-state-machine").serializeInteger;
|
||||
exports.serializeURLOrigin = require("./url-state-machine").serializeURLOrigin;
|
||||
exports.setTheUsername = require("./url-state-machine").setTheUsername;
|
||||
exports.setThePassword = require("./url-state-machine").setThePassword;
|
||||
exports.cannotHaveAUsernamePasswordPort = require("./url-state-machine").cannotHaveAUsernamePasswordPort;
|
||||
|
||||
exports.percentDecode = require("./urlencoded").percentDecode;
|
1299
node_modules/whatwg-url/lib/url-state-machine.js
generated
vendored
1299
node_modules/whatwg-url/lib/url-state-machine.js
generated
vendored
File diff suppressed because it is too large
Load diff
138
node_modules/whatwg-url/lib/urlencoded.js
generated
vendored
138
node_modules/whatwg-url/lib/urlencoded.js
generated
vendored
|
@ -1,138 +0,0 @@
|
|||
"use strict";
|
||||
const { isASCIIHex } = require("./infra");
|
||||
|
||||
function strictlySplitByteSequence(buf, cp) {
|
||||
const list = [];
|
||||
let last = 0;
|
||||
let i = buf.indexOf(cp);
|
||||
while (i >= 0) {
|
||||
list.push(buf.slice(last, i));
|
||||
last = i + 1;
|
||||
i = buf.indexOf(cp, last);
|
||||
}
|
||||
if (last !== buf.length) {
|
||||
list.push(buf.slice(last));
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
function replaceByteInByteSequence(buf, from, to) {
|
||||
let i = buf.indexOf(from);
|
||||
while (i >= 0) {
|
||||
buf[i] = to;
|
||||
i = buf.indexOf(from, i + 1);
|
||||
}
|
||||
return buf;
|
||||
}
|
||||
|
||||
function percentEncode(c) {
|
||||
let hex = c.toString(16).toUpperCase();
|
||||
if (hex.length === 1) {
|
||||
hex = "0" + hex;
|
||||
}
|
||||
|
||||
return "%" + hex;
|
||||
}
|
||||
|
||||
function percentDecode(input) {
|
||||
const output = Buffer.alloc(input.byteLength);
|
||||
let ptr = 0;
|
||||
for (let i = 0; i < input.length; ++i) {
|
||||
if (input[i] !== 37 || !isASCIIHex(input[i + 1]) || !isASCIIHex(input[i + 2])) {
|
||||
output[ptr++] = input[i];
|
||||
} else {
|
||||
output[ptr++] = parseInt(input.slice(i + 1, i + 3).toString(), 16);
|
||||
i += 2;
|
||||
}
|
||||
}
|
||||
return output.slice(0, ptr);
|
||||
}
|
||||
|
||||
function parseUrlencoded(input) {
|
||||
const sequences = strictlySplitByteSequence(input, 38);
|
||||
const output = [];
|
||||
for (const bytes of sequences) {
|
||||
if (bytes.length === 0) {
|
||||
continue;
|
||||
}
|
||||
|
||||
let name;
|
||||
let value;
|
||||
const indexOfEqual = bytes.indexOf(61);
|
||||
|
||||
if (indexOfEqual >= 0) {
|
||||
name = bytes.slice(0, indexOfEqual);
|
||||
value = bytes.slice(indexOfEqual + 1);
|
||||
} else {
|
||||
name = bytes;
|
||||
value = Buffer.alloc(0);
|
||||
}
|
||||
|
||||
name = replaceByteInByteSequence(Buffer.from(name), 43, 32);
|
||||
value = replaceByteInByteSequence(Buffer.from(value), 43, 32);
|
||||
|
||||
output.push([percentDecode(name).toString(), percentDecode(value).toString()]);
|
||||
}
|
||||
return output;
|
||||
}
|
||||
|
||||
function serializeUrlencodedByte(input) {
|
||||
let output = "";
|
||||
for (const byte of input) {
|
||||
if (byte === 32) {
|
||||
output += "+";
|
||||
} else if (byte === 42 ||
|
||||
byte === 45 ||
|
||||
byte === 46 ||
|
||||
(byte >= 48 && byte <= 57) ||
|
||||
(byte >= 65 && byte <= 90) ||
|
||||
byte === 95 ||
|
||||
(byte >= 97 && byte <= 122)) {
|
||||
output += String.fromCodePoint(byte);
|
||||
} else {
|
||||
output += percentEncode(byte);
|
||||
}
|
||||
}
|
||||
return output;
|
||||
}
|
||||
|
||||
function serializeUrlencoded(tuples, encodingOverride = undefined) {
|
||||
let encoding = "utf-8";
|
||||
if (encodingOverride !== undefined) {
|
||||
encoding = encodingOverride;
|
||||
}
|
||||
|
||||
let output = "";
|
||||
for (const [i, tuple] of tuples.entries()) {
|
||||
// TODO: handle encoding override
|
||||
const name = serializeUrlencodedByte(Buffer.from(tuple[0]));
|
||||
let value = tuple[1];
|
||||
if (tuple.length > 2 && tuple[2] !== undefined) {
|
||||
if (tuple[2] === "hidden" && name === "_charset_") {
|
||||
value = encoding;
|
||||
} else if (tuple[2] === "file") {
|
||||
// value is a File object
|
||||
value = value.name;
|
||||
}
|
||||
}
|
||||
value = serializeUrlencodedByte(Buffer.from(value));
|
||||
if (i !== 0) {
|
||||
output += "&";
|
||||
}
|
||||
output += `${name}=${value}`;
|
||||
}
|
||||
return output;
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
percentEncode,
|
||||
percentDecode,
|
||||
|
||||
// application/x-www-form-urlencoded string parser
|
||||
parseUrlencoded(input) {
|
||||
return parseUrlencoded(Buffer.from(input));
|
||||
},
|
||||
|
||||
// application/x-www-form-urlencoded serializer
|
||||
serializeUrlencoded
|
||||
};
|
125
node_modules/whatwg-url/lib/utils.js
generated
vendored
125
node_modules/whatwg-url/lib/utils.js
generated
vendored
|
@ -1,125 +0,0 @@
|
|||
"use strict";
|
||||
|
||||
// Returns "Type(value) is Object" in ES terminology.
|
||||
function isObject(value) {
|
||||
return typeof value === "object" && value !== null || typeof value === "function";
|
||||
}
|
||||
|
||||
function getReferenceToBytes(bufferSource) {
|
||||
// Node.js' Buffer does not allow subclassing for now, so we can get away with a prototype object check for perf.
|
||||
if (Object.getPrototypeOf(bufferSource) === Buffer.prototype) {
|
||||
return bufferSource;
|
||||
}
|
||||
if (bufferSource instanceof ArrayBuffer) {
|
||||
return Buffer.from(bufferSource);
|
||||
}
|
||||
return Buffer.from(bufferSource.buffer, bufferSource.byteOffset, bufferSource.byteLength);
|
||||
}
|
||||
|
||||
function getCopyToBytes(bufferSource) {
|
||||
return Buffer.from(getReferenceToBytes(bufferSource));
|
||||
}
|
||||
|
||||
function mixin(target, source) {
|
||||
const keys = Object.getOwnPropertyNames(source);
|
||||
for (let i = 0; i < keys.length; ++i) {
|
||||
if (keys[i] in target) {
|
||||
continue;
|
||||
}
|
||||
|
||||
Object.defineProperty(target, keys[i], Object.getOwnPropertyDescriptor(source, keys[i]));
|
||||
}
|
||||
}
|
||||
|
||||
const wrapperSymbol = Symbol("wrapper");
|
||||
const implSymbol = Symbol("impl");
|
||||
const sameObjectCaches = Symbol("SameObject caches");
|
||||
|
||||
function getSameObject(wrapper, prop, creator) {
|
||||
if (!wrapper[sameObjectCaches]) {
|
||||
wrapper[sameObjectCaches] = Object.create(null);
|
||||
}
|
||||
|
||||
if (prop in wrapper[sameObjectCaches]) {
|
||||
return wrapper[sameObjectCaches][prop];
|
||||
}
|
||||
|
||||
wrapper[sameObjectCaches][prop] = creator();
|
||||
return wrapper[sameObjectCaches][prop];
|
||||
}
|
||||
|
||||
function wrapperForImpl(impl) {
|
||||
return impl ? impl[wrapperSymbol] : null;
|
||||
}
|
||||
|
||||
function implForWrapper(wrapper) {
|
||||
return wrapper ? wrapper[implSymbol] : null;
|
||||
}
|
||||
|
||||
function tryWrapperForImpl(impl) {
|
||||
const wrapper = wrapperForImpl(impl);
|
||||
return wrapper ? wrapper : impl;
|
||||
}
|
||||
|
||||
function tryImplForWrapper(wrapper) {
|
||||
const impl = implForWrapper(wrapper);
|
||||
return impl ? impl : wrapper;
|
||||
}
|
||||
|
||||
const iterInternalSymbol = Symbol("internal");
|
||||
const IteratorPrototype = Object.getPrototypeOf(Object.getPrototypeOf([][Symbol.iterator]()));
|
||||
|
||||
function isArrayIndexPropName(P) {
|
||||
if (typeof P !== "string") {
|
||||
return false;
|
||||
}
|
||||
const i = P >>> 0;
|
||||
if (i === Math.pow(2, 32) - 1) {
|
||||
return false;
|
||||
}
|
||||
const s = `${i}`;
|
||||
if (P !== s) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
const supportsPropertyIndex = Symbol("supports property index");
|
||||
const supportedPropertyIndices = Symbol("supported property indices");
|
||||
const supportsPropertyName = Symbol("supports property name");
|
||||
const supportedPropertyNames = Symbol("supported property names");
|
||||
const indexedGet = Symbol("indexed property get");
|
||||
const indexedSetNew = Symbol("indexed property set new");
|
||||
const indexedSetExisting = Symbol("indexed property set existing");
|
||||
const namedGet = Symbol("named property get");
|
||||
const namedSetNew = Symbol("named property set new");
|
||||
const namedSetExisting = Symbol("named property set existing");
|
||||
const namedDelete = Symbol("named property delete");
|
||||
|
||||
module.exports = exports = {
|
||||
isObject,
|
||||
getReferenceToBytes,
|
||||
getCopyToBytes,
|
||||
mixin,
|
||||
wrapperSymbol,
|
||||
implSymbol,
|
||||
getSameObject,
|
||||
wrapperForImpl,
|
||||
implForWrapper,
|
||||
tryWrapperForImpl,
|
||||
tryImplForWrapper,
|
||||
iterInternalSymbol,
|
||||
IteratorPrototype,
|
||||
isArrayIndexPropName,
|
||||
supportsPropertyIndex,
|
||||
supportedPropertyIndices,
|
||||
supportsPropertyName,
|
||||
supportedPropertyNames,
|
||||
indexedGet,
|
||||
indexedSetNew,
|
||||
indexedSetExisting,
|
||||
namedGet,
|
||||
namedSetNew,
|
||||
namedSetExisting,
|
||||
namedDelete
|
||||
};
|
Loading…
Add table
Add a link
Reference in a new issue