UNPKG

botframework-streaming

Version:

Streaming library for the Microsoft Bot Framework

1,525 lines (1,484 loc) 137 kB
var __defProp = Object.defineProperty; var __getOwnPropNames = Object.getOwnPropertyNames; var __name = (target, value) => __defProp(target, "name", { value, configurable: true }); 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 }); }; // (disabled):util var require_util = __commonJS({ "(disabled):util"() { } }); // lib/chai/utils/index.js var utils_exports = {}; __export(utils_exports, { addChainableMethod: () => addChainableMethod, addLengthGuard: () => addLengthGuard, addMethod: () => addMethod, addProperty: () => addProperty, checkError: () => check_error_exports, compareByInspect: () => compareByInspect, eql: () => deep_eql_default, expectTypes: () => expectTypes, flag: () => flag, getActual: () => getActual, getMessage: () => getMessage2, getName: () => getName, getOperator: () => getOperator, getOwnEnumerableProperties: () => getOwnEnumerableProperties, getOwnEnumerablePropertySymbols: () => getOwnEnumerablePropertySymbols, getPathInfo: () => getPathInfo, hasProperty: () => hasProperty, inspect: () => inspect2, isNaN: () => isNaN2, isNumeric: () => isNumeric, isProxyEnabled: () => isProxyEnabled, isRegExp: () => isRegExp2, objDisplay: () => objDisplay, overwriteChainableMethod: () => overwriteChainableMethod, overwriteMethod: () => overwriteMethod, overwriteProperty: () => overwriteProperty, proxify: () => proxify, test: () => test, transferFlags: () => transferFlags, type: () => type }); // node_modules/check-error/index.js var check_error_exports = {}; __export(check_error_exports, { compatibleConstructor: () => compatibleConstructor, compatibleInstance: () => compatibleInstance, compatibleMessage: () => compatibleMessage, getConstructorName: () => getConstructorName, getMessage: () => getMessage }); function isErrorInstance(obj) { return obj instanceof Error || Object.prototype.toString.call(obj) === "[object Error]"; } __name(isErrorInstance, "isErrorInstance"); function isRegExp(obj) { return Object.prototype.toString.call(obj) === "[object RegExp]"; } __name(isRegExp, "isRegExp"); function compatibleInstance(thrown, errorLike) { return isErrorInstance(errorLike) && thrown === errorLike; } __name(compatibleInstance, "compatibleInstance"); function compatibleConstructor(thrown, errorLike) { if (isErrorInstance(errorLike)) { return thrown.constructor === errorLike.constructor || thrown instanceof errorLike.constructor; } else if ((typeof errorLike === "object" || typeof errorLike === "function") && errorLike.prototype) { return thrown.constructor === errorLike || thrown instanceof errorLike; } return false; } __name(compatibleConstructor, "compatibleConstructor"); function compatibleMessage(thrown, errMatcher) { const comparisonString = typeof thrown === "string" ? thrown : thrown.message; if (isRegExp(errMatcher)) { return errMatcher.test(comparisonString); } else if (typeof errMatcher === "string") { return comparisonString.indexOf(errMatcher) !== -1; } return false; } __name(compatibleMessage, "compatibleMessage"); function getConstructorName(errorLike) { let constructorName = errorLike; if (isErrorInstance(errorLike)) { constructorName = errorLike.constructor.name; } else if (typeof errorLike === "function") { constructorName = errorLike.name; if (constructorName === "") { const newConstructorName = new errorLike().name; constructorName = newConstructorName || constructorName; } } return constructorName; } __name(getConstructorName, "getConstructorName"); function getMessage(errorLike) { let msg = ""; if (errorLike && errorLike.message) { msg = errorLike.message; } else if (typeof errorLike === "string") { msg = errorLike; } return msg; } __name(getMessage, "getMessage"); // lib/chai/utils/flag.js function flag(obj, key, value) { var flags = obj.__flags || (obj.__flags = /* @__PURE__ */ Object.create(null)); if (arguments.length === 3) { flags[key] = value; } else { return flags[key]; } } __name(flag, "flag"); // lib/chai/utils/test.js function test(obj, args) { var negate = flag(obj, "negate"), expr = args[0]; return negate ? !expr : expr; } __name(test, "test"); // lib/chai/utils/type-detect.js function type(obj) { if (typeof obj === "undefined") { return "undefined"; } if (obj === null) { return "null"; } const stringTag = obj[Symbol.toStringTag]; if (typeof stringTag === "string") { return stringTag; } const type3 = Object.prototype.toString.call(obj).slice(8, -1); return type3; } __name(type, "type"); // node_modules/assertion-error/index.js var canElideFrames = "captureStackTrace" in Error; var AssertionError = class _AssertionError extends Error { static { __name(this, "AssertionError"); } message; get name() { return "AssertionError"; } get ok() { return false; } constructor(message = "Unspecified AssertionError", props, ssf) { super(message); this.message = message; if (canElideFrames) { Error.captureStackTrace(this, ssf || _AssertionError); } for (const key in props) { if (!(key in this)) { this[key] = props[key]; } } } toJSON(stack) { return { ...this, name: this.name, message: this.message, ok: false, stack: stack !== false ? this.stack : void 0 }; } }; // lib/chai/utils/expectTypes.js function expectTypes(obj, types) { var flagMsg = flag(obj, "message"); var ssfi = flag(obj, "ssfi"); flagMsg = flagMsg ? flagMsg + ": " : ""; obj = flag(obj, "object"); types = types.map(function(t) { return t.toLowerCase(); }); types.sort(); var str = types.map(function(t, index) { var art = ~["a", "e", "i", "o", "u"].indexOf(t.charAt(0)) ? "an" : "a"; var or = types.length > 1 && index === types.length - 1 ? "or " : ""; return or + art + " " + t; }).join(", "); var objType = type(obj).toLowerCase(); if (!types.some(function(expected) { return objType === expected; })) { throw new AssertionError( flagMsg + "object tested must be " + str + ", but " + objType + " given", void 0, ssfi ); } } __name(expectTypes, "expectTypes"); // lib/chai/utils/getActual.js function getActual(obj, args) { return args.length > 4 ? args[4] : obj._obj; } __name(getActual, "getActual"); // node_modules/loupe/lib/helpers.js 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`; } __name(colorise, "colorise"); 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 } = {}, inspect3) { 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: inspect3, stylize }; if (options.colors) { options.stylize = colorise; } return options; } __name(normaliseOptions, "normaliseOptions"); function isHighSurrogate(char) { return char >= "\uD800" && char <= "\uDBFF"; } __name(isHighSurrogate, "isHighSurrogate"); 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; } __name(truncate, "truncate"); 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}`; } __name(inspectList, "inspectList"); 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, "'"); } __name(quoteComplexKey, "quoteComplexKey"); 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}`; } __name(inspectProperty, "inspectProperty"); // node_modules/loupe/lib/array.js 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}` : ""} ]`; } __name(inspectArray, "inspectArray"); // node_modules/loupe/lib/typedarray.js var getArrayName = /* @__PURE__ */ __name((array) => { if (typeof Buffer === "function" && array instanceof Buffer) { return "Buffer"; } if (array[Symbol.toStringTag]) { return array[Symbol.toStringTag]; } return array.constructor.name; }, "getArrayName"); 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}` : ""} ]`; } __name(inspectTypedArray, "inspectTypedArray"); // node_modules/loupe/lib/date.js 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"); } __name(inspectDate, "inspectDate"); // node_modules/loupe/lib/function.js 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"); } __name(inspectFunction, "inspectFunction"); // node_modules/loupe/lib/map.js 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}`; } __name(inspectMapEntry, "inspectMapEntry"); function mapToEntries(map) { const entries = []; map.forEach((value, key) => { entries.push([key, value]); }); return entries; } __name(mapToEntries, "mapToEntries"); function inspectMap(map, options) { const size = map.size - 1; if (size <= 0) { return "Map{}"; } options.truncate -= 7; return `Map{ ${inspectList(mapToEntries(map), options, inspectMapEntry)} }`; } __name(inspectMap, "inspectMap"); // node_modules/loupe/lib/number.js 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"); } __name(inspectNumber, "inspectNumber"); // node_modules/loupe/lib/bigint.js function inspectBigInt(number, options) { let nums = truncate(number.toString(), options.truncate - 1); if (nums !== truncator) nums += "n"; return options.stylize(nums, "bigint"); } __name(inspectBigInt, "inspectBigInt"); // node_modules/loupe/lib/regexp.js 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"); } __name(inspectRegExp, "inspectRegExp"); // node_modules/loupe/lib/set.js function arrayFromSet(set2) { const values = []; set2.forEach((value) => { values.push(value); }); return values; } __name(arrayFromSet, "arrayFromSet"); function inspectSet(set2, options) { if (set2.size === 0) return "Set{}"; options.truncate -= 7; return `Set{ ${inspectList(arrayFromSet(set2), options)} }`; } __name(inspectSet, "inspectSet"); // node_modules/loupe/lib/string.js 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)}`; } __name(escape, "escape"); function inspectString(string, options) { if (stringEscapeChars.test(string)) { string = string.replace(stringEscapeChars, escape); } return options.stylize(`'${truncate(string, options.truncate - 2)}'`, "string"); } __name(inspectString, "inspectString"); // node_modules/loupe/lib/symbol.js function inspectSymbol(value) { if ("description" in Symbol.prototype) { return value.description ? `Symbol(${value.description})` : "Symbol()"; } return value.toString(); } __name(inspectSymbol, "inspectSymbol"); // node_modules/loupe/lib/promise.js var getPromiseValue = /* @__PURE__ */ __name(() => "Promise{\u2026}", "getPromiseValue"); try { const { getPromiseDetails, kPending, kRejected } = process.binding("util"); if (Array.isArray(getPromiseDetails(Promise.resolve()))) { getPromiseValue = /* @__PURE__ */ __name((value, options) => { const [state, innerValue] = getPromiseDetails(value); if (state === kPending) { return "Promise{<pending>}"; } return `Promise${state === kRejected ? "!" : ""}{${options.inspect(innerValue, options)}}`; }, "getPromiseValue"); } } catch (notNode) { } var promise_default = getPromiseValue; // node_modules/loupe/lib/object.js 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} }`; } __name(inspectObject, "inspectObject"); // node_modules/loupe/lib/class.js 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)}`; } __name(inspectClass, "inspectClass"); // node_modules/loupe/lib/arguments.js function inspectArguments(args, options) { if (args.length === 0) return "Arguments[]"; options.truncate -= 13; return `Arguments[ ${inspectList(args, options)} ]`; } __name(inspectArguments, "inspectArguments"); // node_modules/loupe/lib/error.js 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} }` : ""}`; } __name(inspectObject2, "inspectObject"); // node_modules/loupe/lib/html.js 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")}`; } __name(inspectAttribute, "inspectAttribute"); function inspectHTMLCollection(collection, options) { return inspectList(collection, options, inspectHTML, "\n"); } __name(inspectHTMLCollection, "inspectHTMLCollection"); 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}`; } __name(inspectHTML, "inspectHTML"); // node_modules/loupe/lib/index.js 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 = /* @__PURE__ */ __name((value, options, type3) => { 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[type3]) { return stringTagMap[type3](value, options); } return ""; }, "inspectCustom"); var toString = Object.prototype.toString; function inspect(value, opts = {}) { const options = normaliseOptions(opts, inspect); const { customInspect } = options; let type3 = value === null ? "null" : typeof value; if (type3 === "object") { type3 = toString.call(value).slice(8, -1); } if (type3 in baseTypesMap) { return baseTypesMap[type3](value, options); } if (customInspect && value) { const output = inspectCustom(value, options, type3); 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), type3); } __name(inspect, "inspect"); // lib/chai/config.js var config = { /** * ### config.includeStack * * User configurable property, influences whether stack trace * is included in Assertion error message. Default of false * suppresses stack trace in the error message. * * chai.config.includeStack = true; // enable stack on error * * @param {boolean} * @public */ includeStack: false, /** * ### config.showDiff * * User configurable property, influences whether or not * the `showDiff` flag should be included in the thrown * AssertionErrors. `false` will always be `false`; `true` * will be true when the assertion has requested a diff * be shown. * * @param {boolean} * @public */ showDiff: true, /** * ### config.truncateThreshold * * User configurable property, sets length threshold for actual and * expected values in assertion errors. If this threshold is exceeded, for * example for large data structures, the value is replaced with something * like `[ Array(3) ]` or `{ Object (prop1, prop2) }`. * * Set it to zero if you want to disable truncating altogether. * * This is especially userful when doing assertions on arrays: having this * set to a reasonable large value makes the failure messages readily * inspectable. * * chai.config.truncateThreshold = 0; // disable truncating * * @param {number} * @public */ truncateThreshold: 40, /** * ### config.useProxy * * User configurable property, defines if chai will use a Proxy to throw * an error when a non-existent property is read, which protects users * from typos when using property-based assertions. * * Set it to false if you want to disable this feature. * * chai.config.useProxy = false; // disable use of Proxy * * This feature is automatically disabled regardless of this config value * in environments that don't support proxies. * * @param {boolean} * @public */ useProxy: true, /** * ### config.proxyExcludedKeys * * User configurable property, defines which properties should be ignored * instead of throwing an error if they do not exist on the assertion. * This is only applied if the environment Chai is running in supports proxies and * if the `useProxy` configuration setting is enabled. * By default, `then` and `inspect` will not throw an error if they do not exist on the * assertion object because the `.inspect` property is read by `util.inspect` (for example, when * using `console.log` on the assertion object) and `.then` is necessary for promise type-checking. * * // By default these keys will not throw an error if they do not exist on the assertion object * chai.config.proxyExcludedKeys = ['then', 'inspect']; * * @param {Array} * @public */ proxyExcludedKeys: ["then", "catch", "inspect", "toJSON"], /** * ### config.deepEqual * * User configurable property, defines which a custom function to use for deepEqual * comparisons. * By default, the function used is the one from the `deep-eql` package without custom comparator. * * // use a custom comparator * chai.config.deepEqual = (expected, actual) => { * return chai.util.eql(expected, actual, { * comparator: (expected, actual) => { * // for non number comparison, use the default behavior * if(typeof expected !== 'number') return null; * // allow a difference of 10 between compared numbers * return typeof actual === 'number' && Math.abs(actual - expected) < 10 * } * }) * }; * * @param {Function} * @public */ deepEqual: null }; // lib/chai/utils/inspect.js function inspect2(obj, showHidden, depth, colors) { var options = { colors, depth: typeof depth === "undefined" ? 2 : depth, showHidden, truncate: config.truncateThreshold ? config.truncateThreshold : Infinity }; return inspect(obj, options); } __name(inspect2, "inspect"); // lib/chai/utils/objDisplay.js function objDisplay(obj) { var str = inspect2(obj), type3 = Object.prototype.toString.call(obj); if (config.truncateThreshold && str.length >= config.truncateThreshold) { if (type3 === "[object Function]") { return !obj.name || obj.name === "" ? "[Function]" : "[Function: " + obj.name + "]"; } else if (type3 === "[object Array]") { return "[ Array(" + obj.length + ") ]"; } else if (type3 === "[object Object]") { var keys = Object.keys(obj), kstr = keys.length > 2 ? keys.splice(0, 2).join(", ") + ", ..." : keys.join(", "); return "{ Object (" + kstr + ") }"; } else { return str; } } else { return str; } } __name(objDisplay, "objDisplay"); // lib/chai/utils/getMessage.js function getMessage2(obj, args) { var negate = flag(obj, "negate"), val = flag(obj, "object"), expected = args[3], actual = getActual(obj, args), msg = negate ? args[2] : args[1], flagMsg = flag(obj, "message"); if (typeof msg === "function") msg = msg(); msg = msg || ""; msg = msg.replace(/#\{this\}/g, function() { return objDisplay(val); }).replace(/#\{act\}/g, function() { return objDisplay(actual); }).replace(/#\{exp\}/g, function() { return objDisplay(expected); }); return flagMsg ? flagMsg + ": " + msg : msg; } __name(getMessage2, "getMessage"); // lib/chai/utils/transferFlags.js function transferFlags(assertion, object, includeAll) { var flags = assertion.__flags || (assertion.__flags = /* @__PURE__ */ Object.create(null)); if (!object.__flags) { object.__flags = /* @__PURE__ */ Object.create(null); } includeAll = arguments.length === 3 ? includeAll : true; for (var flag3 in flags) { if (includeAll || flag3 !== "object" && flag3 !== "ssfi" && flag3 !== "lockSsfi" && flag3 != "message") { object.__flags[flag3] = flags[flag3]; } } } __name(transferFlags, "transferFlags"); // node_modules/deep-eql/index.js function type2(obj) { if (typeof obj === "undefined") { return "undefined"; } if (obj === null) { return "null"; } const stringTag = obj[Symbol.toStringTag]; if (typeof stringTag === "string") { return stringTag; } const sliceStart = 8; const sliceEnd = -1; return Object.prototype.toString.call(obj).slice(sliceStart, sliceEnd); } __name(type2, "type"); function FakeMap() { this._key = "chai/deep-eql__" + Math.random() + Date.now(); } __name(FakeMap, "FakeMap"); FakeMap.prototype = { get: /* @__PURE__ */ __name(function get(key) { return key[this._key]; }, "get"), set: /* @__PURE__ */ __name(function set(key, value) { if (Object.isExtensible(key)) { Object.defineProperty(key, this._key, { value, configurable: true }); } }, "set") }; var MemoizeMap = typeof WeakMap === "function" ? WeakMap : FakeMap; function memoizeCompare(leftHandOperand, rightHandOperand, memoizeMap) { if (!memoizeMap || isPrimitive(leftHandOperand) || isPrimitive(rightHandOperand)) { return null; } var leftHandMap = memoizeMap.get(leftHandOperand); if (leftHandMap) { var result = leftHandMap.get(rightHandOperand); if (typeof result === "boolean") { return result; } } return null; } __name(memoizeCompare, "memoizeCompare"); function memoizeSet(leftHandOperand, rightHandOperand, memoizeMap, result) { if (!memoizeMap || isPrimitive(leftHandOperand) || isPrimitive(rightHandOperand)) { return; } var leftHandMap = memoizeMap.get(leftHandOperand); if (leftHandMap) { leftHandMap.set(rightHandOperand, result); } else { leftHandMap = new MemoizeMap(); leftHandMap.set(rightHandOperand, result); memoizeMap.set(leftHandOperand, leftHandMap); } } __name(memoizeSet, "memoizeSet"); var deep_eql_default = deepEqual; function deepEqual(leftHandOperand, rightHandOperand, options) { if (options && options.comparator) { return extensiveDeepEqual(leftHandOperand, rightHandOperand, options); } var simpleResult = simpleEqual(leftHandOperand, rightHandOperand); if (simpleResult !== null) { return simpleResult; } return extensiveDeepEqual(leftHandOperand, rightHandOperand, options); } __name(deepEqual, "deepEqual"); function simpleEqual(leftHandOperand, rightHandOperand) { if (leftHandOperand === rightHandOperand) { return leftHandOperand !== 0 || 1 / leftHandOperand === 1 / rightHandOperand; } if (leftHandOperand !== leftHandOperand && // eslint-disable-line no-self-compare rightHandOperand !== rightHandOperand) { return true; } if (isPrimitive(leftHandOperand) || isPrimitive(rightHandOperand)) { return false; } return null; } __name(simpleEqual, "simpleEqual"); function extensiveDeepEqual(leftHandOperand, rightHandOperand, options) { options = options || {}; options.memoize = options.memoize === false ? false : options.memoize || new MemoizeMap(); var comparator = options && options.comparator; var memoizeResultLeft = memoizeCompare(leftHandOperand, rightHandOperand, options.memoize); if (memoizeResultLeft !== null) { return memoizeResultLeft; } var memoizeResultRight = memoizeCompare(rightHandOperand, leftHandOperand, options.memoize); if (memoizeResultRight !== null) { return memoizeResultRight; } if (comparator) { var comparatorResult = comparator(leftHandOperand, rightHandOperand); if (comparatorResult === false || comparatorResult === true) { memoizeSet(leftHandOperand, rightHandOperand, options.memoize, comparatorResult); return comparatorResult; } var simpleResult = simpleEqual(leftHandOperand, rightHandOperand); if (simpleResult !== null) { return simpleResult; } } var leftHandType = type2(leftHandOperand); if (leftHandType !== type2(rightHandOperand)) { memoizeSet(leftHandOperand, rightHandOperand, options.memoize, false); return false; } memoizeSet(leftHandOperand, rightHandOperand, options.memoize, true); var result = extensiveDeepEqualByType(leftHandOperand, rightHandOperand, leftHandType, options); memoizeSet(leftHandOperand, rightHandOperand, options.memoize, result); return result; } __name(extensiveDeepEqual, "extensiveDeepEqual"); function extensiveDeepEqualByType(leftHandOperand, rightHandOperand, leftHandType, options) { switch (leftHandType) { case "String": case "Number": case "Boolean": case "Date": return deepEqual(leftHandOperand.valueOf(), rightHandOperand.valueOf()); case "Promise": case "Symbol": case "function": case "WeakMap": case "WeakSet": return leftHandOperand === rightHandOperand; case "Error": return keysEqual(leftHandOperand, rightHandOperand, ["name", "message", "code"], options); case "Arguments": case "Int8Array": case "Uint8Array": case "Uint8ClampedArray": case "Int16Array": case "Uint16Array": case "Int32Array": case "Uint32Array": case "Float32Array": case "Float64Array": case "Array": return iterableEqual(leftHandOperand, rightHandOperand, options); case "RegExp": return regexpEqual(leftHandOperand, rightHandOperand); case "Generator": return generatorEqual(leftHandOperand, rightHandOperand, options); case "DataView": return iterableEqual(new Uint8Array(leftHandOperand.buffer), new Uint8Array(rightHandOperand.buffer), options); case "ArrayBuffer": return iterableEqual(new Uint8Array(leftHandOperand), new Uint8Array(rightHandOperand), options); case "Set": return entriesEqual(leftHandOperand, rightHandOperand, options); case "Map": return entriesEqual(leftHandOperand, rightHandOperand, options); case "Temporal.PlainDate": case "Temporal.PlainTime": case "Temporal.PlainDateTime": case "Temporal.Instant": case "Temporal.ZonedDateTime": case "Temporal.PlainYearMonth": case "Temporal.PlainMonthDay": return leftHandOperand.equals(rightHandOperand); case "Temporal.Duration": return leftHandOperand.total("nanoseconds") === rightHandOperand.total("nanoseconds"); case "Temporal.TimeZone": case "Temporal.Calendar": return leftHandOperand.toString() === rightHandOperand.toString(); default: return objectEqual(leftHandOperand, rightHandOperand, options); } } __name(extensiveDeepEqualByType, "extensiveDeepEqualByType"); function regexpEqual(leftHandOperand, rightHandOperand) { return leftHandOperand.toString() === rightHandOperand.toString(); } __name(regexpEqual, "regexpEqual"); function entriesEqual(leftHandOperand, rightHandOperand, options) { try { if (leftHandOperand.size !== rightHandOperand.size) { return false; } if (leftHandOperand.size === 0) { return true; } } catch (sizeError) { return false; } var leftHandItems = []; var rightHandItems = []; leftHandOperand.forEach(/* @__PURE__ */ __name(function gatherEntries(key, value) { leftHandItems.push([key, value]); }, "gatherEntries")); rightHandOperand.forEach(/* @__PURE__ */ __name(function gatherEntries(key, value) { rightHandItems.push([key, value]); }, "gatherEntries")); return iterableEqual(leftHandItems.sort(), rightHandItems.sort(), options); } __name(entriesEqual, "entriesEqual"); function iterableEqual(leftHandOperand, rightHandOperand, options) { var length = leftHandOperand.length; if (length !== rightHandOperand.length) { return false; } if (length === 0) { return true; } var index = -1; while (++index < length) { if (deepEqual(leftHandOperand[index], rightHandOperand[index], options) === false) { return false; } } return true; } __name(iterableEqual, "iterableEqual"); function generatorEqual(leftHandOperand, rightHandOperand, options) { return iterableEqual(getGeneratorEntries(leftHandOperand), getGeneratorEntries(rightHandOperand), options); } __name(generatorEqual, "generatorEqual"); function hasIteratorFunction(target) { return typeof Symbol !== "undefined" && typeof target === "object" && typeof Symbol.iterator !== "undefined" && typeof target[Symbol.iterator] === "function"; } __name(hasIteratorFunction, "hasIteratorFunction"); function getIteratorEntries(target) { if (hasIteratorFunction(target)) { try { return getGeneratorEntries(target[Symbol.iterator]()); } catch (iteratorError) { return []; } } return []; } __name(getIteratorEntries, "getIteratorEntries"); function getGeneratorEntries(generator) { var generatorResult = generator.next(); var accumulator = [generatorResult.value]; while (generatorResult.done === false) { generatorResult = generator.next(); accumulator.push(generatorResult.value); } return accumulator; } __name(getGeneratorEntries, "getGeneratorEntries"); function getEnumerableKeys(target) { var keys = []; for (var key in target) { keys.push(key); } return keys; } __name(getEnumerableKeys, "getEnumerableKeys"); function getEnumerableSymbols(target) { var keys = []; var allKeys = Object.getOwnPropertySymbols(target); for (var i = 0; i < allKeys.length; i += 1) { var key = allKeys[i]; if (Object.getOwnPropertyDescriptor(target, key).enumerable) { keys.push(key); } } return keys; } __name(getEnumerableSymbols, "getEnumerableSymbols"); function keysEqual(leftHandOperand, rightHandOperand, keys, options) { var length = keys.length; if (length === 0) { return true; } for (var i = 0; i < length; i += 1) { if (deepEqual(leftHandOperand[keys[i]], rightHandOperand[keys[i]], options) === false) { return false; } } return true; } __name(keysEqual, "keysEqual"); function objectEqual(leftHandOperand, rightHandOperand, options) { var leftHandKeys = getEnumerableKeys(leftHandOperand); var rightHandKeys = getEnumerableKeys(rightHandOperand); var leftHandSymbols = getEnumerableSymbols(leftHandOperand); var rightHandSymbols = getEnumerableSymbols(rightHandOperand); leftHandKeys = leftHandKeys.concat(leftHandSymbols); rightHandKeys = rightHandKeys.concat(rightHandSymbols); if (leftHandKeys.length && leftHandKeys.length === rightHandKeys.length) { if (iterableEqual(mapSymbols(leftHandKeys).sort(), mapSymbols(rightHandKeys).sort()) === false) { return false; } return keysEqual(leftHandOperand, rightHandOperand, leftHandKeys, options); } var leftHandEntries = getIteratorEntries(leftHandOperand); var rightHandEntries = getIteratorEntries(rightHandOperand); if (leftHandEntries.length && leftHandEntries.length === rightHandEntries.length) { leftHandEntries.sort(); rightHandEntries.sort(); return iterableEqual(leftHandEntries, rightHandEntries, options); } if (leftHandKeys.length === 0 && leftHandEntries.length === 0 && rightHandKeys.length === 0 && rightHandEntries.length === 0) { return true; } return false; } __name(objectEqual, "objectEqual"); function isPrimitive(value) { return value === null || typeof value !== "object"; } __name(isPrimitive, "isPrimitive"); function mapSymbols(arr) { return arr.map(/* @__PURE__ */ __name(function mapSymbol(entry) { if (typeof entry === "symbol") { return entry.toString(); } return entry; }, "mapSymbol")); } __name(mapSymbols, "mapSymbols"); // node_modules/pathval/index.js function hasProperty(obj, name) { if (typeof obj === "undefined" || obj === null) { return false; } return name in Object(obj); } __name(hasProperty, "hasProperty"); function parsePath(path) { const str = path.replace(/([^\\])\[/g, "$1.["); const parts = str.match(/(\\\.|[^.]+?)+/g); return parts.map((value) => { if (value === "constructor" || value === "__proto__" || value === "prototype") { return {}; } const regexp = /^\[(\d+)\]$/; const mArr = regexp.exec(value); let parsed = null; if (mArr) { parsed = { i: parseFloat(mArr[1]) }; } else { parsed = { p: value.replace(/\\([.[\]])/g, "$1") }; } return parsed; }); } __name(parsePath, "parsePath"); function internalGetPathValue(obj, parsed, pathDepth) { let temporaryValue = obj; let res = null; pathDepth = typeof pathDepth === "undefined" ? parsed.length : pathDepth; for (let i = 0; i < pathDepth; i++) { const part = parsed[i]; if (temporaryValue) { if (typeof part.p === "undefined") { temporaryValue = temporaryValue[part.i]; } else { temporaryValue = temporaryValue[part.p]; } if (i === pathDepth - 1) { res = temporaryValue; } } } return res; } __name(internalGetPathValue, "internalGetPathValue"); function getPathInfo(obj, path) { const parsed = parsePath(path); const last = parsed[parsed.length - 1]; const info = { parent: parsed.length > 1 ? internalGetPathValue(obj, parsed, parsed.length - 1) : obj, name: last.p || last.i, value: internalGetPathValue(obj, parsed) }; info.exists = hasProperty(info.parent, info.name); return info; } __name(getPathInfo, "getPathInfo"); // lib/chai/assertion.js function Assertion(obj, msg, ssfi, lockSsfi) { flag(this, "ssfi", ssfi || Assertion); flag(this, "lockSsfi", lockSsfi); flag(this, "object", obj); flag(this, "message", msg); flag(this, "eql", config.deepEqual || deep_eql_default); return proxify(this); } __name(Assertion, "Assertion"); Object.defineProperty(Assertion, "includeStack", { get: function() { console.warn("Assertion.includeStack is deprecated, use chai.config.includeStack instead."); return config.includeStack; }, set: function(value) { console.warn("Assertion.includeStack is deprecated, use chai.config.includeStack instead."); config.includeStack = value; } }); Object.defineProperty(Assertion, "showDiff", { get: function() { console.warn("Assertion.showDiff is deprecated, use chai.config.showDiff instead."); return config.showDiff; }, set: function(value) { console.warn("Assertion.showDiff is deprecated, use chai.config.showDiff instead."); config.showDiff = value; } }); Assertion.addProperty = function(name, fn) { addProperty(this.prototype, name, fn); }; Assertion.addMethod = function(name, fn) { addMethod(this.prototype, name, fn); }; Assertion.addChainableMethod = function(name, fn, chainingBehavior) { addChainableMethod(this.prototype, name, fn, chainingBehavior); }; Assertion.overwriteProperty = function(name, fn) { overwriteProperty(this.prototype, name, fn); }; Assertion.overwriteMethod = function(name, fn) { overwriteMethod(this.prototype, name, fn); }; Assertion.overwriteChainableMethod = function(name, fn, chainingBehavior) { overwriteChainableMethod(this.prototype, name, fn, chainingBehavior); }; Assertion.prototype.assert = function(expr, msg, negateMsg, expected, _actual, showDiff) { var ok = test(this, arguments); if (false !== showDiff) showDiff = true; if (void 0 === expected && void 0 === _actual) showDiff = false; if (true !== config.showDiff) showDiff = false; if (!ok) { msg = getMessage2(this, arguments); var actual = getActual(this, arguments); var assertionErrorObjectProperties = { actual, expected, showDiff }; var operator = getOperator(this, arguments); if (operator) { assertionErrorObjectProperties.operator = operator; } throw new AssertionError( msg, assertionErrorObjectProperties, config.includeStack ? this.assert : flag(this, "ssfi") ); } }; Object.defineProperty( Assertion.prototype, "_obj", { get: function() { return flag(this, "object"); }, set: function(val) { flag(this, "object", val); } } ); // lib/chai/utils/isProxyEnabled.js function isProxyEnabled() { return config.useProxy && typeof Proxy !== "undefined" && typeof Reflect !== "undefined"; } __name(isProxyEnabled, "isProxyEnabled"); // lib/chai/utils/addProperty.js function addProperty(ctx, name, getter) { getter = getter === void 0 ? function() { } : getter; Object.defineProperty( ctx, name, { get: /* @__PURE__ */ __name(function propertyGetter() { if (!isProxyEnabled() && !flag(this, "lockSsfi")) { flag(this, "ssfi", propertyGetter); } var result = getter.call(this); if (result !== void 0) return result; var newAssertion = new Assertion(); transferFlags(this, newAssertion); return newAssertion; }, "propertyGetter"), configurable: true } ); } __name(addProperty, "addProperty"); // lib/chai/utils/addLengthGuard.js var fnLengthDesc = Object.getOwnPropertyDescriptor(function() { }, "length"); function addLengthGuard(fn, assertionName, isChainable) { if (!fnLengthDesc.configurable) return fn; Object.defineProperty(fn, "length", { get: function() { if (isChainable) { throw Error("Invalid Chai property: " + assertionName + '.length. Due to a compatibility issue, "length" cannot directly follow "' + assertionName + '". Use "' + assertionName + '.lengthOf" instead.'); } throw Error("Invalid Chai property: " + assertionName + '.length. See docs for proper usage of "' + assertionName + '".'); } }); return fn; } __name(addLengthGuard, "addLengthGuard"); // lib/chai/utils/getProperties.js function getProperties(object) { var result = Object.getOwnPropertyNames(object); function addProperty2(property) { if (result.indexOf(property) === -1) { result.push(property); } } __name(addProperty2, "addProperty");