mirror of
https://github.com/denoland/deno.git
synced 2024-12-27 01:29:14 -05:00
fix(core): Use primordials for methods (#18839)
I would like to get this change into Deno before merging https://github.com/denoland/deno_lint/pull/1152
This commit is contained in:
parent
0ddad2486c
commit
3d0b879c0d
17 changed files with 378 additions and 270 deletions
|
@ -28,13 +28,13 @@
|
||||||
SafeArrayIterator,
|
SafeArrayIterator,
|
||||||
SafeMap,
|
SafeMap,
|
||||||
SafePromisePrototypeFinally,
|
SafePromisePrototypeFinally,
|
||||||
setQueueMicrotask,
|
|
||||||
StringPrototypeSlice,
|
StringPrototypeSlice,
|
||||||
StringPrototypeSplit,
|
StringPrototypeSplit,
|
||||||
SymbolFor,
|
SymbolFor,
|
||||||
SyntaxError,
|
SyntaxError,
|
||||||
TypeError,
|
TypeError,
|
||||||
URIError,
|
URIError,
|
||||||
|
setQueueMicrotask,
|
||||||
} = window.__bootstrap.primordials;
|
} = window.__bootstrap.primordials;
|
||||||
const { ops, asyncOps } = window.Deno.core;
|
const { ops, asyncOps } = window.Deno.core;
|
||||||
|
|
||||||
|
|
11
ext/cache/01_cache.js
vendored
11
ext/cache/01_cache.js
vendored
|
@ -4,9 +4,12 @@ const core = globalThis.Deno.core;
|
||||||
import * as webidl from "ext:deno_webidl/00_webidl.js";
|
import * as webidl from "ext:deno_webidl/00_webidl.js";
|
||||||
const primordials = globalThis.__bootstrap.primordials;
|
const primordials = globalThis.__bootstrap.primordials;
|
||||||
const {
|
const {
|
||||||
|
ArrayPrototypePush,
|
||||||
|
ObjectPrototypeIsPrototypeOf,
|
||||||
|
StringPrototypeSplit,
|
||||||
|
StringPrototypeTrim,
|
||||||
Symbol,
|
Symbol,
|
||||||
TypeError,
|
TypeError,
|
||||||
ObjectPrototypeIsPrototypeOf,
|
|
||||||
} = primordials;
|
} = primordials;
|
||||||
import {
|
import {
|
||||||
Request,
|
Request,
|
||||||
|
@ -101,10 +104,10 @@ class Cache {
|
||||||
// Step 7.
|
// Step 7.
|
||||||
const varyHeader = getHeader(innerResponse.headerList, "vary");
|
const varyHeader = getHeader(innerResponse.headerList, "vary");
|
||||||
if (varyHeader) {
|
if (varyHeader) {
|
||||||
const fieldValues = varyHeader.split(",");
|
const fieldValues = StringPrototypeSplit(varyHeader, ",");
|
||||||
for (let i = 0; i < fieldValues.length; ++i) {
|
for (let i = 0; i < fieldValues.length; ++i) {
|
||||||
const field = fieldValues[i];
|
const field = fieldValues[i];
|
||||||
if (field.trim() === "*") {
|
if (StringPrototypeTrim(field) === "*") {
|
||||||
throw new TypeError("Vary header must not contain '*'");
|
throw new TypeError("Vary header must not contain '*'");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -258,7 +261,7 @@ class Cache {
|
||||||
statusText: meta.responseStatusText,
|
statusText: meta.responseStatusText,
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
responses.push(response);
|
ArrayPrototypePush(responses, response);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Step 5.4-5.5: don't apply in this context.
|
// Step 5.4-5.5: don't apply in this context.
|
||||||
|
|
|
@ -6,118 +6,134 @@ const core = globalThis.Deno.core;
|
||||||
const internals = globalThis.__bootstrap.internals;
|
const internals = globalThis.__bootstrap.internals;
|
||||||
const primordials = globalThis.__bootstrap.primordials;
|
const primordials = globalThis.__bootstrap.primordials;
|
||||||
const {
|
const {
|
||||||
DateNow,
|
|
||||||
Boolean,
|
|
||||||
ObjectKeys,
|
|
||||||
ObjectAssign,
|
|
||||||
ObjectCreate,
|
|
||||||
ObjectFreeze,
|
|
||||||
ObjectValues,
|
|
||||||
ObjectFromEntries,
|
|
||||||
ObjectPrototypeHasOwnProperty,
|
|
||||||
ObjectPrototypeIsPrototypeOf,
|
|
||||||
ObjectDefineProperty,
|
|
||||||
String,
|
|
||||||
SafeStringIterator,
|
|
||||||
DatePrototype,
|
|
||||||
MapPrototypeEntries,
|
|
||||||
SetPrototypeGetSize,
|
|
||||||
StringPrototypeRepeat,
|
|
||||||
StringPrototypeEndsWith,
|
|
||||||
StringPrototypeIndexOf,
|
|
||||||
RegExpPrototypeExec,
|
|
||||||
RegExpPrototypeSymbolReplace,
|
|
||||||
StringPrototypeReplace,
|
|
||||||
StringPrototypeReplaceAll,
|
|
||||||
ObjectPrototype,
|
|
||||||
FunctionPrototypeCall,
|
|
||||||
StringPrototypeSplit,
|
|
||||||
StringPrototypeSlice,
|
|
||||||
StringPrototypeCharCodeAt,
|
|
||||||
MathFloor,
|
|
||||||
StringPrototypePadEnd,
|
|
||||||
ObjectGetOwnPropertySymbols,
|
|
||||||
ObjectGetOwnPropertyNames,
|
|
||||||
SymbolPrototypeGetDescription,
|
|
||||||
SymbolPrototypeToString,
|
|
||||||
ArrayPrototypePushApply,
|
|
||||||
ObjectPrototypePropertyIsEnumerable,
|
|
||||||
StringPrototypeMatch,
|
|
||||||
StringPrototypePadStart,
|
|
||||||
StringPrototypeTrim,
|
|
||||||
StringPrototypeIncludes,
|
|
||||||
NumberIsInteger,
|
|
||||||
NumberParseInt,
|
|
||||||
SafeArrayIterator,
|
|
||||||
SafeMap,
|
|
||||||
ArrayPrototypeShift,
|
|
||||||
AggregateErrorPrototype,
|
AggregateErrorPrototype,
|
||||||
RegExpPrototypeTest,
|
|
||||||
ObjectPrototypeToString,
|
|
||||||
ArrayPrototypeSort,
|
|
||||||
ArrayPrototypeUnshift,
|
|
||||||
DatePrototypeGetTime,
|
|
||||||
DatePrototypeToISOString,
|
|
||||||
SafeRegExp,
|
|
||||||
SetPrototype,
|
|
||||||
Symbol,
|
|
||||||
SymbolToStringTag,
|
|
||||||
SymbolHasInstance,
|
|
||||||
SymbolFor,
|
|
||||||
ObjectGetOwnPropertyDescriptor,
|
|
||||||
ObjectIs,
|
|
||||||
Uint8Array,
|
|
||||||
isNaN,
|
|
||||||
TypedArrayPrototypeGetSymbolToStringTag,
|
|
||||||
TypedArrayPrototypeGetLength,
|
|
||||||
ReflectOwnKeys,
|
|
||||||
Array,
|
Array,
|
||||||
RegExpPrototypeToString,
|
|
||||||
ArrayIsArray,
|
|
||||||
SymbolIterator,
|
|
||||||
ArrayBufferIsView,
|
ArrayBufferIsView,
|
||||||
ArrayPrototypeJoin,
|
ArrayBufferPrototypeGetByteLength,
|
||||||
ArrayPrototypeMap,
|
ArrayIsArray,
|
||||||
ArrayPrototypeReduce,
|
|
||||||
ObjectSetPrototypeOf,
|
|
||||||
ArrayPrototypePush,
|
|
||||||
ArrayPrototypeIncludes,
|
|
||||||
ArrayPrototypeFill,
|
ArrayPrototypeFill,
|
||||||
ArrayPrototypeFilter,
|
ArrayPrototypeFilter,
|
||||||
ArrayPrototypeFind,
|
ArrayPrototypeFind,
|
||||||
FunctionPrototypeBind,
|
ArrayPrototypeForEach,
|
||||||
MapPrototype,
|
ArrayPrototypeIncludes,
|
||||||
MapPrototypeHas,
|
ArrayPrototypeJoin,
|
||||||
MapPrototypeGet,
|
ArrayPrototypeMap,
|
||||||
MapPrototypeSet,
|
ArrayPrototypePop,
|
||||||
MapPrototypeDelete,
|
ArrayPrototypePush,
|
||||||
MapPrototypeForEach,
|
ArrayPrototypePushApply,
|
||||||
MapPrototypeGetSize,
|
ArrayPrototypeReduce,
|
||||||
|
ArrayPrototypeShift,
|
||||||
|
ArrayPrototypeSlice,
|
||||||
|
ArrayPrototypeSort,
|
||||||
|
ArrayPrototypeSplice,
|
||||||
|
ArrayPrototypeUnshift,
|
||||||
|
BigIntPrototypeValueOf,
|
||||||
|
Boolean,
|
||||||
|
BooleanPrototypeValueOf,
|
||||||
|
DateNow,
|
||||||
|
DatePrototype,
|
||||||
|
DatePrototypeGetTime,
|
||||||
|
DatePrototypeToISOString,
|
||||||
Error,
|
Error,
|
||||||
ErrorPrototype,
|
|
||||||
ErrorCaptureStackTrace,
|
ErrorCaptureStackTrace,
|
||||||
MathSqrt,
|
ErrorPrototype,
|
||||||
|
FunctionPrototypeBind,
|
||||||
|
FunctionPrototypeCall,
|
||||||
|
FunctionPrototypeToString,
|
||||||
|
MapPrototype,
|
||||||
|
MapPrototypeDelete,
|
||||||
|
MapPrototypeEntries,
|
||||||
|
MapPrototypeForEach,
|
||||||
|
MapPrototypeGet,
|
||||||
|
MapPrototypeGetSize,
|
||||||
|
MapPrototypeHas,
|
||||||
|
MapPrototypeSet,
|
||||||
MathAbs,
|
MathAbs,
|
||||||
|
MathFloor,
|
||||||
MathMax,
|
MathMax,
|
||||||
MathMin,
|
MathMin,
|
||||||
MathRound,
|
MathRound,
|
||||||
|
MathSqrt,
|
||||||
Number,
|
Number,
|
||||||
|
NumberIsInteger,
|
||||||
|
NumberParseInt,
|
||||||
NumberPrototypeToString,
|
NumberPrototypeToString,
|
||||||
|
NumberPrototypeValueOf,
|
||||||
|
ObjectAssign,
|
||||||
|
ObjectCreate,
|
||||||
|
ObjectDefineProperty,
|
||||||
|
ObjectFreeze,
|
||||||
|
ObjectFromEntries,
|
||||||
|
ObjectGetOwnPropertyDescriptor,
|
||||||
|
ObjectGetOwnPropertyNames,
|
||||||
|
ObjectGetOwnPropertySymbols,
|
||||||
|
ObjectGetPrototypeOf,
|
||||||
|
ObjectIs,
|
||||||
|
ObjectKeys,
|
||||||
|
ObjectPrototype,
|
||||||
|
ObjectPrototypeHasOwnProperty,
|
||||||
|
ObjectPrototypeIsPrototypeOf,
|
||||||
|
ObjectPrototypePropertyIsEnumerable,
|
||||||
|
ObjectPrototypeToString,
|
||||||
|
ObjectSetPrototypeOf,
|
||||||
|
ObjectValues,
|
||||||
Proxy,
|
Proxy,
|
||||||
ReflectGet,
|
ReflectGet,
|
||||||
ReflectGetOwnPropertyDescriptor,
|
ReflectGetOwnPropertyDescriptor,
|
||||||
ReflectGetPrototypeOf,
|
ReflectGetPrototypeOf,
|
||||||
ReflectHas,
|
ReflectHas,
|
||||||
BigIntPrototypeValueOf,
|
ReflectOwnKeys,
|
||||||
ObjectGetPrototypeOf,
|
RegExpPrototypeExec,
|
||||||
FunctionPrototypeToString,
|
RegExpPrototypeSymbolReplace,
|
||||||
StringPrototypeStartsWith,
|
RegExpPrototypeTest,
|
||||||
SetPrototypeValues,
|
RegExpPrototypeToString,
|
||||||
|
SafeArrayIterator,
|
||||||
|
SafeMap,
|
||||||
|
SafeMapIterator,
|
||||||
|
SafeRegExp,
|
||||||
SafeSet,
|
SafeSet,
|
||||||
SafeSetIterator,
|
SafeSetIterator,
|
||||||
|
SafeStringIterator,
|
||||||
|
SetPrototype,
|
||||||
|
SetPrototypeAdd,
|
||||||
|
SetPrototypeHas,
|
||||||
|
SetPrototypeGetSize,
|
||||||
|
SetPrototypeValues,
|
||||||
|
String,
|
||||||
|
StringPrototypeCharCodeAt,
|
||||||
|
StringPrototypeCodePointAt,
|
||||||
|
StringPrototypeEndsWith,
|
||||||
|
StringPrototypeIncludes,
|
||||||
|
StringPrototypeIndexOf,
|
||||||
|
StringPrototypeLastIndexOf,
|
||||||
|
StringPrototypeMatch,
|
||||||
|
StringPrototypeNormalize,
|
||||||
|
StringPrototypePadEnd,
|
||||||
|
StringPrototypePadStart,
|
||||||
|
StringPrototypeRepeat,
|
||||||
|
StringPrototypeReplace,
|
||||||
|
StringPrototypeReplaceAll,
|
||||||
|
StringPrototypeSlice,
|
||||||
|
StringPrototypeSplit,
|
||||||
|
StringPrototypeStartsWith,
|
||||||
|
StringPrototypeToLowerCase,
|
||||||
|
StringPrototypeTrim,
|
||||||
|
StringPrototypeValueOf,
|
||||||
|
Symbol,
|
||||||
|
SymbolFor,
|
||||||
|
SymbolHasInstance,
|
||||||
|
SymbolIterator,
|
||||||
|
SymbolPrototypeGetDescription,
|
||||||
|
SymbolPrototypeToString,
|
||||||
|
SymbolPrototypeValueOf,
|
||||||
|
SymbolToStringTag,
|
||||||
TypedArrayPrototypeGetByteLength,
|
TypedArrayPrototypeGetByteLength,
|
||||||
SafeMapIterator,
|
TypedArrayPrototypeGetLength,
|
||||||
ArrayBufferPrototype,
|
TypedArrayPrototypeGetSymbolToStringTag,
|
||||||
|
Uint8Array,
|
||||||
|
WeakMapPrototypeHas,
|
||||||
|
WeakSetPrototypeHas,
|
||||||
|
isNaN,
|
||||||
} = primordials;
|
} = primordials;
|
||||||
|
|
||||||
let noColor = false;
|
let noColor = false;
|
||||||
|
@ -227,45 +243,9 @@ defineColorAlias("inverse", "swapColors");
|
||||||
defineColorAlias("inverse", "swapcolors");
|
defineColorAlias("inverse", "swapcolors");
|
||||||
defineColorAlias("doubleunderline", "doubleUnderline");
|
defineColorAlias("doubleunderline", "doubleUnderline");
|
||||||
|
|
||||||
// https://tc39.es/ecma262/#sec-boolean.prototype.valueof
|
|
||||||
const _booleanValueOf = Boolean.prototype.valueOf;
|
|
||||||
|
|
||||||
// https://tc39.es/ecma262/#sec-number.prototype.valueof
|
|
||||||
const _numberValueOf = Number.prototype.valueOf;
|
|
||||||
|
|
||||||
// https://tc39.es/ecma262/#sec-string.prototype.valueof
|
|
||||||
const _stringValueOf = String.prototype.valueOf;
|
|
||||||
|
|
||||||
// https://tc39.es/ecma262/#sec-symbol.prototype.valueof
|
|
||||||
const _symbolValueOf = Symbol.prototype.valueOf;
|
|
||||||
|
|
||||||
// https://tc39.es/ecma262/#sec-weakmap.prototype.has
|
|
||||||
const _weakMapHas = WeakMap.prototype.has;
|
|
||||||
|
|
||||||
// https://tc39.es/ecma262/#sec-weakset.prototype.has
|
|
||||||
const _weakSetHas = WeakSet.prototype.has;
|
|
||||||
|
|
||||||
// https://tc39.es/ecma262/#sec-get-arraybuffer.prototype.bytelength
|
|
||||||
const _getArrayBufferByteLength = ObjectGetOwnPropertyDescriptor(
|
|
||||||
ArrayBufferPrototype,
|
|
||||||
"byteLength",
|
|
||||||
).get;
|
|
||||||
|
|
||||||
// https://tc39.es/ecma262/#sec-get-sharedarraybuffer.prototype.bytelength
|
// https://tc39.es/ecma262/#sec-get-sharedarraybuffer.prototype.bytelength
|
||||||
let _getSharedArrayBufferByteLength;
|
let _getSharedArrayBufferByteLength;
|
||||||
|
|
||||||
// https://tc39.es/ecma262/#sec-get-set.prototype.size
|
|
||||||
const _getSetSize = ObjectGetOwnPropertyDescriptor(
|
|
||||||
SetPrototype,
|
|
||||||
"size",
|
|
||||||
).get;
|
|
||||||
|
|
||||||
// https://tc39.es/ecma262/#sec-get-map.prototype.size
|
|
||||||
const _getMapSize = ObjectGetOwnPropertyDescriptor(
|
|
||||||
MapPrototype,
|
|
||||||
"size",
|
|
||||||
).get;
|
|
||||||
|
|
||||||
function isObjectLike(value) {
|
function isObjectLike(value) {
|
||||||
return value !== null && typeof value === "object";
|
return value !== null && typeof value === "object";
|
||||||
}
|
}
|
||||||
|
@ -284,7 +264,7 @@ export function isArgumentsObject(value) {
|
||||||
|
|
||||||
export function isArrayBuffer(value) {
|
export function isArrayBuffer(value) {
|
||||||
try {
|
try {
|
||||||
_getArrayBufferByteLength.call(value);
|
ArrayBufferPrototypeGetByteLength(value);
|
||||||
return true;
|
return true;
|
||||||
} catch {
|
} catch {
|
||||||
return false;
|
return false;
|
||||||
|
@ -311,7 +291,7 @@ export function isBooleanObject(value) {
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
_booleanValueOf.call(value);
|
BooleanPrototypeValueOf(value);
|
||||||
return true;
|
return true;
|
||||||
} catch {
|
} catch {
|
||||||
return false;
|
return false;
|
||||||
|
@ -352,7 +332,7 @@ export function isGeneratorFunction(
|
||||||
|
|
||||||
export function isMap(value) {
|
export function isMap(value) {
|
||||||
try {
|
try {
|
||||||
_getMapSize.call(value);
|
MapPrototypeGetSize(value);
|
||||||
return true;
|
return true;
|
||||||
} catch {
|
} catch {
|
||||||
return false;
|
return false;
|
||||||
|
@ -391,7 +371,7 @@ export function isNumberObject(value) {
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
_numberValueOf.call(value);
|
NumberPrototypeValueOf(value);
|
||||||
return true;
|
return true;
|
||||||
} catch {
|
} catch {
|
||||||
return false;
|
return false;
|
||||||
|
@ -427,7 +407,7 @@ export function isRegExp(value) {
|
||||||
|
|
||||||
export function isSet(value) {
|
export function isSet(value) {
|
||||||
try {
|
try {
|
||||||
_getSetSize.call(value);
|
SetPrototypeGetSize(value);
|
||||||
return true;
|
return true;
|
||||||
} catch {
|
} catch {
|
||||||
return false;
|
return false;
|
||||||
|
@ -454,7 +434,7 @@ export function isSharedArrayBuffer(
|
||||||
).get;
|
).get;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
_getSharedArrayBufferByteLength.call(value);
|
FunctionPrototypeCall(_getSharedArrayBufferByteLength, value);
|
||||||
return true;
|
return true;
|
||||||
} catch {
|
} catch {
|
||||||
return false;
|
return false;
|
||||||
|
@ -467,7 +447,7 @@ export function isStringObject(value) {
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
_stringValueOf.call(value);
|
StringPrototypeValueOf(value);
|
||||||
return true;
|
return true;
|
||||||
} catch {
|
} catch {
|
||||||
return false;
|
return false;
|
||||||
|
@ -480,7 +460,7 @@ export function isSymbolObject(value) {
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
_symbolValueOf.call(value);
|
SymbolPrototypeValueOf(value);
|
||||||
return true;
|
return true;
|
||||||
} catch {
|
} catch {
|
||||||
return false;
|
return false;
|
||||||
|
@ -491,7 +471,7 @@ export function isWeakMap(
|
||||||
value,
|
value,
|
||||||
) {
|
) {
|
||||||
try {
|
try {
|
||||||
_weakMapHas.call(value, null);
|
WeakMapPrototypeHas(value, null);
|
||||||
return true;
|
return true;
|
||||||
} catch {
|
} catch {
|
||||||
return false;
|
return false;
|
||||||
|
@ -502,7 +482,7 @@ export function isWeakSet(
|
||||||
value,
|
value,
|
||||||
) {
|
) {
|
||||||
try {
|
try {
|
||||||
_weakSetHas.call(value, null);
|
WeakSetPrototypeHas(value, null);
|
||||||
return true;
|
return true;
|
||||||
} catch {
|
} catch {
|
||||||
return false;
|
return false;
|
||||||
|
@ -552,7 +532,7 @@ const keyStrRegExp = new SafeRegExp("^[a-zA-Z_][a-zA-Z_0-9]*$");
|
||||||
const numberRegExp = new SafeRegExp("^(0|[1-9][0-9]*)$");
|
const numberRegExp = new SafeRegExp("^(0|[1-9][0-9]*)$");
|
||||||
|
|
||||||
// TODO(wafuwafu13): Figure out
|
// TODO(wafuwafu13): Figure out
|
||||||
const escapeFn = (str) => meta[str.charCodeAt(0)];
|
const escapeFn = (str) => meta[StringPrototypeCharCodeAt(str, 0)];
|
||||||
|
|
||||||
function stylizeNoColor(str) {
|
function stylizeNoColor(str) {
|
||||||
return str;
|
return str;
|
||||||
|
@ -711,16 +691,16 @@ function formatValue(
|
||||||
|
|
||||||
// Using an array here is actually better for the average case than using
|
// Using an array here is actually better for the average case than using
|
||||||
// a Set. `seen` will only check for the depth and will never grow too large.
|
// a Set. `seen` will only check for the depth and will never grow too large.
|
||||||
if (ctx.seen.includes(value)) {
|
if (ArrayPrototypeIncludes(ctx.seen, value)) {
|
||||||
let index = 1;
|
let index = 1;
|
||||||
if (ctx.circular === undefined) {
|
if (ctx.circular === undefined) {
|
||||||
ctx.circular = new SafeMap();
|
ctx.circular = new SafeMap();
|
||||||
ctx.circular.set(value, index);
|
MapPrototypeSet(ctx.circular, value, index);
|
||||||
} else {
|
} else {
|
||||||
index = ctx.circular.get(value);
|
index = ctx.circular.get(value);
|
||||||
if (index === undefined) {
|
if (index === undefined) {
|
||||||
index = ctx.circular.size + 1;
|
index = ctx.circular.size + 1;
|
||||||
ctx.circular.set(value, index);
|
MapPrototypeSet(ctx.circular, value, index);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return ctx.stylize(`[Circular *${index}]`, "special");
|
return ctx.stylize(`[Circular *${index}]`, "special");
|
||||||
|
@ -1006,7 +986,7 @@ function formatRaw(ctx, value, recurseTimes, typedArray, proxyDetails) {
|
||||||
} else if (isModuleNamespaceObject(value)) {
|
} else if (isModuleNamespaceObject(value)) {
|
||||||
braces[0] = `${getPrefix(constructor, tag, "Module")}{`;
|
braces[0] = `${getPrefix(constructor, tag, "Module")}{`;
|
||||||
// Special handle keys for namespace objects.
|
// Special handle keys for namespace objects.
|
||||||
formatter = formatNamespaceObject.bind(null, keys);
|
formatter = FunctionPrototypeBind(formatNamespaceObject, null, keys);
|
||||||
} else if (isBoxedPrimitive(value)) {
|
} else if (isBoxedPrimitive(value)) {
|
||||||
base = getBoxedBase(value, ctx, keys, constructor, tag);
|
base = getBoxedBase(value, ctx, keys, constructor, tag);
|
||||||
if (keys.length === 0 && protoProps === undefined) {
|
if (keys.length === 0 && protoProps === undefined) {
|
||||||
|
@ -1039,7 +1019,7 @@ function formatRaw(ctx, value, recurseTimes, typedArray, proxyDetails) {
|
||||||
}
|
}
|
||||||
recurseTimes += 1;
|
recurseTimes += 1;
|
||||||
|
|
||||||
ctx.seen.push(value);
|
ArrayPrototypePush(ctx.seen, value);
|
||||||
ctx.currentDepth = recurseTimes;
|
ctx.currentDepth = recurseTimes;
|
||||||
let output;
|
let output;
|
||||||
const indentationLvl = ctx.indentationLvl;
|
const indentationLvl = ctx.indentationLvl;
|
||||||
|
@ -1075,15 +1055,19 @@ function formatRaw(ctx, value, recurseTimes, typedArray, proxyDetails) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ctx.seen.pop();
|
ArrayPrototypePop(ctx.seen);
|
||||||
|
|
||||||
if (ctx.sorted) {
|
if (ctx.sorted) {
|
||||||
const comparator = ctx.sorted === true ? undefined : ctx.sorted;
|
const comparator = ctx.sorted === true ? undefined : ctx.sorted;
|
||||||
if (extrasType === kObjectType) {
|
if (extrasType === kObjectType) {
|
||||||
output = ArrayPrototypeSort(output, comparator);
|
output = ArrayPrototypeSort(output, comparator);
|
||||||
} else if (keys.length > 1) {
|
} else if (keys.length > 1) {
|
||||||
const sorted = output.slice(output.length - keys.length).sort(comparator);
|
const sorted = ArrayPrototypeSort(
|
||||||
output.splice(
|
ArrayPrototypeSlice(output, output.length - keys.length),
|
||||||
|
comparator,
|
||||||
|
);
|
||||||
|
ArrayPrototypeSplice(
|
||||||
|
output,
|
||||||
output.length - keys.length,
|
output.length - keys.length,
|
||||||
keys.length,
|
keys.length,
|
||||||
...new SafeArrayIterator(sorted),
|
...new SafeArrayIterator(sorted),
|
||||||
|
@ -1118,8 +1102,9 @@ function formatRaw(ctx, value, recurseTimes, typedArray, proxyDetails) {
|
||||||
|
|
||||||
const builtInObjectsRegExp = new SafeRegExp("^[A-Z][a-zA-Z0-9]+$");
|
const builtInObjectsRegExp = new SafeRegExp("^[A-Z][a-zA-Z0-9]+$");
|
||||||
const builtInObjects = new SafeSet(
|
const builtInObjects = new SafeSet(
|
||||||
ObjectGetOwnPropertyNames(globalThis).filter((e) =>
|
ArrayPrototypeFilter(
|
||||||
builtInObjectsRegExp.test(e)
|
ObjectGetOwnPropertyNames(globalThis),
|
||||||
|
(e) => RegExpPrototypeTest(builtInObjectsRegExp, e),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -1145,7 +1130,7 @@ function addPrototypeProperties(
|
||||||
if (
|
if (
|
||||||
descriptor !== undefined &&
|
descriptor !== undefined &&
|
||||||
typeof descriptor.value === "function" &&
|
typeof descriptor.value === "function" &&
|
||||||
builtInObjects.has(descriptor.value.name)
|
SetPrototypeHas(builtInObjects, descriptor.value.name)
|
||||||
) {
|
) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -1154,18 +1139,17 @@ function addPrototypeProperties(
|
||||||
if (depth === 0) {
|
if (depth === 0) {
|
||||||
keySet = new SafeSet();
|
keySet = new SafeSet();
|
||||||
} else {
|
} else {
|
||||||
Array.prototype.forEach.call(keys, (key) => keySet.add(key));
|
ArrayPrototypeForEach(keys, (key) => SetPrototypeAdd(keySet, key));
|
||||||
}
|
}
|
||||||
// Get all own property names and symbols.
|
// Get all own property names and symbols.
|
||||||
keys = ReflectOwnKeys(obj);
|
keys = ReflectOwnKeys(obj);
|
||||||
Array.prototype.push.call(ctx.seen, main);
|
ArrayPrototypePush(ctx.seen, main);
|
||||||
for (const key of new SafeArrayIterator(keys)) {
|
for (const key of new SafeArrayIterator(keys)) {
|
||||||
// Ignore the `constructor` property and keys that exist on layers above.
|
// Ignore the `constructor` property and keys that exist on layers above.
|
||||||
if (
|
if (
|
||||||
key === "constructor" ||
|
key === "constructor" ||
|
||||||
// deno-lint-ignore no-prototype-builtins
|
ObjectPrototypeHasOwnProperty(main, key) ||
|
||||||
main.hasOwnProperty(key) ||
|
(depth !== 0 && SetPrototypeHas(keySet, key))
|
||||||
(depth !== 0 && keySet.has(key))
|
|
||||||
) {
|
) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -1184,12 +1168,12 @@ function addPrototypeProperties(
|
||||||
);
|
);
|
||||||
if (ctx.colors) {
|
if (ctx.colors) {
|
||||||
// Faint!
|
// Faint!
|
||||||
Array.prototype.push.call(output, `\u001b[2m${value}\u001b[22m`);
|
ArrayPrototypePush(output, `\u001b[2m${value}\u001b[22m`);
|
||||||
} else {
|
} else {
|
||||||
Array.prototype.push.call(output, value);
|
ArrayPrototypePush(output, value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Array.prototype.pop.call(ctx.seen);
|
ArrayPrototypePop(ctx.seen);
|
||||||
// Limit the inspection to up to three prototype layers. Using `recurseTimes`
|
// Limit the inspection to up to three prototype layers. Using `recurseTimes`
|
||||||
// is not a good choice here, because it's as if the properties are declared
|
// is not a good choice here, because it's as if the properties are declared
|
||||||
// on the current object from the users perspective.
|
// on the current object from the users perspective.
|
||||||
|
@ -1218,7 +1202,7 @@ function getConstructorName(obj, ctx, recurseTimes, protoProps) {
|
||||||
if (
|
if (
|
||||||
protoProps !== undefined &&
|
protoProps !== undefined &&
|
||||||
(firstProto !== obj ||
|
(firstProto !== obj ||
|
||||||
!builtInObjects.has(descriptor.value.name))
|
!SetPrototypeHas(builtInObjects, descriptor.value.name))
|
||||||
) {
|
) {
|
||||||
addPrototypeProperties(
|
addPrototypeProperties(
|
||||||
ctx,
|
ctx,
|
||||||
|
@ -1273,7 +1257,7 @@ function formatPrimitive(fn, value, ctx) {
|
||||||
let trailer = "";
|
let trailer = "";
|
||||||
if (value.length > ctx.maxStringLength) {
|
if (value.length > ctx.maxStringLength) {
|
||||||
const remaining = value.length - ctx.maxStringLength;
|
const remaining = value.length - ctx.maxStringLength;
|
||||||
value = value.slice(0, ctx.maxStringLength);
|
value = StringPrototypeSlice(value, 0, ctx.maxStringLength);
|
||||||
trailer = `... ${remaining} more character${remaining > 1 ? "s" : ""}`;
|
trailer = `... ${remaining} more character${remaining > 1 ? "s" : ""}`;
|
||||||
}
|
}
|
||||||
if (
|
if (
|
||||||
|
@ -1283,10 +1267,13 @@ function formatPrimitive(fn, value, ctx) {
|
||||||
value.length > kMinLineLength &&
|
value.length > kMinLineLength &&
|
||||||
value.length > ctx.breakLength - ctx.indentationLvl - 4
|
value.length > ctx.breakLength - ctx.indentationLvl - 4
|
||||||
) {
|
) {
|
||||||
return value
|
return ArrayPrototypeJoin(
|
||||||
.split(formatPrimitiveRegExp)
|
ArrayPrototypeMap(
|
||||||
.map((line) => fn(quoteString(line, ctx), "string"))
|
StringPrototypeSplit(value, formatPrimitiveRegExp),
|
||||||
.join(` +\n${" ".repeat(ctx.indentationLvl + 2)}`) + trailer;
|
(line) => fn(quoteString(line, ctx), "string"),
|
||||||
|
),
|
||||||
|
` +\n${StringPrototypeRepeat(" ", ctx.indentationLvl + 2)}`,
|
||||||
|
) + trailer;
|
||||||
}
|
}
|
||||||
return fn(quoteString(value, ctx), "string") + trailer;
|
return fn(quoteString(value, ctx), "string") + trailer;
|
||||||
}
|
}
|
||||||
|
@ -1328,14 +1315,19 @@ function formatArray(ctx, value, recurseTimes) {
|
||||||
const output = [];
|
const output = [];
|
||||||
for (let i = 0; i < len; i++) {
|
for (let i = 0; i < len; i++) {
|
||||||
// Special handle sparse arrays.
|
// Special handle sparse arrays.
|
||||||
// deno-lint-ignore no-prototype-builtins
|
if (!ObjectPrototypeHasOwnProperty(value, i)) {
|
||||||
if (!value.hasOwnProperty(i)) {
|
|
||||||
return formatSpecialArray(ctx, value, recurseTimes, len, output, i);
|
return formatSpecialArray(ctx, value, recurseTimes, len, output, i);
|
||||||
}
|
}
|
||||||
output.push(formatProperty(ctx, value, recurseTimes, i, kArrayType));
|
ArrayPrototypePush(
|
||||||
|
output,
|
||||||
|
formatProperty(ctx, value, recurseTimes, i, kArrayType),
|
||||||
|
);
|
||||||
}
|
}
|
||||||
if (remaining > 0) {
|
if (remaining > 0) {
|
||||||
output.push(`... ${remaining} more item${remaining > 1 ? "s" : ""}`);
|
ArrayPrototypePush(
|
||||||
|
output,
|
||||||
|
`... ${remaining} more item${remaining > 1 ? "s" : ""}`,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
return output;
|
return output;
|
||||||
}
|
}
|
||||||
|
@ -1393,10 +1385,13 @@ function formatSet(value, ctx, _ignored, recurseTimes) {
|
||||||
const remaining = valLen - len;
|
const remaining = valLen - len;
|
||||||
const output = [];
|
const output = [];
|
||||||
for (let i = 0; i < len; i++) {
|
for (let i = 0; i < len; i++) {
|
||||||
output.push(formatValue(ctx, values[i], recurseTimes));
|
ArrayPrototypePush(output, formatValue(ctx, values[i], recurseTimes));
|
||||||
}
|
}
|
||||||
if (remaining > 0) {
|
if (remaining > 0) {
|
||||||
output.push(`... ${remaining} more item${remaining > 1 ? "s" : ""}`);
|
ArrayPrototypePush(
|
||||||
|
output,
|
||||||
|
`... ${remaining} more item${remaining > 1 ? "s" : ""}`,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
ctx.indentationLvl -= 2;
|
ctx.indentationLvl -= 2;
|
||||||
|
@ -1413,14 +1408,18 @@ function formatMap(value, ctx, _gnored, recurseTimes) {
|
||||||
const remaining = valLen - len;
|
const remaining = valLen - len;
|
||||||
const output = [];
|
const output = [];
|
||||||
for (let i = 0; i < len; i++) {
|
for (let i = 0; i < len; i++) {
|
||||||
output.push(
|
ArrayPrototypePush(
|
||||||
|
output,
|
||||||
`${formatValue(ctx, values[i][0], recurseTimes)} => ${
|
`${formatValue(ctx, values[i][0], recurseTimes)} => ${
|
||||||
formatValue(ctx, values[i][1], recurseTimes)
|
formatValue(ctx, values[i][1], recurseTimes)
|
||||||
}`,
|
}`,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
if (remaining > 0) {
|
if (remaining > 0) {
|
||||||
output.push(`... ${remaining} more item${remaining > 1 ? "s" : ""}`);
|
ArrayPrototypePush(
|
||||||
|
output,
|
||||||
|
`... ${remaining} more item${remaining > 1 ? "s" : ""}`,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
ctx.indentationLvl -= 2;
|
ctx.indentationLvl -= 2;
|
||||||
|
@ -1460,7 +1459,7 @@ function formatTypedArray(
|
||||||
])
|
])
|
||||||
) {
|
) {
|
||||||
const str = formatValue(ctx, value[key], recurseTimes, true);
|
const str = formatValue(ctx, value[key], recurseTimes, true);
|
||||||
Array.prototype.push.call(output, `[${key}]: ${str}`);
|
ArrayPrototypePush(output, `[${key}]: ${str}`);
|
||||||
}
|
}
|
||||||
ctx.indentationLvl -= 2;
|
ctx.indentationLvl -= 2;
|
||||||
}
|
}
|
||||||
|
@ -1484,7 +1483,11 @@ function formatIterator(braces, ctx, value, recurseTimes) {
|
||||||
const { 0: entries, 1: isKeyValue } = value;
|
const { 0: entries, 1: isKeyValue } = value;
|
||||||
if (isKeyValue) {
|
if (isKeyValue) {
|
||||||
// Mark entry iterators as such.
|
// Mark entry iterators as such.
|
||||||
braces[0] = braces[0].replace(iteratorRegExp, " Entries] {");
|
braces[0] = StringPrototypeReplace(
|
||||||
|
braces[0],
|
||||||
|
iteratorRegExp,
|
||||||
|
" Entries] {",
|
||||||
|
);
|
||||||
return formatMapIterInner(ctx, recurseTimes, entries, kMapEntries);
|
return formatMapIterInner(ctx, recurseTimes, entries, kMapEntries);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1627,8 +1630,13 @@ function formatArrayBuffer(ctx, value) {
|
||||||
} catch {
|
} catch {
|
||||||
return [ctx.stylize("(detached)", "special")];
|
return [ctx.stylize("(detached)", "special")];
|
||||||
}
|
}
|
||||||
let str = hexSlice(buffer, 0, MathMin(ctx.maxArrayLength, buffer.length))
|
let str = StringPrototypeTrim(
|
||||||
.replace(arrayBufferRegExp, "$1 ").trim();
|
StringPrototypeReplace(
|
||||||
|
hexSlice(buffer, 0, MathMin(ctx.maxArrayLength, buffer.length)),
|
||||||
|
arrayBufferRegExp,
|
||||||
|
"$1 ",
|
||||||
|
),
|
||||||
|
);
|
||||||
|
|
||||||
const remaining = buffer.length - ctx.maxArrayLength;
|
const remaining = buffer.length - ctx.maxArrayLength;
|
||||||
if (remaining > 0) {
|
if (remaining > 0) {
|
||||||
|
@ -1703,7 +1711,7 @@ function formatProperty(
|
||||||
ctx.indentationLvl += diff;
|
ctx.indentationLvl += diff;
|
||||||
str = formatValue(ctx, desc.value, recurseTimes);
|
str = formatValue(ctx, desc.value, recurseTimes);
|
||||||
if (diff === 3 && ctx.breakLength < getStringWidth(str, ctx.colors)) {
|
if (diff === 3 && ctx.breakLength < getStringWidth(str, ctx.colors)) {
|
||||||
extra = `\n${" ".repeat(ctx.indentationLvl)}`;
|
extra = `\n${StringPrototypeRepeat(" ", ctx.indentationLvl)}`;
|
||||||
}
|
}
|
||||||
ctx.indentationLvl -= diff;
|
ctx.indentationLvl -= diff;
|
||||||
} else if (desc.get !== undefined) {
|
} else if (desc.get !== undefined) {
|
||||||
|
@ -1716,7 +1724,7 @@ function formatProperty(
|
||||||
(ctx.getters === "set" && desc.set !== undefined))
|
(ctx.getters === "set" && desc.set !== undefined))
|
||||||
) {
|
) {
|
||||||
try {
|
try {
|
||||||
const tmp = desc.get.call(original);
|
const tmp = FunctionPrototypeCall(desc.get, original);
|
||||||
ctx.indentationLvl += 2;
|
ctx.indentationLvl += 2;
|
||||||
if (tmp === null) {
|
if (tmp === null) {
|
||||||
str = `${s(`[${label}:`, sp)} ${s("null", "null")}${s("]", sp)}`;
|
str = `${s(`[${label}:`, sp)} ${s("null", "null")}${s("]", sp)}`;
|
||||||
|
@ -1747,7 +1755,11 @@ function formatProperty(
|
||||||
} else if (key === "__proto__") {
|
} else if (key === "__proto__") {
|
||||||
name = "['__proto__']";
|
name = "['__proto__']";
|
||||||
} else if (desc.enumerable === false) {
|
} else if (desc.enumerable === false) {
|
||||||
const tmp = key.replace(strEscapeSequencesReplacer, escapeFn);
|
const tmp = StringPrototypeReplace(
|
||||||
|
key,
|
||||||
|
strEscapeSequencesReplacer,
|
||||||
|
escapeFn,
|
||||||
|
);
|
||||||
|
|
||||||
name = `[${tmp}]`;
|
name = `[${tmp}]`;
|
||||||
} else if (keyStrRegExp.test(key)) {
|
} else if (keyStrRegExp.test(key)) {
|
||||||
|
@ -1780,7 +1792,7 @@ function handleMaxCallStackSize(
|
||||||
|
|
||||||
const colorRegExp = new SafeRegExp("\u001b\\[\\d\\d?m", "g");
|
const colorRegExp = new SafeRegExp("\u001b\\[\\d\\d?m", "g");
|
||||||
function removeColors(str) {
|
function removeColors(str) {
|
||||||
return str.replace(colorRegExp, "");
|
return StringPrototypeReplace(str, colorRegExp, "");
|
||||||
}
|
}
|
||||||
|
|
||||||
function isBelowBreakLength(ctx, output, start, base) {
|
function isBelowBreakLength(ctx, output, start, base) {
|
||||||
|
@ -1836,10 +1848,10 @@ function formatNamespaceObject(
|
||||||
// this aligned, even though this is a hacky way of dealing with this.
|
// this aligned, even though this is a hacky way of dealing with this.
|
||||||
const tmp = { [keys[i]]: "" };
|
const tmp = { [keys[i]]: "" };
|
||||||
output[i] = formatProperty(ctx, tmp, recurseTimes, keys[i], kObjectType);
|
output[i] = formatProperty(ctx, tmp, recurseTimes, keys[i], kObjectType);
|
||||||
const pos = output[i].lastIndexOf(" ");
|
const pos = StringPrototypeLastIndexOf(output[i], " ");
|
||||||
// We have to find the last whitespace and have to replace that value as
|
// We have to find the last whitespace and have to replace that value as
|
||||||
// it will be visualized as a regular string.
|
// it will be visualized as a regular string.
|
||||||
output[i] = output[i].slice(0, pos + 1) +
|
output[i] = StringPrototypeSlice(output[i], 0, pos + 1) +
|
||||||
ctx.stylize("<uninitialized>", "special");
|
ctx.stylize("<uninitialized>", "special");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1873,13 +1885,16 @@ function formatSpecialArray(
|
||||||
const emptyItems = tmp - index;
|
const emptyItems = tmp - index;
|
||||||
const ending = emptyItems > 1 ? "s" : "";
|
const ending = emptyItems > 1 ? "s" : "";
|
||||||
const message = `<${emptyItems} empty item${ending}>`;
|
const message = `<${emptyItems} empty item${ending}>`;
|
||||||
output.push(ctx.stylize(message, "undefined"));
|
ArrayPrototypePush(output, ctx.stylize(message, "undefined"));
|
||||||
index = tmp;
|
index = tmp;
|
||||||
if (output.length === maxLength) {
|
if (output.length === maxLength) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
output.push(formatProperty(ctx, value, recurseTimes, key, kArrayType));
|
ArrayPrototypePush(
|
||||||
|
output,
|
||||||
|
formatProperty(ctx, value, recurseTimes, key, kArrayType),
|
||||||
|
);
|
||||||
index++;
|
index++;
|
||||||
}
|
}
|
||||||
const remaining = value.length - index;
|
const remaining = value.length - index;
|
||||||
|
@ -1887,10 +1902,13 @@ function formatSpecialArray(
|
||||||
if (remaining > 0) {
|
if (remaining > 0) {
|
||||||
const ending = remaining > 1 ? "s" : "";
|
const ending = remaining > 1 ? "s" : "";
|
||||||
const message = `<${remaining} empty item${ending}>`;
|
const message = `<${remaining} empty item${ending}>`;
|
||||||
output.push(ctx.stylize(message, "undefined"));
|
ArrayPrototypePush(output, ctx.stylize(message, "undefined"));
|
||||||
}
|
}
|
||||||
} else if (remaining > 0) {
|
} else if (remaining > 0) {
|
||||||
output.push(`... ${remaining} more item${remaining > 1 ? "s" : ""}`);
|
ArrayPrototypePush(
|
||||||
|
output,
|
||||||
|
`... ${remaining} more item${remaining > 1 ? "s" : ""}`,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
return output;
|
return output;
|
||||||
}
|
}
|
||||||
|
@ -1902,22 +1920,28 @@ function getBoxedBase(
|
||||||
constructor,
|
constructor,
|
||||||
tag,
|
tag,
|
||||||
) {
|
) {
|
||||||
let type;
|
let type, primitive;
|
||||||
if (isNumberObject(value)) {
|
if (isNumberObject(value)) {
|
||||||
type = "Number";
|
type = "Number";
|
||||||
|
primitive = NumberPrototypeValueOf(value);
|
||||||
} else if (isStringObject(value)) {
|
} else if (isStringObject(value)) {
|
||||||
type = "String";
|
type = "String";
|
||||||
|
primitive = StringPrototypeValueOf(value);
|
||||||
// For boxed Strings, we have to remove the 0-n indexed entries,
|
// For boxed Strings, we have to remove the 0-n indexed entries,
|
||||||
// since they just noisy up the output and are redundant
|
// since they just noisy up the output and are redundant
|
||||||
// Make boxed primitive Strings look like such
|
// Make boxed primitive Strings look like such
|
||||||
keys.splice(0, value.length);
|
ArrayPrototypeSplice(keys, 0, value.length);
|
||||||
} else if (isBooleanObject(value)) {
|
} else if (isBooleanObject(value)) {
|
||||||
type = "Boolean";
|
type = "Boolean";
|
||||||
|
primitive = BooleanPrototypeValueOf(value);
|
||||||
} else if (isBigIntObject(value)) {
|
} else if (isBigIntObject(value)) {
|
||||||
type = "BigInt";
|
type = "BigInt";
|
||||||
|
primitive = BigIntPrototypeValueOf(value);
|
||||||
} else {
|
} else {
|
||||||
type = "Symbol";
|
type = "Symbol";
|
||||||
|
primitive = SymbolPrototypeValueOf(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
let base = `[${type}`;
|
let base = `[${type}`;
|
||||||
if (type !== constructor) {
|
if (type !== constructor) {
|
||||||
if (constructor === null) {
|
if (constructor === null) {
|
||||||
|
@ -1926,15 +1950,14 @@ function getBoxedBase(
|
||||||
base += ` (${constructor})`;
|
base += ` (${constructor})`;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
base += `: ${formatPrimitive(stylizeNoColor, primitive, ctx)}]`;
|
||||||
base += `: ${formatPrimitive(stylizeNoColor, value.valueOf(), ctx)}]`;
|
|
||||||
if (tag !== "" && tag !== constructor) {
|
if (tag !== "" && tag !== constructor) {
|
||||||
base += ` [${tag}]`;
|
base += ` [${tag}]`;
|
||||||
}
|
}
|
||||||
if (keys.length !== 0 || ctx.stylize === stylizeNoColor) {
|
if (keys.length !== 0 || ctx.stylize === stylizeNoColor) {
|
||||||
return base;
|
return base;
|
||||||
}
|
}
|
||||||
return ctx.stylize(base, type.toLowerCase());
|
return ctx.stylize(base, StringPrototypeToLowerCase(type));
|
||||||
}
|
}
|
||||||
|
|
||||||
function reduceToSingleString(
|
function reduceToSingleString(
|
||||||
|
@ -2140,7 +2163,7 @@ function formatMapIterInner(
|
||||||
const len = entries.length / 2;
|
const len = entries.length / 2;
|
||||||
const remaining = len - maxArrayLength;
|
const remaining = len - maxArrayLength;
|
||||||
const maxLength = MathMin(maxArrayLength, len);
|
const maxLength = MathMin(maxArrayLength, len);
|
||||||
let output = new Array(maxLength);
|
const output = new Array(maxLength);
|
||||||
let i = 0;
|
let i = 0;
|
||||||
ctx.indentationLvl += 2;
|
ctx.indentationLvl += 2;
|
||||||
if (state === kWeak) {
|
if (state === kWeak) {
|
||||||
|
@ -2154,7 +2177,7 @@ function formatMapIterInner(
|
||||||
// retrieved ones exist, we can not reliably return the same output) if the
|
// retrieved ones exist, we can not reliably return the same output) if the
|
||||||
// output is not sorted anyway.
|
// output is not sorted anyway.
|
||||||
if (!ctx.sorted) {
|
if (!ctx.sorted) {
|
||||||
output = output.sort();
|
ArrayPrototypeSort(output);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
for (; i < maxLength; i++) {
|
for (; i < maxLength; i++) {
|
||||||
|
@ -2175,7 +2198,10 @@ function formatMapIterInner(
|
||||||
}
|
}
|
||||||
ctx.indentationLvl -= 2;
|
ctx.indentationLvl -= 2;
|
||||||
if (remaining > 0) {
|
if (remaining > 0) {
|
||||||
output.push(`... ${remaining} more item${remaining > 1 ? "s" : ""}`);
|
ArrayPrototypePush(
|
||||||
|
output,
|
||||||
|
`... ${remaining} more item${remaining > 1 ? "s" : ""}`,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
return output;
|
return output;
|
||||||
}
|
}
|
||||||
|
@ -2198,11 +2224,11 @@ function formatSetIterInner(
|
||||||
// Sort all entries to have a halfway reliable output (if more entries than
|
// Sort all entries to have a halfway reliable output (if more entries than
|
||||||
// retrieved ones exist, we can not reliably return the same output) if the
|
// retrieved ones exist, we can not reliably return the same output) if the
|
||||||
// output is not sorted anyway.
|
// output is not sorted anyway.
|
||||||
output.sort();
|
ArrayPrototypeSort(output);
|
||||||
}
|
}
|
||||||
const remaining = entries.length - maxLength;
|
const remaining = entries.length - maxLength;
|
||||||
if (remaining > 0) {
|
if (remaining > 0) {
|
||||||
Array.prototype.push.call(
|
ArrayPrototypePush(
|
||||||
output,
|
output,
|
||||||
`... ${remaining} more item${remaining > 1 ? "s" : ""}`,
|
`... ${remaining} more item${remaining > 1 ? "s" : ""}`,
|
||||||
);
|
);
|
||||||
|
@ -2229,9 +2255,9 @@ export function getStringWidth(str, removeControlChars = true) {
|
||||||
if (removeControlChars) {
|
if (removeControlChars) {
|
||||||
str = stripVTControlCharacters(str);
|
str = stripVTControlCharacters(str);
|
||||||
}
|
}
|
||||||
str = str.normalize("NFC");
|
str = StringPrototypeNormalize(str, "NFC");
|
||||||
for (const char of new SafeStringIterator(str)) {
|
for (const char of new SafeStringIterator(str)) {
|
||||||
const code = char.codePointAt(0);
|
const code = StringPrototypeCodePointAt(char, 0);
|
||||||
if (isFullWidthCodePoint(code)) {
|
if (isFullWidthCodePoint(code)) {
|
||||||
width += 2;
|
width += 2;
|
||||||
} else if (!isZeroWidthCodePoint(code)) {
|
} else if (!isZeroWidthCodePoint(code)) {
|
||||||
|
@ -2258,7 +2284,7 @@ const isZeroWidthCodePoint = (code) => {
|
||||||
* Remove all VT control characters. Use to estimate displayed string width.
|
* Remove all VT control characters. Use to estimate displayed string width.
|
||||||
*/
|
*/
|
||||||
export function stripVTControlCharacters(str) {
|
export function stripVTControlCharacters(str) {
|
||||||
return str.replace(ansi, "");
|
return StringPrototypeReplace(str, ansi, "");
|
||||||
}
|
}
|
||||||
|
|
||||||
function hasOwnProperty(obj, v) {
|
function hasOwnProperty(obj, v) {
|
||||||
|
@ -2353,7 +2379,10 @@ function cliTable(head, columns) {
|
||||||
(n, a) => MathMax(n, a.length),
|
(n, a) => MathMax(n, a.length),
|
||||||
0,
|
0,
|
||||||
);
|
);
|
||||||
const columnRightAlign = new Array(columnWidths.length).fill(true);
|
const columnRightAlign = ArrayPrototypeFill(
|
||||||
|
new Array(columnWidths.length),
|
||||||
|
true,
|
||||||
|
);
|
||||||
|
|
||||||
for (let i = 0; i < head.length; i++) {
|
for (let i = 0; i < head.length; i++) {
|
||||||
const column = columns[i];
|
const column = columns[i];
|
||||||
|
@ -3349,7 +3378,7 @@ class Console {
|
||||||
const values = [];
|
const values = [];
|
||||||
|
|
||||||
let hasPrimitives = false;
|
let hasPrimitives = false;
|
||||||
keys.forEach((k, idx) => {
|
ArrayPrototypeForEach(keys, (k, idx) => {
|
||||||
const value = resultData[k];
|
const value = resultData[k];
|
||||||
const primitive = value === null ||
|
const primitive = value === null ||
|
||||||
(typeof value !== "function" && typeof value !== "object");
|
(typeof value !== "function" && typeof value !== "object");
|
||||||
|
|
|
@ -12,11 +12,12 @@ const primordials = globalThis.__bootstrap.primordials;
|
||||||
import * as webidl from "ext:deno_webidl/00_webidl.js";
|
import * as webidl from "ext:deno_webidl/00_webidl.js";
|
||||||
import DOMException from "ext:deno_web/01_dom_exception.js";
|
import DOMException from "ext:deno_web/01_dom_exception.js";
|
||||||
const {
|
const {
|
||||||
ArrayBufferPrototype,
|
|
||||||
ArrayBufferPrototypeSlice,
|
|
||||||
ArrayBufferPrototypeGetByteLength,
|
|
||||||
ArrayBufferIsView,
|
ArrayBufferIsView,
|
||||||
|
ArrayBufferPrototype,
|
||||||
|
ArrayBufferPrototypeGetByteLength,
|
||||||
|
ArrayBufferPrototypeSlice,
|
||||||
ArrayPrototypeEvery,
|
ArrayPrototypeEvery,
|
||||||
|
ArrayPrototypeFilter,
|
||||||
ArrayPrototypeFind,
|
ArrayPrototypeFind,
|
||||||
ArrayPrototypeIncludes,
|
ArrayPrototypeIncludes,
|
||||||
DataViewPrototypeGetBuffer,
|
DataViewPrototypeGetBuffer,
|
||||||
|
@ -28,21 +29,21 @@ const {
|
||||||
ObjectAssign,
|
ObjectAssign,
|
||||||
ObjectPrototypeHasOwnProperty,
|
ObjectPrototypeHasOwnProperty,
|
||||||
ObjectPrototypeIsPrototypeOf,
|
ObjectPrototypeIsPrototypeOf,
|
||||||
StringPrototypeToLowerCase,
|
|
||||||
StringPrototypeToUpperCase,
|
|
||||||
StringPrototypeCharCodeAt,
|
|
||||||
StringFromCharCode,
|
|
||||||
SafeArrayIterator,
|
SafeArrayIterator,
|
||||||
SafeWeakMap,
|
SafeWeakMap,
|
||||||
|
StringFromCharCode,
|
||||||
|
StringPrototypeCharCodeAt,
|
||||||
|
StringPrototypeToLowerCase,
|
||||||
|
StringPrototypeToUpperCase,
|
||||||
Symbol,
|
Symbol,
|
||||||
SymbolFor,
|
SymbolFor,
|
||||||
SyntaxError,
|
SyntaxError,
|
||||||
TypedArrayPrototypeSlice,
|
TypeError,
|
||||||
TypedArrayPrototypeGetBuffer,
|
TypedArrayPrototypeGetBuffer,
|
||||||
TypedArrayPrototypeGetByteLength,
|
TypedArrayPrototypeGetByteLength,
|
||||||
TypedArrayPrototypeGetByteOffset,
|
TypedArrayPrototypeGetByteOffset,
|
||||||
TypedArrayPrototypeGetSymbolToStringTag,
|
TypedArrayPrototypeGetSymbolToStringTag,
|
||||||
TypeError,
|
TypedArrayPrototypeSlice,
|
||||||
Uint8Array,
|
Uint8Array,
|
||||||
WeakMapPrototypeGet,
|
WeakMapPrototypeGet,
|
||||||
WeakMapPrototypeSet,
|
WeakMapPrototypeSet,
|
||||||
|
@ -388,7 +389,10 @@ function constructKey(type, extractable, usages, algorithm, handle) {
|
||||||
* @returns
|
* @returns
|
||||||
*/
|
*/
|
||||||
function usageIntersection(a, b) {
|
function usageIntersection(a, b) {
|
||||||
return a.filter((i) => b.includes(i));
|
return ArrayPrototypeFilter(
|
||||||
|
a,
|
||||||
|
(i) => ArrayPrototypeIncludes(b, i),
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO(lucacasonato): this should be moved to rust
|
// TODO(lucacasonato): this should be moved to rust
|
||||||
|
|
|
@ -37,6 +37,7 @@ const {
|
||||||
ObjectKeys,
|
ObjectKeys,
|
||||||
ObjectPrototypeIsPrototypeOf,
|
ObjectPrototypeIsPrototypeOf,
|
||||||
RegExpPrototypeTest,
|
RegExpPrototypeTest,
|
||||||
|
StringPrototypeStartsWith,
|
||||||
Symbol,
|
Symbol,
|
||||||
SymbolFor,
|
SymbolFor,
|
||||||
TypeError,
|
TypeError,
|
||||||
|
@ -90,7 +91,11 @@ function processUrlList(urlList, urlListProcessed) {
|
||||||
*/
|
*/
|
||||||
function newInnerRequest(method, url, headerList, body, maybeBlob) {
|
function newInnerRequest(method, url, headerList, body, maybeBlob) {
|
||||||
let blobUrlEntry = null;
|
let blobUrlEntry = null;
|
||||||
if (maybeBlob && typeof url === "string" && url.startsWith("blob:")) {
|
if (
|
||||||
|
maybeBlob &&
|
||||||
|
typeof url === "string" &&
|
||||||
|
StringPrototypeStartsWith(url, "blob:")
|
||||||
|
) {
|
||||||
blobUrlEntry = blobFromObjectUrl(url);
|
blobUrlEntry = blobFromObjectUrl(url);
|
||||||
}
|
}
|
||||||
return {
|
return {
|
||||||
|
|
|
@ -7,12 +7,15 @@ const {
|
||||||
ArrayPrototypeFilter,
|
ArrayPrototypeFilter,
|
||||||
Date,
|
Date,
|
||||||
DatePrototype,
|
DatePrototype,
|
||||||
|
DatePrototypeGetTime,
|
||||||
Error,
|
Error,
|
||||||
Function,
|
Function,
|
||||||
MathTrunc,
|
MathTrunc,
|
||||||
ObjectEntries,
|
ObjectEntries,
|
||||||
ObjectPrototypeIsPrototypeOf,
|
ObjectPrototypeIsPrototypeOf,
|
||||||
ObjectValues,
|
ObjectValues,
|
||||||
|
StringPrototypeSlice,
|
||||||
|
StringPrototypeStartsWith,
|
||||||
SymbolAsyncIterator,
|
SymbolAsyncIterator,
|
||||||
SymbolIterator,
|
SymbolIterator,
|
||||||
Uint32Array,
|
Uint32Array,
|
||||||
|
@ -232,8 +235,8 @@ function createByteStruct(types) {
|
||||||
for (let i = 0; i < typeEntries.length; ++i) {
|
for (let i = 0; i < typeEntries.length; ++i) {
|
||||||
let { 0: name, 1: type } = typeEntries[i];
|
let { 0: name, 1: type } = typeEntries[i];
|
||||||
|
|
||||||
const optional = type.startsWith("?");
|
const optional = StringPrototypeStartsWith(type, "?");
|
||||||
if (optional) type = type.slice(1);
|
if (optional) type = StringPrototypeSlice(type, 1);
|
||||||
|
|
||||||
if (type == "u64") {
|
if (type == "u64") {
|
||||||
if (!optional) {
|
if (!optional) {
|
||||||
|
@ -369,7 +372,7 @@ async function link(oldpath, newpath) {
|
||||||
|
|
||||||
function toUnixTimeFromEpoch(value) {
|
function toUnixTimeFromEpoch(value) {
|
||||||
if (ObjectPrototypeIsPrototypeOf(DatePrototype, value)) {
|
if (ObjectPrototypeIsPrototypeOf(DatePrototype, value)) {
|
||||||
const time = value.valueOf();
|
const time = DatePrototypeGetTime(value);
|
||||||
const seconds = MathTrunc(time / 1e3);
|
const seconds = MathTrunc(time / 1e3);
|
||||||
const nanoseconds = MathTrunc(time - (seconds * 1e3)) * 1e6;
|
const nanoseconds = MathTrunc(time - (seconds * 1e3)) * 1e6;
|
||||||
|
|
||||||
|
|
|
@ -37,14 +37,15 @@ import {
|
||||||
import { TcpConn } from "ext:deno_net/01_net.js";
|
import { TcpConn } from "ext:deno_net/01_net.js";
|
||||||
const {
|
const {
|
||||||
ObjectPrototypeIsPrototypeOf,
|
ObjectPrototypeIsPrototypeOf,
|
||||||
|
PromisePrototypeCatch,
|
||||||
SafeSet,
|
SafeSet,
|
||||||
SafeSetIterator,
|
SafeSetIterator,
|
||||||
SetPrototypeAdd,
|
SetPrototypeAdd,
|
||||||
SetPrototypeDelete,
|
SetPrototypeDelete,
|
||||||
Symbol,
|
Symbol,
|
||||||
TypeError,
|
TypeError,
|
||||||
Uint8ArrayPrototype,
|
|
||||||
Uint8Array,
|
Uint8Array,
|
||||||
|
Uint8ArrayPrototype,
|
||||||
} = primordials;
|
} = primordials;
|
||||||
|
|
||||||
const {
|
const {
|
||||||
|
@ -667,7 +668,7 @@ async function serve(arg1, arg2) {
|
||||||
if (req === 0xffffffff) {
|
if (req === 0xffffffff) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
callback(req).catch((error) => {
|
PromisePrototypeCatch(callback(req), (error) => {
|
||||||
// Abnormal exit
|
// Abnormal exit
|
||||||
console.error(
|
console.error(
|
||||||
"Terminating Deno.serve loop due to unexpected error",
|
"Terminating Deno.serve loop due to unexpected error",
|
||||||
|
|
|
@ -54,8 +54,9 @@ const {
|
||||||
SetPrototypeDelete,
|
SetPrototypeDelete,
|
||||||
StringPrototypeCharCodeAt,
|
StringPrototypeCharCodeAt,
|
||||||
StringPrototypeIncludes,
|
StringPrototypeIncludes,
|
||||||
StringPrototypeToLowerCase,
|
|
||||||
StringPrototypeSplit,
|
StringPrototypeSplit,
|
||||||
|
StringPrototypeToLowerCase,
|
||||||
|
StringPrototypeToUpperCase,
|
||||||
Symbol,
|
Symbol,
|
||||||
SymbolAsyncIterator,
|
SymbolAsyncIterator,
|
||||||
TypeError,
|
TypeError,
|
||||||
|
@ -497,17 +498,20 @@ function buildCaseInsensitiveCommaValueFinder(checkText) {
|
||||||
StringPrototypeToLowerCase(checkText),
|
StringPrototypeToLowerCase(checkText),
|
||||||
"",
|
"",
|
||||||
),
|
),
|
||||||
(c) => [c.charCodeAt(0), c.toUpperCase().charCodeAt(0)],
|
(c) => [
|
||||||
|
StringPrototypeCharCodeAt(c, 0),
|
||||||
|
StringPrototypeCharCodeAt(StringPrototypeToUpperCase(c), 0),
|
||||||
|
],
|
||||||
);
|
);
|
||||||
/** @type {number} */
|
/** @type {number} */
|
||||||
let i;
|
let i;
|
||||||
/** @type {number} */
|
/** @type {number} */
|
||||||
let char;
|
let char;
|
||||||
|
|
||||||
/** @param value {string} */
|
/** @param {string} value */
|
||||||
return function (value) {
|
return function (value) {
|
||||||
for (i = 0; i < value.length; i++) {
|
for (i = 0; i < value.length; i++) {
|
||||||
char = value.charCodeAt(i);
|
char = StringPrototypeCharCodeAt(value, i);
|
||||||
skipWhitespace(value);
|
skipWhitespace(value);
|
||||||
|
|
||||||
if (hasWord(value)) {
|
if (hasWord(value)) {
|
||||||
|
|
|
@ -11,13 +11,16 @@ import {
|
||||||
import * as abortSignal from "ext:deno_web/03_abort_signal.js";
|
import * as abortSignal from "ext:deno_web/03_abort_signal.js";
|
||||||
const primordials = globalThis.__bootstrap.primordials;
|
const primordials = globalThis.__bootstrap.primordials;
|
||||||
const {
|
const {
|
||||||
|
ArrayPrototypeFilter,
|
||||||
|
ArrayPrototypeForEach,
|
||||||
|
ArrayPrototypePush,
|
||||||
Error,
|
Error,
|
||||||
ObjectPrototypeIsPrototypeOf,
|
ObjectPrototypeIsPrototypeOf,
|
||||||
PromiseResolve,
|
PromiseResolve,
|
||||||
SymbolAsyncIterator,
|
SymbolAsyncIterator,
|
||||||
SymbolFor,
|
SymbolFor,
|
||||||
TypedArrayPrototypeSubarray,
|
|
||||||
TypeError,
|
TypeError,
|
||||||
|
TypedArrayPrototypeSubarray,
|
||||||
Uint8Array,
|
Uint8Array,
|
||||||
} = primordials;
|
} = primordials;
|
||||||
|
|
||||||
|
@ -97,15 +100,16 @@ class Conn {
|
||||||
const promise = core.read(this.rid, buffer);
|
const promise = core.read(this.rid, buffer);
|
||||||
const promiseId = promise[promiseIdSymbol];
|
const promiseId = promise[promiseIdSymbol];
|
||||||
if (this.#unref) core.unrefOp(promiseId);
|
if (this.#unref) core.unrefOp(promiseId);
|
||||||
this.#pendingReadPromiseIds.push(promiseId);
|
ArrayPrototypePush(this.#pendingReadPromiseIds, promiseId);
|
||||||
let nread;
|
let nread;
|
||||||
try {
|
try {
|
||||||
nread = await promise;
|
nread = await promise;
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
throw e;
|
throw e;
|
||||||
} finally {
|
} finally {
|
||||||
this.#pendingReadPromiseIds = this.#pendingReadPromiseIds.filter((id) =>
|
this.#pendingReadPromiseIds = ArrayPrototypeFilter(
|
||||||
id !== promiseId
|
this.#pendingReadPromiseIds,
|
||||||
|
(id) => id !== promiseId,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
return nread === 0 ? null : nread;
|
return nread === 0 ? null : nread;
|
||||||
|
@ -141,7 +145,7 @@ class Conn {
|
||||||
if (this.#readable) {
|
if (this.#readable) {
|
||||||
readableStreamForRidUnrefableRef(this.#readable);
|
readableStreamForRidUnrefableRef(this.#readable);
|
||||||
}
|
}
|
||||||
this.#pendingReadPromiseIds.forEach((id) => core.refOp(id));
|
ArrayPrototypeForEach(this.#pendingReadPromiseIds, (id) => core.refOp(id));
|
||||||
}
|
}
|
||||||
|
|
||||||
unref() {
|
unref() {
|
||||||
|
@ -149,7 +153,10 @@ class Conn {
|
||||||
if (this.#readable) {
|
if (this.#readable) {
|
||||||
readableStreamForRidUnrefableUnref(this.#readable);
|
readableStreamForRidUnrefableUnref(this.#readable);
|
||||||
}
|
}
|
||||||
this.#pendingReadPromiseIds.forEach((id) => core.unrefOp(id));
|
ArrayPrototypeForEach(
|
||||||
|
this.#pendingReadPromiseIds,
|
||||||
|
(id) => core.unrefOp(id),
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -17,13 +17,14 @@ const {
|
||||||
ArrayPrototypeSort,
|
ArrayPrototypeSort,
|
||||||
ArrayPrototypeSplice,
|
ArrayPrototypeSplice,
|
||||||
ObjectKeys,
|
ObjectKeys,
|
||||||
Uint32Array,
|
|
||||||
SafeArrayIterator,
|
SafeArrayIterator,
|
||||||
StringPrototypeSlice,
|
StringPrototypeSlice,
|
||||||
|
StringPrototypeStartsWith,
|
||||||
Symbol,
|
Symbol,
|
||||||
SymbolFor,
|
SymbolFor,
|
||||||
SymbolIterator,
|
SymbolIterator,
|
||||||
TypeError,
|
TypeError,
|
||||||
|
Uint32Array,
|
||||||
} = primordials;
|
} = primordials;
|
||||||
|
|
||||||
const _list = Symbol("list");
|
const _list = Symbol("list");
|
||||||
|
@ -421,7 +422,10 @@ class URL {
|
||||||
|
|
||||||
#hasAuthority() {
|
#hasAuthority() {
|
||||||
// https://github.com/servo/rust-url/blob/1d307ae51a28fecc630ecec03380788bfb03a643/url/src/lib.rs#L824
|
// https://github.com/servo/rust-url/blob/1d307ae51a28fecc630ecec03380788bfb03a643/url/src/lib.rs#L824
|
||||||
return this.#serialization.slice(this.#schemeEnd).startsWith("://");
|
return StringPrototypeStartsWith(
|
||||||
|
StringPrototypeSlice(this.#serialization, this.#schemeEnd),
|
||||||
|
"://",
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @return {string} */
|
/** @return {string} */
|
||||||
|
@ -429,7 +433,7 @@ class URL {
|
||||||
webidl.assertBranded(this, URLPrototype);
|
webidl.assertBranded(this, URLPrototype);
|
||||||
// https://github.com/servo/rust-url/blob/1d307ae51a28fecc630ecec03380788bfb03a643/url/src/quirks.rs#L263
|
// https://github.com/servo/rust-url/blob/1d307ae51a28fecc630ecec03380788bfb03a643/url/src/quirks.rs#L263
|
||||||
return this.#fragmentStart
|
return this.#fragmentStart
|
||||||
? trim(this.#serialization.slice(this.#fragmentStart))
|
? trim(StringPrototypeSlice(this.#serialization, this.#fragmentStart))
|
||||||
: "";
|
: "";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -455,7 +459,11 @@ class URL {
|
||||||
get host() {
|
get host() {
|
||||||
webidl.assertBranded(this, URLPrototype);
|
webidl.assertBranded(this, URLPrototype);
|
||||||
// https://github.com/servo/rust-url/blob/1d307ae51a28fecc630ecec03380788bfb03a643/url/src/quirks.rs#L101
|
// https://github.com/servo/rust-url/blob/1d307ae51a28fecc630ecec03380788bfb03a643/url/src/quirks.rs#L101
|
||||||
return this.#serialization.slice(this.#hostStart, this.#pathStart);
|
return StringPrototypeSlice(
|
||||||
|
this.#serialization,
|
||||||
|
this.#hostStart,
|
||||||
|
this.#pathStart,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @param {string} value */
|
/** @param {string} value */
|
||||||
|
@ -480,7 +488,11 @@ class URL {
|
||||||
get hostname() {
|
get hostname() {
|
||||||
webidl.assertBranded(this, URLPrototype);
|
webidl.assertBranded(this, URLPrototype);
|
||||||
// https://github.com/servo/rust-url/blob/1d307ae51a28fecc630ecec03380788bfb03a643/url/src/lib.rs#L988
|
// https://github.com/servo/rust-url/blob/1d307ae51a28fecc630ecec03380788bfb03a643/url/src/lib.rs#L988
|
||||||
return this.#serialization.slice(this.#hostStart, this.#hostEnd);
|
return StringPrototypeSlice(
|
||||||
|
this.#serialization,
|
||||||
|
this.#hostStart,
|
||||||
|
this.#hostEnd,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @param {string} value */
|
/** @param {string} value */
|
||||||
|
@ -523,7 +535,11 @@ class URL {
|
||||||
get origin() {
|
get origin() {
|
||||||
webidl.assertBranded(this, URLPrototype);
|
webidl.assertBranded(this, URLPrototype);
|
||||||
// https://github.com/servo/rust-url/blob/1d307ae51a28fecc630ecec03380788bfb03a643/url/src/origin.rs#L14
|
// https://github.com/servo/rust-url/blob/1d307ae51a28fecc630ecec03380788bfb03a643/url/src/origin.rs#L14
|
||||||
const scheme = this.#serialization.slice(0, this.#schemeEnd);
|
const scheme = StringPrototypeSlice(
|
||||||
|
this.#serialization,
|
||||||
|
0,
|
||||||
|
this.#schemeEnd,
|
||||||
|
);
|
||||||
if (
|
if (
|
||||||
scheme === "http" || scheme === "https" || scheme === "ftp" ||
|
scheme === "http" || scheme === "https" || scheme === "ftp" ||
|
||||||
scheme === "ws" || scheme === "wss"
|
scheme === "ws" || scheme === "wss"
|
||||||
|
@ -552,7 +568,8 @@ class URL {
|
||||||
this.#usernameEnd !== this.#serialization.length &&
|
this.#usernameEnd !== this.#serialization.length &&
|
||||||
this.#serialization[this.#usernameEnd] === ":"
|
this.#serialization[this.#usernameEnd] === ":"
|
||||||
) {
|
) {
|
||||||
return this.#serialization.slice(
|
return StringPrototypeSlice(
|
||||||
|
this.#serialization,
|
||||||
this.#usernameEnd + 1,
|
this.#usernameEnd + 1,
|
||||||
this.#hostStart - 1,
|
this.#hostStart - 1,
|
||||||
);
|
);
|
||||||
|
@ -583,11 +600,15 @@ class URL {
|
||||||
webidl.assertBranded(this, URLPrototype);
|
webidl.assertBranded(this, URLPrototype);
|
||||||
// https://github.com/servo/rust-url/blob/1d307ae51a28fecc630ecec03380788bfb03a643/url/src/lib.rs#L1203
|
// https://github.com/servo/rust-url/blob/1d307ae51a28fecc630ecec03380788bfb03a643/url/src/lib.rs#L1203
|
||||||
if (!this.#queryStart && !this.#fragmentStart) {
|
if (!this.#queryStart && !this.#fragmentStart) {
|
||||||
return this.#serialization.slice(this.#pathStart);
|
return StringPrototypeSlice(this.#serialization, this.#pathStart);
|
||||||
}
|
}
|
||||||
|
|
||||||
const nextComponentStart = this.#queryStart || this.#fragmentStart;
|
const nextComponentStart = this.#queryStart || this.#fragmentStart;
|
||||||
return this.#serialization.slice(this.#pathStart, nextComponentStart);
|
return StringPrototypeSlice(
|
||||||
|
this.#serialization,
|
||||||
|
this.#pathStart,
|
||||||
|
nextComponentStart,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @param {string} value */
|
/** @param {string} value */
|
||||||
|
@ -613,9 +634,14 @@ class URL {
|
||||||
webidl.assertBranded(this, URLPrototype);
|
webidl.assertBranded(this, URLPrototype);
|
||||||
// https://github.com/servo/rust-url/blob/1d307ae51a28fecc630ecec03380788bfb03a643/url/src/quirks.rs#L196
|
// https://github.com/servo/rust-url/blob/1d307ae51a28fecc630ecec03380788bfb03a643/url/src/quirks.rs#L196
|
||||||
if (this.#port === NO_PORT) {
|
if (this.#port === NO_PORT) {
|
||||||
return this.#serialization.slice(this.#hostEnd, this.#pathStart);
|
return StringPrototypeSlice(
|
||||||
|
this.#serialization,
|
||||||
|
this.#hostEnd,
|
||||||
|
this.#pathStart,
|
||||||
|
);
|
||||||
} else {
|
} else {
|
||||||
return this.#serialization.slice(
|
return StringPrototypeSlice(
|
||||||
|
this.#serialization,
|
||||||
this.#hostEnd + 1, /* : */
|
this.#hostEnd + 1, /* : */
|
||||||
this.#pathStart,
|
this.#pathStart,
|
||||||
);
|
);
|
||||||
|
@ -644,7 +670,11 @@ class URL {
|
||||||
get protocol() {
|
get protocol() {
|
||||||
webidl.assertBranded(this, URLPrototype);
|
webidl.assertBranded(this, URLPrototype);
|
||||||
// https://github.com/servo/rust-url/blob/1d307ae51a28fecc630ecec03380788bfb03a643/url/src/quirks.rs#L56
|
// https://github.com/servo/rust-url/blob/1d307ae51a28fecc630ecec03380788bfb03a643/url/src/quirks.rs#L56
|
||||||
return this.#serialization.slice(0, this.#schemeEnd + 1 /* : */);
|
return StringPrototypeSlice(
|
||||||
|
this.#serialization,
|
||||||
|
0,
|
||||||
|
this.#schemeEnd + 1, /* : */
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @param {string} value */
|
/** @param {string} value */
|
||||||
|
@ -672,7 +702,9 @@ class URL {
|
||||||
const afterPath = this.#queryStart || this.#fragmentStart ||
|
const afterPath = this.#queryStart || this.#fragmentStart ||
|
||||||
this.#serialization.length;
|
this.#serialization.length;
|
||||||
const afterQuery = this.#fragmentStart || this.#serialization.length;
|
const afterQuery = this.#fragmentStart || this.#serialization.length;
|
||||||
return trim(this.#serialization.slice(afterPath, afterQuery));
|
return trim(
|
||||||
|
StringPrototypeSlice(this.#serialization, afterPath, afterQuery),
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @param {string} value */
|
/** @param {string} value */
|
||||||
|
@ -703,7 +735,8 @@ class URL {
|
||||||
this.#hasAuthority() &&
|
this.#hasAuthority() &&
|
||||||
this.#usernameEnd > this.#schemeEnd + schemeSeperatorLen
|
this.#usernameEnd > this.#schemeEnd + schemeSeperatorLen
|
||||||
) {
|
) {
|
||||||
return this.#serialization.slice(
|
return StringPrototypeSlice(
|
||||||
|
this.#serialization,
|
||||||
this.#schemeEnd + schemeSeperatorLen,
|
this.#schemeEnd + schemeSeperatorLen,
|
||||||
this.#usernameEnd,
|
this.#usernameEnd,
|
||||||
);
|
);
|
||||||
|
|
|
@ -13,8 +13,9 @@ import * as webidl from "ext:deno_webidl/00_webidl.js";
|
||||||
const primordials = globalThis.__bootstrap.primordials;
|
const primordials = globalThis.__bootstrap.primordials;
|
||||||
const {
|
const {
|
||||||
ArrayPrototypeMap,
|
ArrayPrototypeMap,
|
||||||
ObjectKeys,
|
ArrayPrototypePop,
|
||||||
ObjectFromEntries,
|
ObjectFromEntries,
|
||||||
|
ObjectKeys,
|
||||||
RegExpPrototypeExec,
|
RegExpPrototypeExec,
|
||||||
RegExpPrototypeTest,
|
RegExpPrototypeTest,
|
||||||
SafeRegExp,
|
SafeRegExp,
|
||||||
|
@ -178,7 +179,7 @@ class URLPattern {
|
||||||
|
|
||||||
const { 0: values, 1: inputs } = res;
|
const { 0: values, 1: inputs } = res;
|
||||||
if (inputs[1] === null) {
|
if (inputs[1] === null) {
|
||||||
inputs.pop();
|
ArrayPrototypePop(inputs);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @type {URLPatternResult} */
|
/** @type {URLPatternResult} */
|
||||||
|
|
|
@ -19,9 +19,10 @@ import {
|
||||||
const primordials = globalThis.__bootstrap.primordials;
|
const primordials = globalThis.__bootstrap.primordials;
|
||||||
const {
|
const {
|
||||||
ArrayBuffer,
|
ArrayBuffer,
|
||||||
|
ArrayBufferIsView,
|
||||||
ArrayBufferPrototype,
|
ArrayBufferPrototype,
|
||||||
ArrayBufferPrototypeGetByteLength,
|
ArrayBufferPrototypeGetByteLength,
|
||||||
ArrayBufferIsView,
|
ArrayBufferPrototypeSlice,
|
||||||
ArrayPrototypeMap,
|
ArrayPrototypeMap,
|
||||||
ArrayPrototypePush,
|
ArrayPrototypePush,
|
||||||
ArrayPrototypeShift,
|
ArrayPrototypeShift,
|
||||||
|
@ -34,12 +35,12 @@ const {
|
||||||
DataViewPrototypeGetByteOffset,
|
DataViewPrototypeGetByteOffset,
|
||||||
Float32Array,
|
Float32Array,
|
||||||
Float64Array,
|
Float64Array,
|
||||||
Int8Array,
|
|
||||||
Int16Array,
|
Int16Array,
|
||||||
Int32Array,
|
Int32Array,
|
||||||
|
Int8Array,
|
||||||
|
MathMin,
|
||||||
NumberIsInteger,
|
NumberIsInteger,
|
||||||
NumberIsNaN,
|
NumberIsNaN,
|
||||||
MathMin,
|
|
||||||
ObjectCreate,
|
ObjectCreate,
|
||||||
ObjectDefineProperties,
|
ObjectDefineProperties,
|
||||||
ObjectDefineProperty,
|
ObjectDefineProperty,
|
||||||
|
@ -52,14 +53,13 @@ const {
|
||||||
PromisePrototypeThen,
|
PromisePrototypeThen,
|
||||||
PromiseReject,
|
PromiseReject,
|
||||||
PromiseResolve,
|
PromiseResolve,
|
||||||
queueMicrotask,
|
|
||||||
RangeError,
|
RangeError,
|
||||||
ReflectHas,
|
ReflectHas,
|
||||||
SafeFinalizationRegistry,
|
SafeFinalizationRegistry,
|
||||||
SafePromiseAll,
|
SafePromiseAll,
|
||||||
SafeWeakMap,
|
SafeWeakMap,
|
||||||
// TODO(lucacasonato): add SharedArrayBuffer to primordials
|
// TODO(lucacasonato): add SharedArrayBuffer to primordials
|
||||||
// SharedArrayBufferPrototype
|
// SharedArrayBufferPrototype,
|
||||||
Symbol,
|
Symbol,
|
||||||
SymbolAsyncIterator,
|
SymbolAsyncIterator,
|
||||||
SymbolFor,
|
SymbolFor,
|
||||||
|
@ -70,13 +70,14 @@ const {
|
||||||
TypedArrayPrototypeGetSymbolToStringTag,
|
TypedArrayPrototypeGetSymbolToStringTag,
|
||||||
TypedArrayPrototypeSet,
|
TypedArrayPrototypeSet,
|
||||||
TypedArrayPrototypeSlice,
|
TypedArrayPrototypeSlice,
|
||||||
Uint8Array,
|
|
||||||
Uint16Array,
|
Uint16Array,
|
||||||
Uint32Array,
|
Uint32Array,
|
||||||
|
Uint8Array,
|
||||||
Uint8ClampedArray,
|
Uint8ClampedArray,
|
||||||
WeakMapPrototypeGet,
|
WeakMapPrototypeGet,
|
||||||
WeakMapPrototypeHas,
|
WeakMapPrototypeHas,
|
||||||
WeakMapPrototypeSet,
|
WeakMapPrototypeSet,
|
||||||
|
queueMicrotask,
|
||||||
} = primordials;
|
} = primordials;
|
||||||
import { createFilteredInspectProxy } from "ext:deno_console/01_console.js";
|
import { createFilteredInspectProxy } from "ext:deno_console/01_console.js";
|
||||||
import { assert, AssertionError } from "ext:deno_web/00_infra.js";
|
import { assert, AssertionError } from "ext:deno_web/00_infra.js";
|
||||||
|
@ -1252,7 +1253,16 @@ function readableByteStreamControllerEnqueueClonedChunkToQueue(
|
||||||
) {
|
) {
|
||||||
let cloneResult;
|
let cloneResult;
|
||||||
try {
|
try {
|
||||||
cloneResult = buffer.slice(byteOffset, byteOffset + byteLength);
|
if (ObjectPrototypeIsPrototypeOf(ArrayBufferPrototype, buffer)) {
|
||||||
|
cloneResult = ArrayBufferPrototypeSlice(
|
||||||
|
buffer,
|
||||||
|
byteOffset,
|
||||||
|
byteOffset + byteLength,
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
// TODO(lucacasonato): add SharedArrayBuffer to primordials
|
||||||
|
cloneResult = buffer.slice(byteOffset, byteOffset + byteLength);
|
||||||
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
readableByteStreamControllerError(controller, e);
|
readableByteStreamControllerError(controller, e);
|
||||||
}
|
}
|
||||||
|
@ -1864,7 +1874,7 @@ function readableByteStreamControllerPullInto(
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
controller[_pendingPullIntos].push(pullIntoDescriptor);
|
ArrayPrototypePush(controller[_pendingPullIntos], pullIntoDescriptor);
|
||||||
readableStreamAddReadIntoRequest(stream, readIntoRequest);
|
readableStreamAddReadIntoRequest(stream, readIntoRequest);
|
||||||
readableByteStreamControllerCallPullIfNeeded(controller);
|
readableByteStreamControllerCallPullIfNeeded(controller);
|
||||||
}
|
}
|
||||||
|
@ -4481,7 +4491,7 @@ function writableStreamMarkCloseRequestInFlight(stream) {
|
||||||
function writableStreamMarkFirstWriteRequestInFlight(stream) {
|
function writableStreamMarkFirstWriteRequestInFlight(stream) {
|
||||||
assert(stream[_inFlightWriteRequest] === undefined);
|
assert(stream[_inFlightWriteRequest] === undefined);
|
||||||
assert(stream[_writeRequests].length);
|
assert(stream[_writeRequests].length);
|
||||||
const writeRequest = stream[_writeRequests].shift();
|
const writeRequest = ArrayPrototypeShift(stream[_writeRequests]);
|
||||||
stream[_inFlightWriteRequest] = writeRequest;
|
stream[_inFlightWriteRequest] = writeRequest;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -259,7 +259,7 @@ function serializeJsMessageData(data, transferables) {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
j++;
|
j++;
|
||||||
transferredArrayBuffers.push(ab);
|
ArrayPrototypePush(transferredArrayBuffers, ab);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -17,6 +17,7 @@ const primordials = globalThis.__bootstrap.primordials;
|
||||||
const {
|
const {
|
||||||
ArrayPrototypeJoin,
|
ArrayPrototypeJoin,
|
||||||
ArrayPrototypeMap,
|
ArrayPrototypeMap,
|
||||||
|
DateNow,
|
||||||
Error,
|
Error,
|
||||||
ObjectPrototypeIsPrototypeOf,
|
ObjectPrototypeIsPrototypeOf,
|
||||||
PromisePrototypeCatch,
|
PromisePrototypeCatch,
|
||||||
|
@ -27,8 +28,8 @@ const {
|
||||||
StringPrototypeToLowerCase,
|
StringPrototypeToLowerCase,
|
||||||
Symbol,
|
Symbol,
|
||||||
SymbolFor,
|
SymbolFor,
|
||||||
TypedArrayPrototypeGetByteLength,
|
|
||||||
TypeError,
|
TypeError,
|
||||||
|
TypedArrayPrototypeGetByteLength,
|
||||||
Uint8ArrayPrototype,
|
Uint8ArrayPrototype,
|
||||||
} = primordials;
|
} = primordials;
|
||||||
|
|
||||||
|
@ -281,7 +282,7 @@ class WebSocketStream {
|
||||||
this[_closed].state === "pending"
|
this[_closed].state === "pending"
|
||||||
) {
|
) {
|
||||||
if (
|
if (
|
||||||
new Date().getTime() - await this[_closeSent].promise <=
|
DateNow() - await this[_closeSent].promise <=
|
||||||
CLOSE_RESPONSE_TIMEOUT
|
CLOSE_RESPONSE_TIMEOUT
|
||||||
) {
|
) {
|
||||||
return pull(controller);
|
return pull(controller);
|
||||||
|
@ -404,7 +405,7 @@ class WebSocketStream {
|
||||||
core.opAsync("op_ws_close", this[_rid], code, closeInfo.reason),
|
core.opAsync("op_ws_close", this[_rid], code, closeInfo.reason),
|
||||||
() => {
|
() => {
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
this[_closeSent].resolve(new Date().getTime());
|
this[_closeSent].resolve(DateNow());
|
||||||
}, 0);
|
}, 0);
|
||||||
},
|
},
|
||||||
(err) => {
|
(err) => {
|
||||||
|
|
|
@ -4,10 +4,11 @@ const core = globalThis.Deno.core;
|
||||||
const ops = core.ops;
|
const ops = core.ops;
|
||||||
const primordials = globalThis.__bootstrap.primordials;
|
const primordials = globalThis.__bootstrap.primordials;
|
||||||
const {
|
const {
|
||||||
|
ArrayPrototypeFilter,
|
||||||
Error,
|
Error,
|
||||||
ObjectPrototypeIsPrototypeOf,
|
ObjectPrototypeIsPrototypeOf,
|
||||||
StringPrototypeStartsWith,
|
|
||||||
String,
|
String,
|
||||||
|
StringPrototypeStartsWith,
|
||||||
SymbolIterator,
|
SymbolIterator,
|
||||||
SymbolToStringTag,
|
SymbolToStringTag,
|
||||||
} = primordials;
|
} = primordials;
|
||||||
|
@ -192,8 +193,9 @@ class Worker extends EventTarget {
|
||||||
const event = new MessageEvent("message", {
|
const event = new MessageEvent("message", {
|
||||||
cancelable: false,
|
cancelable: false,
|
||||||
data: message,
|
data: message,
|
||||||
ports: transferables.filter((t) =>
|
ports: ArrayPrototypeFilter(
|
||||||
ObjectPrototypeIsPrototypeOf(MessagePortPrototype, t)
|
transferables,
|
||||||
|
(t) => ObjectPrototypeIsPrototypeOf(MessagePortPrototype, t),
|
||||||
),
|
),
|
||||||
});
|
});
|
||||||
this.dispatchEvent(event);
|
this.dispatchEvent(event);
|
||||||
|
|
|
@ -6,10 +6,12 @@ import { Event, EventTarget } from "ext:deno_web/02_event.js";
|
||||||
const primordials = globalThis.__bootstrap.primordials;
|
const primordials = globalThis.__bootstrap.primordials;
|
||||||
const {
|
const {
|
||||||
Error,
|
Error,
|
||||||
|
FunctionPrototypeBind,
|
||||||
SymbolFor,
|
SymbolFor,
|
||||||
} = primordials;
|
} = primordials;
|
||||||
|
|
||||||
const windowDispatchEvent = EventTarget.prototype.dispatchEvent.bind(
|
const windowDispatchEvent = FunctionPrototypeBind(
|
||||||
|
EventTarget.prototype.dispatchEvent,
|
||||||
globalThis,
|
globalThis,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
|
@ -12,27 +12,28 @@ const ops = core.ops;
|
||||||
const internals = globalThis.__bootstrap.internals;
|
const internals = globalThis.__bootstrap.internals;
|
||||||
const primordials = globalThis.__bootstrap.primordials;
|
const primordials = globalThis.__bootstrap.primordials;
|
||||||
const {
|
const {
|
||||||
|
ArrayPrototypeFilter,
|
||||||
ArrayPrototypeIndexOf,
|
ArrayPrototypeIndexOf,
|
||||||
|
ArrayPrototypeMap,
|
||||||
ArrayPrototypePush,
|
ArrayPrototypePush,
|
||||||
ArrayPrototypeShift,
|
ArrayPrototypeShift,
|
||||||
ArrayPrototypeSplice,
|
ArrayPrototypeSplice,
|
||||||
ArrayPrototypeMap,
|
|
||||||
DateNow,
|
DateNow,
|
||||||
Error,
|
Error,
|
||||||
ErrorPrototype,
|
ErrorPrototype,
|
||||||
FunctionPrototypeCall,
|
|
||||||
FunctionPrototypeBind,
|
FunctionPrototypeBind,
|
||||||
|
FunctionPrototypeCall,
|
||||||
ObjectAssign,
|
ObjectAssign,
|
||||||
ObjectDefineProperty,
|
|
||||||
ObjectDefineProperties,
|
ObjectDefineProperties,
|
||||||
|
ObjectDefineProperty,
|
||||||
ObjectFreeze,
|
ObjectFreeze,
|
||||||
ObjectPrototypeIsPrototypeOf,
|
ObjectPrototypeIsPrototypeOf,
|
||||||
ObjectSetPrototypeOf,
|
ObjectSetPrototypeOf,
|
||||||
|
PromisePrototypeThen,
|
||||||
PromiseResolve,
|
PromiseResolve,
|
||||||
|
SafeWeakMap,
|
||||||
Symbol,
|
Symbol,
|
||||||
SymbolIterator,
|
SymbolIterator,
|
||||||
PromisePrototypeThen,
|
|
||||||
SafeWeakMap,
|
|
||||||
TypeError,
|
TypeError,
|
||||||
WeakMapPrototypeDelete,
|
WeakMapPrototypeDelete,
|
||||||
WeakMapPrototypeGet,
|
WeakMapPrototypeGet,
|
||||||
|
@ -147,8 +148,10 @@ async function pollForMessages() {
|
||||||
const msgEvent = new event.MessageEvent("message", {
|
const msgEvent = new event.MessageEvent("message", {
|
||||||
cancelable: false,
|
cancelable: false,
|
||||||
data: message,
|
data: message,
|
||||||
ports: transferables.filter((t) =>
|
ports: ArrayPrototypeFilter(
|
||||||
ObjectPrototypeIsPrototypeOf(messagePort.MessagePortPrototype, t)
|
transferables,
|
||||||
|
(t) =>
|
||||||
|
ObjectPrototypeIsPrototypeOf(messagePort.MessagePortPrototype, t),
|
||||||
),
|
),
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue