reduce the import weight of internal/primordials (#16209)

This commit is contained in:
Meghan Denny
2025-01-10 22:18:58 -08:00
committed by GitHub
parent 487da0aeac
commit df21b18901
9 changed files with 271 additions and 433 deletions

View File

@@ -1,4 +1,3 @@
/// <reference path="../builtins.d.ts" />
// Copied from Node.js (src/lib/assert.js)
// Originally from narwhal.js (http://narwhaljs.org)
// Copyright (c) 2009 Thomas Robinson <280north.com>
@@ -22,37 +21,30 @@
"use strict";
const {
ArrayFrom,
ArrayPrototypeIndexOf,
ArrayPrototypeJoin,
ArrayPrototypePush,
ArrayPrototypeSlice,
Error,
FunctionPrototypeCall,
NumberIsNaN,
ObjectAssign,
ObjectIs,
ObjectKeys,
ObjectPrototypeIsPrototypeOf,
ReflectHas,
ReflectOwnKeys,
RegExpPrototypeExec,
SafeMap,
SafeSet,
SafeWeakSet,
StringPrototypeIndexOf,
StringPrototypeSlice,
StringPrototypeSplit,
SymbolIterator,
} = require("internal/primordials");
const { SafeMap, SafeSet, SafeWeakSet } = require("internal/primordials");
const { Buffer } = require("node:buffer");
const { isKeyObject, isPromise, isRegExp, isMap, isSet, isDate, isWeakSet, isWeakMap } = require("node:util/types");
const { innerOk } = require("internal/assert/utils");
const { validateFunction } = require("internal/validators");
const ArrayFrom = Array.from;
const ArrayPrototypeIndexOf = Array.prototype.indexOf;
const ArrayPrototypeJoin = Array.prototype.join;
const ArrayPrototypePush = Array.prototype.push;
const ArrayPrototypeSlice = Array.prototype.slice;
const NumberIsNaN = Number.isNaN;
const ObjectAssign = Object.assign;
const ObjectIs = Object.is;
const ObjectKeys = Object.keys;
const ObjectPrototypeIsPrototypeOf = Object.prototype.isPrototypeOf;
const ReflectHas = Reflect.has;
const ReflectOwnKeys = Reflect.ownKeys;
const RegExpPrototypeExec = RegExp.prototype.exec;
const StringPrototypeIndexOf = String.prototype.indexOf;
const StringPrototypeSlice = String.prototype.slice;
const StringPrototypeSplit = String.prototype.split;
const SymbolIterator = Symbol.iterator;
type nodeAssert = typeof import("node:assert");
function isDeepEqual(a, b) {
@@ -375,6 +367,7 @@ function isSpecial(obj) {
}
const typesToCallDeepStrictEqualWith = [isKeyObject, isWeakSet, isWeakMap, Buffer.isBuffer];
const SafeSetPrototypeIterator = SafeSet.prototype[SymbolIterator];
/**
* Compares two objects or values recursively to check if they are equal.
@@ -403,8 +396,8 @@ function compareBranch(actual, expected, comparedObjects) {
return false; // `expected` can't be a subset if it has more elements
}
const actualArray = ArrayFrom(FunctionPrototypeCall(SafeSet.prototype[SymbolIterator], actual));
const expectedIterator = FunctionPrototypeCall(SafeSet.prototype[SymbolIterator], expected);
const actualArray = ArrayFrom(SafeSetPrototypeIterator.$call(actual));
const expectedIterator = SafeSetPrototypeIterator.$call(expected);
const usedIndices = new SafeSet();
expectedIteration: for (const expectedItem of expectedIterator) {
@@ -523,7 +516,7 @@ class Comparison {
actual !== undefined &&
typeof actual[key] === "string" &&
isRegExp(obj[key]) &&
RegExpPrototypeExec(obj[key], actual[key]) !== null
RegExpPrototypeExec.$call(obj[key], actual[key]) !== null
) {
this[key] = actual[key];
} else {
@@ -571,7 +564,7 @@ function expectedException(actual, expected, message, fn) {
// Handle regular expressions.
if (isRegExp(expected)) {
const str = String(actual);
if (RegExpPrototypeExec(expected, str) !== null) return;
if (RegExpPrototypeExec.$call(expected, str) !== null) return;
const inspect = lazyInspect();
if (!message) {
@@ -598,7 +591,7 @@ function expectedException(actual, expected, message, fn) {
// Special handle errors to make sure the name and the message are
// compared as well.
if (expected instanceof Error) {
ArrayPrototypePush(keys, "name", "message");
ArrayPrototypePush.$call(keys, "name", "message");
} else if (keys.length === 0) {
throw $ERR_INVALID_ARG_VALUE("error", expected, "may not be an empty object");
}
@@ -606,7 +599,7 @@ function expectedException(actual, expected, message, fn) {
if (
typeof actual[key] === "string" &&
isRegExp(expected[key]) &&
RegExpPrototypeExec(expected[key], actual[key]) !== null
RegExpPrototypeExec.$call(expected[key], actual[key]) !== null
) {
continue;
}
@@ -618,7 +611,7 @@ function expectedException(actual, expected, message, fn) {
// Check for matching Error classes.
} else if (expected.prototype !== undefined && actual instanceof expected) {
return;
} else if (ObjectPrototypeIsPrototypeOf(Error, expected)) {
} else if (ObjectPrototypeIsPrototypeOf.$call(Error, expected)) {
if (!message) {
generatedMessage = true;
message = "The error is expected to be an instance of " + `"${expected.name}". Received `;
@@ -762,7 +755,7 @@ function hasMatchingError(actual, expected) {
if (typeof expected !== "function") {
if (isRegExp(expected)) {
const str = String(actual);
return RegExpPrototypeExec(expected, str) !== null;
return RegExpPrototypeExec.$call(expected, str) !== null;
}
throw $ERR_INVALID_ARG_TYPE("expected", ["Function", "RegExp"], expected);
}
@@ -770,7 +763,7 @@ function hasMatchingError(actual, expected) {
if (expected.prototype !== undefined && actual instanceof expected) {
return true;
}
if (ObjectPrototypeIsPrototypeOf(Error, expected)) {
if (ObjectPrototypeIsPrototypeOf.$call(Error, expected)) {
return false;
}
return expected.$apply({}, [actual]) === true;
@@ -879,22 +872,25 @@ assert.ifError = function ifError(err: unknown): void {
// This will remove any duplicated frames from the error frames taken
// from within `ifError` and add the original error frames to the newly
// created ones.
const origStackStart = StringPrototypeIndexOf(origStack, "\n at");
const origStackStart = StringPrototypeIndexOf.$call(origStack, "\n at");
if (origStackStart !== -1) {
const originalFrames = StringPrototypeSplit(StringPrototypeSlice(origStack, origStackStart + 1), "\n");
const originalFrames = StringPrototypeSplit.$call(
StringPrototypeSlice.$call(origStack, origStackStart + 1),
"\n",
);
// Filter all frames existing in err.stack.
let newFrames = StringPrototypeSplit(newErr.stack, "\n");
let newFrames = StringPrototypeSplit.$call(newErr.stack, "\n");
for (const errFrame of originalFrames) {
// Find the first occurrence of the frame.
const pos = ArrayPrototypeIndexOf(newFrames, errFrame);
const pos = ArrayPrototypeIndexOf.$call(newFrames, errFrame);
if (pos !== -1) {
// Only keep new frames.
newFrames = ArrayPrototypeSlice(newFrames, 0, pos);
newFrames = ArrayPrototypeSlice.$call(newFrames, 0, pos);
break;
}
}
const stackStart = ArrayPrototypeJoin(newFrames, "\n");
const stackEnd = ArrayPrototypeJoin(originalFrames, "\n");
const stackStart = ArrayPrototypeJoin.$call(newFrames, "\n");
const stackEnd = ArrayPrototypeJoin.$call(originalFrames, "\n");
newErr.stack = `${stackStart}\n${stackEnd}`;
}
}
@@ -908,7 +904,7 @@ function internalMatch(string, regexp, message, fn) {
throw $ERR_INVALID_ARG_TYPE("regexp", "RegExp", regexp);
}
const match = fn === assert.match;
if (typeof string !== "string" || (RegExpPrototypeExec(regexp, string) !== null) !== match) {
if (typeof string !== "string" || (RegExpPrototypeExec.$call(regexp, string) !== null) !== match) {
if (message instanceof Error) {
throw message;
}

View File

@@ -42,17 +42,13 @@ const {
validateAbortSignal,
} = require("internal/validators");
const {
FunctionPrototypeBind,
ObjectSetPrototypeOf,
SymbolAsyncDispose,
SymbolDispose,
StringPrototypeTrim,
NumberIsNaN,
} = require("internal/primordials");
const EventEmitter = require("node:events");
const SymbolDispose = Symbol.dispose;
const SymbolAsyncDispose = Symbol.asyncDispose;
const ObjectSetPrototypeOf = Object.setPrototypeOf;
const FunctionPrototypeBind = Function.prototype.bind;
class ERR_SOCKET_BUFFER_SIZE extends Error {
constructor(ctx) {
super(`Invalid buffer size: ${ctx}`);
@@ -92,9 +88,9 @@ function newHandle(type, lookup) {
const handle = {};
if (type === "udp4") {
handle.lookup = FunctionPrototypeBind(lookup4, handle, lookup);
handle.lookup = FunctionPrototypeBind.$call(lookup4, handle, lookup);
} else if (type === "udp6") {
handle.lookup = FunctionPrototypeBind(lookup6, handle, lookup);
handle.lookup = FunctionPrototypeBind.$call(lookup6, handle, lookup);
} else {
throw $ERR_SOCKET_BAD_TYPE();
}
@@ -328,7 +324,7 @@ Socket.prototype.connect = function (port, address, callback) {
if (state.bindState === BIND_STATE_UNBOUND) this.bind({ port: 0, exclusive: true }, null);
if (state.bindState !== BIND_STATE_BOUND) {
enqueue(this, FunctionPrototypeBind(_connect, this, port, address, callback));
enqueue(this, FunctionPrototypeBind.$call(_connect, this, port, address, callback));
return;
}
@@ -534,7 +530,7 @@ Socket.prototype.send = function (buffer, offset, length, port, address, callbac
// If the socket hasn't been bound yet, push the outbound packet onto the
// send queue and send after binding is complete.
if (state.bindState !== BIND_STATE_BOUND) {
enqueue(this, FunctionPrototypeBind(this.send, this, list, port, address, callback));
enqueue(this, FunctionPrototypeBind.$call(this.send, this, list, port, address, callback));
return;
}
@@ -642,7 +638,7 @@ Socket.prototype.close = function (callback) {
if (typeof callback === "function") this.on("close", callback);
if (queue !== undefined) {
queue.push(FunctionPrototypeBind(this.close, this));
queue.push(FunctionPrototypeBind.$call(this.close, this));
return this;
}

View File

@@ -1,8 +1,6 @@
// Hardcoded module "node:http2"
const { isTypedArray } = require("node:util/types");
// This is a stub! None of this is actually implemented yet.
const { hideFromStack, throwNotImplemented } = require("internal/shared");
const tls = require("node:tls");
@@ -24,22 +22,20 @@ const Socket = net.Socket;
const EventEmitter = require("node:events");
const { Duplex } = require("node:stream");
const {
FunctionPrototypeBind,
StringPrototypeTrim,
ArrayPrototypePush,
ObjectAssign,
ArrayIsArray,
SafeArrayIterator,
StringPrototypeToLowerCase,
StringPrototypeIncludes,
ObjectKeys,
ObjectPrototypeHasOwnProperty,
SafeSet,
DatePrototypeToUTCString,
DatePrototypeGetMilliseconds,
} = require("internal/primordials");
const { SafeArrayIterator, SafeSet } = require("internal/primordials");
const RegExpPrototypeExec = RegExp.prototype.exec;
const ObjectAssign = Object.assign;
const ArrayIsArray = Array.isArray;
const ObjectKeys = Object.keys;
const FunctionPrototypeBind = Function.prototype.bind;
const StringPrototypeTrim = String.prototype.trim;
const ArrayPrototypePush = Array.prototype.push;
const StringPrototypeToLowerCase = String.prototype.toLocaleLowerCase;
const StringPrototypeIncludes = String.prototype.includes;
const ObjectPrototypeHasOwnProperty = Object.prototype.hasOwnProperty;
const DatePrototypeToUTCString = Date.prototype.toUTCString;
const DatePrototypeGetMilliseconds = Date.prototype.getMilliseconds;
const [H2FrameParser, assertSettings, getPackedSettings, getUnpackedSettings] = $zig(
"h2_frame_parser.zig",
@@ -91,8 +87,8 @@ function utcDate() {
function cache() {
const d = new Date();
utcCache = DatePrototypeToUTCString(d);
setTimeout(resetCache, 1000 - DatePrototypeGetMilliseconds(d)).unref();
utcCache = DatePrototypeToUTCString.$call(d);
setTimeout(resetCache, 1000 - DatePrototypeGetMilliseconds.call(d)).unref();
}
function resetCache() {
@@ -116,7 +112,7 @@ function onStreamTrailers(trailers, flags, rawTrailers) {
const request = this[kRequest];
if (request !== undefined) {
ObjectAssign(request[kTrailers], trailers);
ArrayPrototypePush(request[kRawTrailers], ...new SafeArrayIterator(rawTrailers));
ArrayPrototypePush.$call(request[kRawTrailers], ...new SafeArrayIterator(rawTrailers));
}
}
@@ -240,7 +236,7 @@ function connectionHeaderMessageWarn() {
}
function assertValidHeader(name, value) {
if (name === "" || typeof name !== "string" || StringPrototypeIncludes(name, " ")) {
if (name === "" || typeof name !== "string" || StringPrototypeIncludes.$call(name, " ")) {
throw $ERR_INVALID_HTTP_TOKEN(`The arguments Header name is invalid. Received ${name}`);
}
if (isPseudoHeader(name)) {
@@ -349,8 +345,7 @@ class Http2ServerRequest extends Readable {
set method(method) {
validateString(method, "method");
if (StringPrototypeTrim(method) === "") throw $ERR_INVALID_ARG_VALUE("method", method);
if (StringPrototypeTrim.$call(method) === "") throw $ERR_INVALID_ARG_VALUE("method", method);
this[kHeaders][HTTP2_HEADER_METHOD] = method;
}
@@ -473,7 +468,7 @@ class Http2ServerResponse extends Stream {
setTrailer(name, value) {
validateString(name, "name");
name = StringPrototypeToLowerCase(StringPrototypeTrim(name));
name = StringPrototypeToLowerCase.$call(StringPrototypeTrim.$call(name));
assertValidHeader(name, value);
this[kTrailers][name] = value;
}
@@ -489,7 +484,7 @@ class Http2ServerResponse extends Stream {
getHeader(name) {
validateString(name, "name");
name = StringPrototypeToLowerCase(StringPrototypeTrim(name));
name = StringPrototypeToLowerCase.$call(StringPrototypeTrim.$call(name));
return this[kHeaders][name];
}
@@ -504,15 +499,15 @@ class Http2ServerResponse extends Stream {
hasHeader(name) {
validateString(name, "name");
name = StringPrototypeToLowerCase(StringPrototypeTrim(name));
return ObjectPrototypeHasOwnProperty(this[kHeaders], name);
name = StringPrototypeToLowerCase.$call(StringPrototypeTrim.$call(name));
return ObjectPrototypeHasOwnProperty.$call(this[kHeaders], name);
}
removeHeader(name) {
validateString(name, "name");
if (this[kStream].headersSent) throw $ERR_HTTP2_HEADERS_SENT("Response has already been initiated");
name = StringPrototypeToLowerCase(StringPrototypeTrim(name));
name = StringPrototypeToLowerCase.$call(StringPrototypeTrim.$call(name));
if (name === "date") {
this[kState].sendDate = false;
@@ -531,7 +526,7 @@ class Http2ServerResponse extends Stream {
}
[kSetHeader](name, value) {
name = StringPrototypeToLowerCase(StringPrototypeTrim(name));
name = StringPrototypeToLowerCase.$call(StringPrototypeTrim.$call(name));
assertValidHeader(name, value);
if (!isConnectionHeaderAllowed(name, value)) {
@@ -553,7 +548,7 @@ class Http2ServerResponse extends Stream {
}
[kAppendHeader](name, value) {
name = StringPrototypeToLowerCase(StringPrototypeTrim(name));
name = StringPrototypeToLowerCase.$call(StringPrototypeTrim.$call(name));
assertValidHeader(name, value);
if (!isConnectionHeaderAllowed(name, value)) {
@@ -851,7 +846,7 @@ const proxySocketHandler = {
case "setTimeout":
case "ref":
case "unref":
return FunctionPrototypeBind(session[prop], session);
return FunctionPrototypeBind.$call(session[prop], session);
case "destroy":
case "emit":
case "end":
@@ -871,7 +866,7 @@ const proxySocketHandler = {
throw $ERR_HTTP2_SOCKET_UNBOUND("The socket has been disconnected from the Http2Session");
}
const value = socket[prop];
return typeof value === "function" ? FunctionPrototypeBind(value, socket) : value;
return typeof value === "function" ? FunctionPrototypeBind.$call(value, socket) : value;
}
}
},
@@ -2072,7 +2067,7 @@ class ServerHttp2Stream extends Http2Stream {
if (!this[kInfoHeaders]) {
this[kInfoHeaders] = [headers];
} else {
ArrayPrototypePush(this[kInfoHeaders], headers);
ArrayPrototypePush.$call(this[kInfoHeaders], headers);
}
session[bunHTTP2Native]?.request(this.id, undefined, headers, sensitiveNames);
@@ -2190,7 +2185,7 @@ function toHeaderObject(headers, sensitiveHeadersValue) {
// fields with the same name. Since it cannot be combined into a
// single field-value, recipients ought to handle "Set-Cookie" as a
// special case while processing header fields."
ArrayPrototypePush(existing, value);
ArrayPrototypePush.$call(existing, value);
break;
default:
// https://tools.ietf.org/html/rfc7230#section-3.2.2
@@ -3170,7 +3165,7 @@ function setupCompat(ev) {
const options = this[bunSocketServerOptions];
const ServerRequest = options?.Http2ServerRequest || Http2ServerRequest;
const ServerResponse = options?.Http2ServerResponse || Http2ServerResponse;
this.on("stream", FunctionPrototypeBind(onServerStream, this, ServerRequest, ServerResponse));
this.on("stream", FunctionPrototypeBind.$call(onServerStream, this, ServerRequest, ServerResponse));
}
}

View File

@@ -19,28 +19,22 @@
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
// USE OR OTHER DEALINGS IN THE SOFTWARE.
const { Buffer } = require("node:buffer");
const ArrayIsArray = Array.isArray;
const MathAbs = Math.abs;
const NumberIsFinite = Number.isFinite;
const ObjectKeys = Object.keys;
const StringPrototypeCharCodeAt = String.prototype.charCodeAt;
const StringPrototypeSlice = String.prototype.slice;
const StringPrototypeToUpperCase = String.prototype.toUpperCase;
const NumberPrototypeToString = Number.prototype.toString;
var __commonJS =
(cb, mod: typeof module | undefined = undefined) =>
() => (mod || cb((mod = { exports: {} }).exports, mod), mod.exports);
var require_src = __commonJS((exports, module) => {
const {
Array,
ArrayIsArray,
Int8Array,
MathAbs,
NumberIsFinite,
ObjectKeys,
String,
StringPrototypeCharCodeAt,
StringPrototypeSlice,
decodeURIComponent,
StringPrototypeToUpperCase,
NumberPrototypeToString,
} = require("internal/primordials");
const { Buffer } = require("node:buffer");
/**
* @param {string} str
* @param {Int8Array} noEscapeTable
@@ -56,22 +50,22 @@ var require_src = __commonJS((exports, module) => {
let i = 0;
outer: for (; i < len; i++) {
let c = StringPrototypeCharCodeAt(str, i);
let c = StringPrototypeCharCodeAt.$call(str, i);
// ASCII
while (c < 0x80) {
if (noEscapeTable[c] !== 1) {
if (lastPos < i) out += StringPrototypeSlice(str, lastPos, i);
if (lastPos < i) out += StringPrototypeSlice.$call(str, lastPos, i);
lastPos = i + 1;
out += hexTable[c];
}
if (++i === len) break outer;
c = StringPrototypeCharCodeAt(str, i);
c = StringPrototypeCharCodeAt.$call(str, i);
}
if (lastPos < i) out += StringPrototypeSlice(str, lastPos, i);
if (lastPos < i) out += StringPrototypeSlice.$call(str, lastPos, i);
// Multi-byte characters ...
if (c < 0x800) {
@@ -92,7 +86,7 @@ var require_src = __commonJS((exports, module) => {
// completion's sake anyway.
if (i >= len) throw $ERR_INVALID_URI("URI malformed");
const c2 = StringPrototypeCharCodeAt(str, i) & 0x3ff;
const c2 = StringPrototypeCharCodeAt.$call(str, i) & 0x3ff;
lastPos = i + 1;
c = 0x10000 + (((c & 0x3ff) << 10) | c2);
@@ -103,13 +97,13 @@ var require_src = __commonJS((exports, module) => {
hexTable[0x80 | (c & 0x3f)];
}
if (lastPos === 0) return str;
if (lastPos < len) return out + StringPrototypeSlice(str, lastPos);
if (lastPos < len) return out + StringPrototypeSlice.$call(str, lastPos);
return out;
}
const hexTable = new Array(256);
for (let i = 0; i < 256; ++i)
hexTable[i] = "%" + StringPrototypeToUpperCase((i < 16 ? "0" : "") + NumberPrototypeToString(i, 16));
hexTable[i] = "%" + StringPrototypeToUpperCase.$call((i < 16 ? "0" : "") + NumberPrototypeToString.$call(i, 16));
// prettier-ignore
const isHexTable = new Int8Array([
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 0 - 15
@@ -181,20 +175,20 @@ var require_src = __commonJS((exports, module) => {
// Flag to know if some hex chars have been decoded
let hasHex = false;
while (index < s.length) {
currentChar = StringPrototypeCharCodeAt(s, index);
currentChar = StringPrototypeCharCodeAt.$call(s, index);
if (currentChar === 43 /* '+' */ && decodeSpaces) {
out[outIndex++] = 32; // ' '
index++;
continue;
}
if (currentChar === 37 /* '%' */ && index < maxLength) {
currentChar = StringPrototypeCharCodeAt(s, ++index);
currentChar = StringPrototypeCharCodeAt.$call(s, ++index);
hexHigh = unhexTable[currentChar];
if (!(hexHigh >= 0)) {
out[outIndex++] = 37; // '%'
continue;
} else {
nextChar = StringPrototypeCharCodeAt(s, ++index);
nextChar = StringPrototypeCharCodeAt.$call(s, ++index);
hexLow = unhexTable[nextChar];
if (!(hexLow >= 0)) {
out[outIndex++] = 37; // '%'
@@ -349,9 +343,9 @@ var require_src = __commonJS((exports, module) => {
*/
function charCodes(str) {
if (str.length === 0) return [];
if (str.length === 1) return [StringPrototypeCharCodeAt(str, 0)];
if (str.length === 1) return [StringPrototypeCharCodeAt.$call(str, 0)];
const ret = new Array(str.length);
for (let i = 0; i < str.length; ++i) ret[i] = StringPrototypeCharCodeAt(str, i);
for (let i = 0; i < str.length; ++i) ret[i] = StringPrototypeCharCodeAt.$call(str, i);
return ret;
}
const defSepCodes = [38]; // &
@@ -423,7 +417,7 @@ var require_src = __commonJS((exports, module) => {
const plusChar = customDecode ? "%20" : " ";
let encodeCheck = 0;
for (let i = 0; i < qs.length; ++i) {
const code = StringPrototypeCharCodeAt(qs, i);
const code = StringPrototypeCharCodeAt.$call(qs, i);
// Try matching key/value pair separator (e.g. '&')
if (code === sepCodes[sepIdx]) {
@@ -434,7 +428,7 @@ var require_src = __commonJS((exports, module) => {
// We didn't find the (entire) key/value separator
if (lastPos < end) {
// Treat the substring as part of the key instead of the value
key += StringPrototypeSlice(qs, lastPos, end);
key += StringPrototypeSlice.$call(qs, lastPos, end);
} else if (key.length === 0) {
// We saw an empty substring between separators
if (--pairs === 0) return obj;
@@ -443,7 +437,7 @@ var require_src = __commonJS((exports, module) => {
continue;
}
} else if (lastPos < end) {
value += StringPrototypeSlice(qs, lastPos, end);
value += StringPrototypeSlice.$call(qs, lastPos, end);
}
addKeyVal(obj, key, value, keyEncoded, valEncoded, decode);
@@ -463,7 +457,7 @@ var require_src = __commonJS((exports, module) => {
if (++eqIdx === eqLen) {
// Key/value separator match!
const end = i - eqIdx + 1;
if (lastPos < end) key += StringPrototypeSlice(qs, lastPos, end);
if (lastPos < end) key += StringPrototypeSlice.$call(qs, lastPos, end);
encodeCheck = 0;
lastPos = i + 1;
}
@@ -487,14 +481,14 @@ var require_src = __commonJS((exports, module) => {
}
}
if (code === 43 /* + */) {
if (lastPos < i) key += StringPrototypeSlice(qs, lastPos, i);
if (lastPos < i) key += StringPrototypeSlice.$call(qs, lastPos, i);
key += plusChar;
lastPos = i + 1;
continue;
}
}
if (code === 43 /* + */) {
if (lastPos < i) value += StringPrototypeSlice(qs, lastPos, i);
if (lastPos < i) value += StringPrototypeSlice.$call(qs, lastPos, i);
value += plusChar;
lastPos = i + 1;
} else if (!valEncoded) {
@@ -515,8 +509,8 @@ var require_src = __commonJS((exports, module) => {
// Deal with any leftover key or value data
if (lastPos < qs.length) {
if (eqIdx < eqLen) key += StringPrototypeSlice(qs, lastPos);
else if (sepIdx < sepLen) value += StringPrototypeSlice(qs, lastPos);
if (eqIdx < eqLen) key += StringPrototypeSlice.$call(qs, lastPos);
else if (sepIdx < sepLen) value += StringPrototypeSlice.$call(qs, lastPos);
} else if (eqIdx === 0 && key.length === 0) {
// We ended on an empty substring
return obj;