You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
651 lines
19 KiB
651 lines
19 KiB
1 month ago
|
"use strict";
|
||
|
var __defProp = Object.defineProperty;
|
||
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
||
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
||
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
||
|
var __commonJS = (cb, mod) => function __require() {
|
||
|
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
||
|
};
|
||
|
var __export = (target, all) => {
|
||
|
for (var name in all)
|
||
|
__defProp(target, name, { get: all[name], enumerable: true });
|
||
|
};
|
||
|
var __copyProps = (to, from, except, desc) => {
|
||
|
if (from && typeof from === "object" || typeof from === "function") {
|
||
|
for (let key of __getOwnPropNames(from))
|
||
|
if (!__hasOwnProp.call(to, key) && key !== except)
|
||
|
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
||
|
}
|
||
|
return to;
|
||
|
};
|
||
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
||
|
|
||
|
// (disabled):util
|
||
|
var require_util = __commonJS({
|
||
|
"(disabled):util"() {
|
||
|
}
|
||
|
});
|
||
|
|
||
|
// src/index.ts
|
||
|
var src_exports = {};
|
||
|
__export(src_exports, {
|
||
|
custom: () => custom,
|
||
|
default: () => src_default,
|
||
|
inspect: () => inspect,
|
||
|
registerConstructor: () => registerConstructor,
|
||
|
registerStringTag: () => registerStringTag
|
||
|
});
|
||
|
module.exports = __toCommonJS(src_exports);
|
||
|
|
||
|
// src/helpers.ts
|
||
|
var ansiColors = {
|
||
|
bold: ["1", "22"],
|
||
|
dim: ["2", "22"],
|
||
|
italic: ["3", "23"],
|
||
|
underline: ["4", "24"],
|
||
|
// 5 & 6 are blinking
|
||
|
inverse: ["7", "27"],
|
||
|
hidden: ["8", "28"],
|
||
|
strike: ["9", "29"],
|
||
|
// 10-20 are fonts
|
||
|
// 21-29 are resets for 1-9
|
||
|
black: ["30", "39"],
|
||
|
red: ["31", "39"],
|
||
|
green: ["32", "39"],
|
||
|
yellow: ["33", "39"],
|
||
|
blue: ["34", "39"],
|
||
|
magenta: ["35", "39"],
|
||
|
cyan: ["36", "39"],
|
||
|
white: ["37", "39"],
|
||
|
brightblack: ["30;1", "39"],
|
||
|
brightred: ["31;1", "39"],
|
||
|
brightgreen: ["32;1", "39"],
|
||
|
brightyellow: ["33;1", "39"],
|
||
|
brightblue: ["34;1", "39"],
|
||
|
brightmagenta: ["35;1", "39"],
|
||
|
brightcyan: ["36;1", "39"],
|
||
|
brightwhite: ["37;1", "39"],
|
||
|
grey: ["90", "39"]
|
||
|
};
|
||
|
var styles = {
|
||
|
special: "cyan",
|
||
|
number: "yellow",
|
||
|
bigint: "yellow",
|
||
|
boolean: "yellow",
|
||
|
undefined: "grey",
|
||
|
null: "bold",
|
||
|
string: "green",
|
||
|
symbol: "green",
|
||
|
date: "magenta",
|
||
|
regexp: "red"
|
||
|
};
|
||
|
var truncator = "\u2026";
|
||
|
function colorise(value, styleType) {
|
||
|
const color = ansiColors[styles[styleType]] || ansiColors[styleType] || "";
|
||
|
if (!color) {
|
||
|
return String(value);
|
||
|
}
|
||
|
return `\x1B[${color[0]}m${String(value)}\x1B[${color[1]}m`;
|
||
|
}
|
||
|
function normaliseOptions({
|
||
|
showHidden = false,
|
||
|
depth = 2,
|
||
|
colors = false,
|
||
|
customInspect = true,
|
||
|
showProxy = false,
|
||
|
maxArrayLength = Infinity,
|
||
|
breakLength = Infinity,
|
||
|
seen = [],
|
||
|
// eslint-disable-next-line no-shadow
|
||
|
truncate: truncate2 = Infinity,
|
||
|
stylize = String
|
||
|
} = {}, inspect2) {
|
||
|
const options = {
|
||
|
showHidden: Boolean(showHidden),
|
||
|
depth: Number(depth),
|
||
|
colors: Boolean(colors),
|
||
|
customInspect: Boolean(customInspect),
|
||
|
showProxy: Boolean(showProxy),
|
||
|
maxArrayLength: Number(maxArrayLength),
|
||
|
breakLength: Number(breakLength),
|
||
|
truncate: Number(truncate2),
|
||
|
seen,
|
||
|
inspect: inspect2,
|
||
|
stylize
|
||
|
};
|
||
|
if (options.colors) {
|
||
|
options.stylize = colorise;
|
||
|
}
|
||
|
return options;
|
||
|
}
|
||
|
function isHighSurrogate(char) {
|
||
|
return char >= "\uD800" && char <= "\uDBFF";
|
||
|
}
|
||
|
function truncate(string, length, tail = truncator) {
|
||
|
string = String(string);
|
||
|
const tailLength = tail.length;
|
||
|
const stringLength = string.length;
|
||
|
if (tailLength > length && stringLength > tailLength) {
|
||
|
return tail;
|
||
|
}
|
||
|
if (stringLength > length && stringLength > tailLength) {
|
||
|
let end = length - tailLength;
|
||
|
if (end > 0 && isHighSurrogate(string[end - 1])) {
|
||
|
end = end - 1;
|
||
|
}
|
||
|
return `${string.slice(0, end)}${tail}`;
|
||
|
}
|
||
|
return string;
|
||
|
}
|
||
|
function inspectList(list, options, inspectItem, separator = ", ") {
|
||
|
inspectItem = inspectItem || options.inspect;
|
||
|
const size = list.length;
|
||
|
if (size === 0)
|
||
|
return "";
|
||
|
const originalLength = options.truncate;
|
||
|
let output = "";
|
||
|
let peek = "";
|
||
|
let truncated = "";
|
||
|
for (let i = 0; i < size; i += 1) {
|
||
|
const last = i + 1 === list.length;
|
||
|
const secondToLast = i + 2 === list.length;
|
||
|
truncated = `${truncator}(${list.length - i})`;
|
||
|
const value = list[i];
|
||
|
options.truncate = originalLength - output.length - (last ? 0 : separator.length);
|
||
|
const string = peek || inspectItem(value, options) + (last ? "" : separator);
|
||
|
const nextLength = output.length + string.length;
|
||
|
const truncatedLength = nextLength + truncated.length;
|
||
|
if (last && nextLength > originalLength && output.length + truncated.length <= originalLength) {
|
||
|
break;
|
||
|
}
|
||
|
if (!last && !secondToLast && truncatedLength > originalLength) {
|
||
|
break;
|
||
|
}
|
||
|
peek = last ? "" : inspectItem(list[i + 1], options) + (secondToLast ? "" : separator);
|
||
|
if (!last && secondToLast && truncatedLength > originalLength && nextLength + peek.length > originalLength) {
|
||
|
break;
|
||
|
}
|
||
|
output += string;
|
||
|
if (!last && !secondToLast && nextLength + peek.length >= originalLength) {
|
||
|
truncated = `${truncator}(${list.length - i - 1})`;
|
||
|
break;
|
||
|
}
|
||
|
truncated = "";
|
||
|
}
|
||
|
return `${output}${truncated}`;
|
||
|
}
|
||
|
function quoteComplexKey(key) {
|
||
|
if (key.match(/^[a-zA-Z_][a-zA-Z_0-9]*$/)) {
|
||
|
return key;
|
||
|
}
|
||
|
return JSON.stringify(key).replace(/'/g, "\\'").replace(/\\"/g, '"').replace(/(^"|"$)/g, "'");
|
||
|
}
|
||
|
function inspectProperty([key, value], options) {
|
||
|
options.truncate -= 2;
|
||
|
if (typeof key === "string") {
|
||
|
key = quoteComplexKey(key);
|
||
|
} else if (typeof key !== "number") {
|
||
|
key = `[${options.inspect(key, options)}]`;
|
||
|
}
|
||
|
options.truncate -= key.length;
|
||
|
value = options.inspect(value, options);
|
||
|
return `${key}: ${value}`;
|
||
|
}
|
||
|
|
||
|
// src/array.ts
|
||
|
function inspectArray(array, options) {
|
||
|
const nonIndexProperties = Object.keys(array).slice(array.length);
|
||
|
if (!array.length && !nonIndexProperties.length)
|
||
|
return "[]";
|
||
|
options.truncate -= 4;
|
||
|
const listContents = inspectList(array, options);
|
||
|
options.truncate -= listContents.length;
|
||
|
let propertyContents = "";
|
||
|
if (nonIndexProperties.length) {
|
||
|
propertyContents = inspectList(
|
||
|
nonIndexProperties.map((key) => [key, array[key]]),
|
||
|
options,
|
||
|
inspectProperty
|
||
|
);
|
||
|
}
|
||
|
return `[ ${listContents}${propertyContents ? `, ${propertyContents}` : ""} ]`;
|
||
|
}
|
||
|
|
||
|
// src/typedarray.ts
|
||
|
var getArrayName = (array) => {
|
||
|
if (typeof Buffer === "function" && array instanceof Buffer) {
|
||
|
return "Buffer";
|
||
|
}
|
||
|
if (array[Symbol.toStringTag]) {
|
||
|
return array[Symbol.toStringTag];
|
||
|
}
|
||
|
return array.constructor.name;
|
||
|
};
|
||
|
function inspectTypedArray(array, options) {
|
||
|
const name = getArrayName(array);
|
||
|
options.truncate -= name.length + 4;
|
||
|
const nonIndexProperties = Object.keys(array).slice(array.length);
|
||
|
if (!array.length && !nonIndexProperties.length)
|
||
|
return `${name}[]`;
|
||
|
let output = "";
|
||
|
for (let i = 0; i < array.length; i++) {
|
||
|
const string = `${options.stylize(truncate(array[i], options.truncate), "number")}${i === array.length - 1 ? "" : ", "}`;
|
||
|
options.truncate -= string.length;
|
||
|
if (array[i] !== array.length && options.truncate <= 3) {
|
||
|
output += `${truncator}(${array.length - array[i] + 1})`;
|
||
|
break;
|
||
|
}
|
||
|
output += string;
|
||
|
}
|
||
|
let propertyContents = "";
|
||
|
if (nonIndexProperties.length) {
|
||
|
propertyContents = inspectList(
|
||
|
nonIndexProperties.map((key) => [key, array[key]]),
|
||
|
options,
|
||
|
inspectProperty
|
||
|
);
|
||
|
}
|
||
|
return `${name}[ ${output}${propertyContents ? `, ${propertyContents}` : ""} ]`;
|
||
|
}
|
||
|
|
||
|
// src/date.ts
|
||
|
function inspectDate(dateObject, options) {
|
||
|
const stringRepresentation = dateObject.toJSON();
|
||
|
if (stringRepresentation === null) {
|
||
|
return "Invalid Date";
|
||
|
}
|
||
|
const split = stringRepresentation.split("T");
|
||
|
const date = split[0];
|
||
|
return options.stylize(`${date}T${truncate(split[1], options.truncate - date.length - 1)}`, "date");
|
||
|
}
|
||
|
|
||
|
// src/function.ts
|
||
|
function inspectFunction(func, options) {
|
||
|
const functionType = func[Symbol.toStringTag] || "Function";
|
||
|
const name = func.name;
|
||
|
if (!name) {
|
||
|
return options.stylize(`[${functionType}]`, "special");
|
||
|
}
|
||
|
return options.stylize(`[${functionType} ${truncate(name, options.truncate - 11)}]`, "special");
|
||
|
}
|
||
|
|
||
|
// src/map.ts
|
||
|
function inspectMapEntry([key, value], options) {
|
||
|
options.truncate -= 4;
|
||
|
key = options.inspect(key, options);
|
||
|
options.truncate -= key.length;
|
||
|
value = options.inspect(value, options);
|
||
|
return `${key} => ${value}`;
|
||
|
}
|
||
|
function mapToEntries(map) {
|
||
|
const entries = [];
|
||
|
map.forEach((value, key) => {
|
||
|
entries.push([key, value]);
|
||
|
});
|
||
|
return entries;
|
||
|
}
|
||
|
function inspectMap(map, options) {
|
||
|
const size = map.size - 1;
|
||
|
if (size <= 0) {
|
||
|
return "Map{}";
|
||
|
}
|
||
|
options.truncate -= 7;
|
||
|
return `Map{ ${inspectList(mapToEntries(map), options, inspectMapEntry)} }`;
|
||
|
}
|
||
|
|
||
|
// src/number.ts
|
||
|
var isNaN = Number.isNaN || ((i) => i !== i);
|
||
|
function inspectNumber(number, options) {
|
||
|
if (isNaN(number)) {
|
||
|
return options.stylize("NaN", "number");
|
||
|
}
|
||
|
if (number === Infinity) {
|
||
|
return options.stylize("Infinity", "number");
|
||
|
}
|
||
|
if (number === -Infinity) {
|
||
|
return options.stylize("-Infinity", "number");
|
||
|
}
|
||
|
if (number === 0) {
|
||
|
return options.stylize(1 / number === Infinity ? "+0" : "-0", "number");
|
||
|
}
|
||
|
return options.stylize(truncate(String(number), options.truncate), "number");
|
||
|
}
|
||
|
|
||
|
// src/bigint.ts
|
||
|
function inspectBigInt(number, options) {
|
||
|
let nums = truncate(number.toString(), options.truncate - 1);
|
||
|
if (nums !== truncator)
|
||
|
nums += "n";
|
||
|
return options.stylize(nums, "bigint");
|
||
|
}
|
||
|
|
||
|
// src/regexp.ts
|
||
|
function inspectRegExp(value, options) {
|
||
|
const flags = value.toString().split("/")[2];
|
||
|
const sourceLength = options.truncate - (2 + flags.length);
|
||
|
const source = value.source;
|
||
|
return options.stylize(`/${truncate(source, sourceLength)}/${flags}`, "regexp");
|
||
|
}
|
||
|
|
||
|
// src/set.ts
|
||
|
function arrayFromSet(set) {
|
||
|
const values = [];
|
||
|
set.forEach((value) => {
|
||
|
values.push(value);
|
||
|
});
|
||
|
return values;
|
||
|
}
|
||
|
function inspectSet(set, options) {
|
||
|
if (set.size === 0)
|
||
|
return "Set{}";
|
||
|
options.truncate -= 7;
|
||
|
return `Set{ ${inspectList(arrayFromSet(set), options)} }`;
|
||
|
}
|
||
|
|
||
|
// src/string.ts
|
||
|
var stringEscapeChars = new RegExp(
|
||
|
"['\\u0000-\\u001f\\u007f-\\u009f\\u00ad\\u0600-\\u0604\\u070f\\u17b4\\u17b5\\u200c-\\u200f\\u2028-\\u202f\\u2060-\\u206f\\ufeff\\ufff0-\\uffff]",
|
||
|
"g"
|
||
|
);
|
||
|
var escapeCharacters = {
|
||
|
"\b": "\\b",
|
||
|
" ": "\\t",
|
||
|
"\n": "\\n",
|
||
|
"\f": "\\f",
|
||
|
"\r": "\\r",
|
||
|
"'": "\\'",
|
||
|
"\\": "\\\\"
|
||
|
};
|
||
|
var hex = 16;
|
||
|
var unicodeLength = 4;
|
||
|
function escape(char) {
|
||
|
return escapeCharacters[char] || `\\u${`0000${char.charCodeAt(0).toString(hex)}`.slice(-unicodeLength)}`;
|
||
|
}
|
||
|
function inspectString(string, options) {
|
||
|
if (stringEscapeChars.test(string)) {
|
||
|
string = string.replace(stringEscapeChars, escape);
|
||
|
}
|
||
|
return options.stylize(`'${truncate(string, options.truncate - 2)}'`, "string");
|
||
|
}
|
||
|
|
||
|
// src/symbol.ts
|
||
|
function inspectSymbol(value) {
|
||
|
if ("description" in Symbol.prototype) {
|
||
|
return value.description ? `Symbol(${value.description})` : "Symbol()";
|
||
|
}
|
||
|
return value.toString();
|
||
|
}
|
||
|
|
||
|
// src/promise.ts
|
||
|
var getPromiseValue = () => "Promise{\u2026}";
|
||
|
try {
|
||
|
const { getPromiseDetails, kPending, kRejected } = process.binding("util");
|
||
|
if (Array.isArray(getPromiseDetails(Promise.resolve()))) {
|
||
|
getPromiseValue = (value, options) => {
|
||
|
const [state, innerValue] = getPromiseDetails(value);
|
||
|
if (state === kPending) {
|
||
|
return "Promise{<pending>}";
|
||
|
}
|
||
|
return `Promise${state === kRejected ? "!" : ""}{${options.inspect(innerValue, options)}}`;
|
||
|
};
|
||
|
}
|
||
|
} catch (notNode) {
|
||
|
}
|
||
|
var promise_default = getPromiseValue;
|
||
|
|
||
|
// src/object.ts
|
||
|
function inspectObject(object, options) {
|
||
|
const properties = Object.getOwnPropertyNames(object);
|
||
|
const symbols = Object.getOwnPropertySymbols ? Object.getOwnPropertySymbols(object) : [];
|
||
|
if (properties.length === 0 && symbols.length === 0) {
|
||
|
return "{}";
|
||
|
}
|
||
|
options.truncate -= 4;
|
||
|
options.seen = options.seen || [];
|
||
|
if (options.seen.includes(object)) {
|
||
|
return "[Circular]";
|
||
|
}
|
||
|
options.seen.push(object);
|
||
|
const propertyContents = inspectList(
|
||
|
properties.map((key) => [key, object[key]]),
|
||
|
options,
|
||
|
inspectProperty
|
||
|
);
|
||
|
const symbolContents = inspectList(
|
||
|
symbols.map((key) => [key, object[key]]),
|
||
|
options,
|
||
|
inspectProperty
|
||
|
);
|
||
|
options.seen.pop();
|
||
|
let sep = "";
|
||
|
if (propertyContents && symbolContents) {
|
||
|
sep = ", ";
|
||
|
}
|
||
|
return `{ ${propertyContents}${sep}${symbolContents} }`;
|
||
|
}
|
||
|
|
||
|
// src/class.ts
|
||
|
var toStringTag = typeof Symbol !== "undefined" && Symbol.toStringTag ? Symbol.toStringTag : false;
|
||
|
function inspectClass(value, options) {
|
||
|
let name = "";
|
||
|
if (toStringTag && toStringTag in value) {
|
||
|
name = value[toStringTag];
|
||
|
}
|
||
|
name = name || value.constructor.name;
|
||
|
if (!name || name === "_class") {
|
||
|
name = "<Anonymous Class>";
|
||
|
}
|
||
|
options.truncate -= name.length;
|
||
|
return `${name}${inspectObject(value, options)}`;
|
||
|
}
|
||
|
|
||
|
// src/arguments.ts
|
||
|
function inspectArguments(args, options) {
|
||
|
if (args.length === 0)
|
||
|
return "Arguments[]";
|
||
|
options.truncate -= 13;
|
||
|
return `Arguments[ ${inspectList(args, options)} ]`;
|
||
|
}
|
||
|
|
||
|
// src/error.ts
|
||
|
var errorKeys = [
|
||
|
"stack",
|
||
|
"line",
|
||
|
"column",
|
||
|
"name",
|
||
|
"message",
|
||
|
"fileName",
|
||
|
"lineNumber",
|
||
|
"columnNumber",
|
||
|
"number",
|
||
|
"description",
|
||
|
"cause"
|
||
|
];
|
||
|
function inspectObject2(error, options) {
|
||
|
const properties = Object.getOwnPropertyNames(error).filter((key) => errorKeys.indexOf(key) === -1);
|
||
|
const name = error.name;
|
||
|
options.truncate -= name.length;
|
||
|
let message = "";
|
||
|
if (typeof error.message === "string") {
|
||
|
message = truncate(error.message, options.truncate);
|
||
|
} else {
|
||
|
properties.unshift("message");
|
||
|
}
|
||
|
message = message ? `: ${message}` : "";
|
||
|
options.truncate -= message.length + 5;
|
||
|
options.seen = options.seen || [];
|
||
|
if (options.seen.includes(error)) {
|
||
|
return "[Circular]";
|
||
|
}
|
||
|
options.seen.push(error);
|
||
|
const propertyContents = inspectList(
|
||
|
properties.map((key) => [key, error[key]]),
|
||
|
options,
|
||
|
inspectProperty
|
||
|
);
|
||
|
return `${name}${message}${propertyContents ? ` { ${propertyContents} }` : ""}`;
|
||
|
}
|
||
|
|
||
|
// src/html.ts
|
||
|
function inspectAttribute([key, value], options) {
|
||
|
options.truncate -= 3;
|
||
|
if (!value) {
|
||
|
return `${options.stylize(String(key), "yellow")}`;
|
||
|
}
|
||
|
return `${options.stylize(String(key), "yellow")}=${options.stylize(`"${value}"`, "string")}`;
|
||
|
}
|
||
|
function inspectHTMLCollection(collection, options) {
|
||
|
return inspectList(collection, options, inspectHTML, "\n");
|
||
|
}
|
||
|
function inspectHTML(element, options) {
|
||
|
const properties = element.getAttributeNames();
|
||
|
const name = element.tagName.toLowerCase();
|
||
|
const head = options.stylize(`<${name}`, "special");
|
||
|
const headClose = options.stylize(`>`, "special");
|
||
|
const tail = options.stylize(`</${name}>`, "special");
|
||
|
options.truncate -= name.length * 2 + 5;
|
||
|
let propertyContents = "";
|
||
|
if (properties.length > 0) {
|
||
|
propertyContents += " ";
|
||
|
propertyContents += inspectList(
|
||
|
properties.map((key) => [key, element.getAttribute(key)]),
|
||
|
options,
|
||
|
inspectAttribute,
|
||
|
" "
|
||
|
);
|
||
|
}
|
||
|
options.truncate -= propertyContents.length;
|
||
|
const truncate2 = options.truncate;
|
||
|
let children = inspectHTMLCollection(element.children, options);
|
||
|
if (children && children.length > truncate2) {
|
||
|
children = `${truncator}(${element.children.length})`;
|
||
|
}
|
||
|
return `${head}${propertyContents}${headClose}${children}${tail}`;
|
||
|
}
|
||
|
|
||
|
// src/index.ts
|
||
|
var symbolsSupported = typeof Symbol === "function" && typeof Symbol.for === "function";
|
||
|
var chaiInspect = symbolsSupported ? Symbol.for("chai/inspect") : "@@chai/inspect";
|
||
|
var nodeInspect = false;
|
||
|
try {
|
||
|
const nodeUtil = require_util();
|
||
|
nodeInspect = nodeUtil.inspect ? nodeUtil.inspect.custom : false;
|
||
|
} catch (noNodeInspect) {
|
||
|
nodeInspect = false;
|
||
|
}
|
||
|
var constructorMap = /* @__PURE__ */ new WeakMap();
|
||
|
var stringTagMap = {};
|
||
|
var baseTypesMap = {
|
||
|
undefined: (value, options) => options.stylize("undefined", "undefined"),
|
||
|
null: (value, options) => options.stylize("null", "null"),
|
||
|
boolean: (value, options) => options.stylize(String(value), "boolean"),
|
||
|
Boolean: (value, options) => options.stylize(String(value), "boolean"),
|
||
|
number: inspectNumber,
|
||
|
Number: inspectNumber,
|
||
|
bigint: inspectBigInt,
|
||
|
BigInt: inspectBigInt,
|
||
|
string: inspectString,
|
||
|
String: inspectString,
|
||
|
function: inspectFunction,
|
||
|
Function: inspectFunction,
|
||
|
symbol: inspectSymbol,
|
||
|
// A Symbol polyfill will return `Symbol` not `symbol` from typedetect
|
||
|
Symbol: inspectSymbol,
|
||
|
Array: inspectArray,
|
||
|
Date: inspectDate,
|
||
|
Map: inspectMap,
|
||
|
Set: inspectSet,
|
||
|
RegExp: inspectRegExp,
|
||
|
Promise: promise_default,
|
||
|
// WeakSet, WeakMap are totally opaque to us
|
||
|
WeakSet: (value, options) => options.stylize("WeakSet{\u2026}", "special"),
|
||
|
WeakMap: (value, options) => options.stylize("WeakMap{\u2026}", "special"),
|
||
|
Arguments: inspectArguments,
|
||
|
Int8Array: inspectTypedArray,
|
||
|
Uint8Array: inspectTypedArray,
|
||
|
Uint8ClampedArray: inspectTypedArray,
|
||
|
Int16Array: inspectTypedArray,
|
||
|
Uint16Array: inspectTypedArray,
|
||
|
Int32Array: inspectTypedArray,
|
||
|
Uint32Array: inspectTypedArray,
|
||
|
Float32Array: inspectTypedArray,
|
||
|
Float64Array: inspectTypedArray,
|
||
|
Generator: () => "",
|
||
|
DataView: () => "",
|
||
|
ArrayBuffer: () => "",
|
||
|
Error: inspectObject2,
|
||
|
HTMLCollection: inspectHTMLCollection,
|
||
|
NodeList: inspectHTMLCollection
|
||
|
};
|
||
|
var inspectCustom = (value, options, type) => {
|
||
|
if (chaiInspect in value && typeof value[chaiInspect] === "function") {
|
||
|
return value[chaiInspect](options);
|
||
|
}
|
||
|
if (nodeInspect && nodeInspect in value && typeof value[nodeInspect] === "function") {
|
||
|
return value[nodeInspect](options.depth, options);
|
||
|
}
|
||
|
if ("inspect" in value && typeof value.inspect === "function") {
|
||
|
return value.inspect(options.depth, options);
|
||
|
}
|
||
|
if ("constructor" in value && constructorMap.has(value.constructor)) {
|
||
|
return constructorMap.get(value.constructor)(value, options);
|
||
|
}
|
||
|
if (stringTagMap[type]) {
|
||
|
return stringTagMap[type](value, options);
|
||
|
}
|
||
|
return "";
|
||
|
};
|
||
|
var toString = Object.prototype.toString;
|
||
|
function inspect(value, opts = {}) {
|
||
|
const options = normaliseOptions(opts, inspect);
|
||
|
const { customInspect } = options;
|
||
|
let type = value === null ? "null" : typeof value;
|
||
|
if (type === "object") {
|
||
|
type = toString.call(value).slice(8, -1);
|
||
|
}
|
||
|
if (type in baseTypesMap) {
|
||
|
return baseTypesMap[type](value, options);
|
||
|
}
|
||
|
if (customInspect && value) {
|
||
|
const output = inspectCustom(value, options, type);
|
||
|
if (output) {
|
||
|
if (typeof output === "string")
|
||
|
return output;
|
||
|
return inspect(output, options);
|
||
|
}
|
||
|
}
|
||
|
const proto = value ? Object.getPrototypeOf(value) : false;
|
||
|
if (proto === Object.prototype || proto === null) {
|
||
|
return inspectObject(value, options);
|
||
|
}
|
||
|
if (value && typeof HTMLElement === "function" && value instanceof HTMLElement) {
|
||
|
return inspectHTML(value, options);
|
||
|
}
|
||
|
if ("constructor" in value) {
|
||
|
if (value.constructor !== Object) {
|
||
|
return inspectClass(value, options);
|
||
|
}
|
||
|
return inspectObject(value, options);
|
||
|
}
|
||
|
if (value === Object(value)) {
|
||
|
return inspectObject(value, options);
|
||
|
}
|
||
|
return options.stylize(String(value), type);
|
||
|
}
|
||
|
function registerConstructor(constructor, inspector) {
|
||
|
if (constructorMap.has(constructor)) {
|
||
|
return false;
|
||
|
}
|
||
|
constructorMap.set(constructor, inspector);
|
||
|
return true;
|
||
|
}
|
||
|
function registerStringTag(stringTag, inspector) {
|
||
|
if (stringTag in stringTagMap) {
|
||
|
return false;
|
||
|
}
|
||
|
stringTagMap[stringTag] = inspector;
|
||
|
return true;
|
||
|
}
|
||
|
var custom = chaiInspect;
|
||
|
var src_default = inspect;
|