any>(funcName: keyof T, clsProto?: T, polyFunc?: P) {\r\n let clsFn = clsProto ? clsProto[funcName] : NULL_VALUE;\r\n\r\n return function(thisArg: any): ReturnType {\r\n let theFunc = (thisArg ? thisArg[funcName] : NULL_VALUE) || clsFn;\r\n if (theFunc || polyFunc) {\r\n let theArgs = arguments;\r\n return ((theFunc || polyFunc) as Function).apply(thisArg, theFunc ? ArrSlice[CALL](theArgs, 1) : theArgs);\r\n }\r\n\r\n throwTypeError(\"\\\"\" + asString(funcName) + \"\\\" not defined for \" + dumpObj(thisArg));\r\n };\r\n}\r\n\r\n/**\r\n * @internal\r\n * @ignore\r\n * Internal helper to lookup and return the named property from the first argument (which becomes the this)\r\n *\r\n * @since 0.4.2\r\n * @typeParam T - The type of the object which contains the propName\r\n * @param propName - The property name\r\n * @returns The value of the property\r\n */\r\n/*#__NO_SIDE_EFFECTS__*/\r\nexport function _unwrapProp(propName: keyof T) {\r\n return function (thisArg: T) {\r\n return thisArg[propName];\r\n };\r\n}\r\n","/*\r\n * @nevware21/ts-utils\r\n * https://github.com/nevware21/ts-utils\r\n *\r\n * Copyright (c) 2022 NevWare21 Solutions LLC\r\n * Licensed under the MIT license.\r\n */\r\n\r\nimport { MathCls } from \"../internal/constants\";\r\nimport { _pureRef } from \"../internal/treeshake_helpers\";\r\n\r\n/**\r\n * The mathMin() function returns the lowest-valued number passed into it, or NaN if any\r\n * parameter isn't a number and can't be converted into one.\r\n *\r\n * If no arguments are given, the result is Infinity.\r\n *\r\n * If at least one of arguments cannot be converted to a number, the result is NaN.\r\n *\r\n * @since 0.4.2\r\n * @group Math\r\n * @param values - Zero or more numbers among which the lowest value will be selected and returned.\r\n * @returns The smallest of the given numbers. If any one or more of the parameters cannot\r\n * be converted into a number, NaN is returned. The result is Infinity if no parameters are provided.\r\n * @example\r\n * ```ts\r\n * const x = 10, y = -20;\r\n * const z = Math.min(x, y); // -20\r\n * ```\r\n */\r\nexport const mathMin: (...values: number[]) => number = (/*#__PURE__*/_pureRef(MathCls, \"min\"));\r\n\r\n/**\r\n * The `mathMax()` function returns the largest of the zero or more numbers given as input\r\n * parameters, or NaN if any parameter isn't a number and can't be converted into one.\r\n *\r\n * If no arguments are given, the result is -Infinity.\r\n *\r\n * If at least one of arguments cannot be converted to a number, the result is NaN.\r\n *\r\n * @since 0.4.2\r\n * @group Math\r\n * @param values - Zero or more numbers among which the largest value will be selected and returned.\r\n * @returns The largest of the given numbers. If any one or more of the parameters cannot be\r\n * converted into a number, NaN is returned. The result is -Infinity if no parameters are provided.\r\n * @example\r\n * ```ts\r\n * mathMax(10, 20); // 20\r\n * mathMax(-10, -20); // -10\r\n * mathMax(-10, 20); // 20\r\n * ```\r\n */\r\nexport const mathMax: (...values: number[]) => number = (/*#__PURE__*/_pureRef(MathCls, \"max\"));\r\n","/*\r\n * @nevware21/ts-utils\r\n * https://github.com/nevware21/ts-utils\r\n *\r\n * Copyright (c) 2022 NevWare21 Solutions LLC\r\n * Licensed under the MIT license.\r\n */\r\n\r\nimport { StrProto } from \"../internal/constants\";\r\nimport { _unwrapFunction } from \"../internal/unwrapFunction\";\r\n\r\n/**\r\n * The `strSlice()` method extracts a section of a string and returns it as a new string, without\r\n * modifying the original string.\r\n * `strSlice()` extracts the text from one string and returns a new string. Changes to the text in one\r\n * string do not affect the other string.\r\n * `strSlice()` extracts up to but not including endIndex. str.slice(1, 4) extracts the second character\r\n * through the fourth character (characters indexed 1, 2, and 3).\r\n * As an example, strSlice(2, -1) extracts the third character through the second to last character\r\n * in the string.\r\n * @group String\r\n * @param value - The value to haveextract a number\r\n * @param beginIndex - The zero-based index at which to begin extraction.\r\n * If `beginIndex` is negative, `strSlice()` begins extraction from `value.length + beginIndex`.\r\n * (E.g. `strSlice(\"test\", -2)` returns \"st\")\r\n * If `beginIndex` is omitted, undefined, or cannot be converted to a number (using Number(`beginIndex`)),\r\n * strSlice() begins extraction from the beginning of the string. (E.g. `strSlice(\"test\")` returns \"test\")\r\n * If `beginIndex` is greater than or equal to `value.length`, an empty string is returned.\r\n * (E.g. `strSlice(\"test\", 4)` returns \"\")\r\n * @param endIndex - The index of the first character to exclude from the returned substring.\r\n * If `endIndex` is omitted, undefined, or cannot be converted to a number (using Number(`endIndex`))\r\n * strSlice() extracts to the end of the string. (E.g. `strSlice(\"test\", 2)` returns \"st\")\r\n * If `endIndex` is greater than `value.length`, strSlice() also extracts to the end of the string.\r\n * (E.g. strSlice(\"test\", 2, 10)` returns \"st\")\r\n * If `endIndex` is negative, `strSlice()` treats it as `value.length + endIndex`. (E.g, if `endIndex`\r\n * is -2, it is treated as `value.length - 2` and `strSlice(\"test\", 1, -2)` returns \"e\") .\r\n * If `endIndex` represents a position that is before the one represented by startIndex, `strSlice()`\r\n * returns \"\". (E.g `strSlice(\"test\", 2, -10)`, strSlice(\"test\", -1, -2)` or `strSlice(\"test\", 3, 2)`).\r\n * @returns A new string containing the extracted section of the string.\r\n */\r\nexport const strSlice: (value: string, beginIndex: number, endIndex?: number) => string = (/*#__PURE__*/_unwrapFunction(\"slice\", StrProto));\r\n\r\n","/*\r\n * @nevware21/ts-utils\r\n * https://github.com/nevware21/ts-utils\r\n *\r\n * Copyright (c) 2022 NevWare21 Solutions LLC\r\n * Licensed under the MIT license.\r\n */\r\n\r\nimport { isNullOrUndefined, isUndefined } from \"../helpers/base\";\r\nimport { dumpObj } from \"../helpers/diagnostics\";\r\nimport { throwTypeError } from \"../helpers/throw\";\r\nimport { EMPTY, LENGTH, StrProto } from \"../internal/constants\";\r\nimport { _unwrapFunction, _unwrapFunctionWithPoly } from \"../internal/unwrapFunction\";\r\nimport { mathMax } from \"../math/min_max\";\r\nimport { strSlice } from \"./slice\";\r\n\r\n/**\r\n * The `strSubstring()` method returns the part of the string between the start and end indexes, or to the end of the string.\r\n *\r\n * `strSubstring()` extracts characters from indexStart up to but not including indexEnd. In particular:\r\n * - If `indexEnd` is omitted, strSubstring() extracts characters to the end of the string.\r\n * - If `indexStart` is equal to indexEnd, strSubstring() returns an empty string.\r\n * - If `indexStart` is greater than indexEnd, then the effect of strSubstring() is as if the two arguments were swapped; see example below.\r\n *\r\n * Any argument value that is less than 0 or greater than `value.length` is treated as if it were 0 and `value.length`, respectively.\r\n *\r\n * Any argument value that is NaN is treated as if it were 0.\r\n * @group String\r\n * @param value - The string value to return the substring from.\r\n * @param indexStart - The index of the first character to include in the returned substring.\r\n * @param indexEnd - The index of the first character to exclude from the returned substring.\r\n * @return A new string containing the specified part of the given string\r\n * @example\r\n * ```ts\r\n * const anyString = 'Nevware21';\r\n * // Displays 'N'\r\n * console.log(strSubstring(anyString, 0, 1));\r\n * console.log(strSubstring(anyString, 1, 0));\r\n *\r\n * // Displays 'Nevwar'\r\n * console.log(strSubstring(anyString, 0, 6));\r\n *\r\n * // Displays 'are21'\r\n * console.log(strSubstring(anyString, 4));\r\n *\r\n * // Displays 'are'\r\n * console.log(strSubstring(anyString, 4, 7));\r\n *\r\n * // Displays '21'\r\n * console.log(strSubstring(anyString, 7, 4));\r\n *\r\n * // Displays 'Nevware'\r\n * console.log(strSubstring(anyString, 0, 7));\r\n *\r\n * // Displays 'Nevware21'\r\n * console.log(strSubstring(anyString, 0, 10));\r\n * ```\r\n */\r\nexport const strSubstring: (value: string, indexStart: number, indexEnd?: number) => string = (/*#__PURE__*/_unwrapFunction(\"substring\", StrProto));\r\n\r\n/**\r\n * The strSubstr() method returns a portion of the string, starting at the specified index and extending for a given\r\n * number of characters afterwards.\r\n *\r\n * @since 0.4.2\r\n * @group String\r\n * @param value - The string value to return the substring from.\r\n * @param start - The index of the first character to include in the returned substring.\r\n * @param length - The number of characters to extract.\r\n * @returns A new string containing the specified part of the given string.\r\n */\r\nexport const strSubstr: (value: string, start: number, length?: number) => string = (/*#__PURE__*/_unwrapFunctionWithPoly(\"substr\", StrProto, polyStrSubstr));\r\n\r\n/**\r\n * The polyStrSubstr() method returns a portion of the string, starting at the specified index and extending for a given\r\n * number of characters afterwards.\r\n *\r\n * @since 0.4.2\r\n * @group String\r\n * @group Polyfill\r\n * @param value - The string value to return the substring from.\r\n * @param start - The index of the first character to include in the returned substring.\r\n * @param length - The number of characters to extract.\r\n * @returns A new string containing the specified part of the given string.\r\n */\r\n/*#__NO_SIDE_EFFECTS__*/\r\nexport function polyStrSubstr(value: string, start: number, length?: number): string {\r\n if (isNullOrUndefined(value)) {\r\n throwTypeError(\"Invalid \" + dumpObj(value));\r\n }\r\n\r\n if (length < 0) {\r\n return EMPTY;\r\n }\r\n\r\n // If start is omitted or undefined, its treated as zero\r\n start = start || 0;\r\n\r\n if (start < 0) {\r\n start = mathMax(start + value[LENGTH], 0);\r\n }\r\n\r\n if (isUndefined(length)) {\r\n return strSlice(value, start);\r\n }\r\n\r\n return strSlice(value, start, start + length);\r\n}\r\n\r\n/**\r\n * Returns a substring of the string starting from the left.\r\n *\r\n * `strLeft()` extracts the number of characters from left of the string up to the count. In particular:\r\n * - If `count` is less than zero, strLeft() returns an empty string.\r\n * - If `count` is less than `value.length', strLeft() returns a new string with the `count` number of characters from the left of the string.\r\n * - If `count` is greater than `value.length`, then the value original value is returned.\r\n *\r\n * Any argument value that is NaN is treated as if it were 0.\r\n *\r\n * @since 0.4.2\r\n * @group String\r\n * @param value - The string value to return the substring from.\r\n * @param count - The number of characters to extract\r\n * @returns The substring based on the count number of characters from the right\r\n * @example\r\n * ```ts\r\n * strLeft(\"Nevware21\", -1); // \"\"\r\n * strLeft(\"Nevware21\", 0); // \"\"\r\n * strLeft(\"Nevware21\", 1); // \"N\"\r\n * strLeft(\"Nevware21\", 3); // \"Nev\"\r\n * strLeft(\"Nevware21\", 21); // \"Nevware21\"\r\n * ```\r\n */\r\n/*#__NO_SIDE_EFFECTS__*/\r\nexport function strLeft(value: string, count: number): string {\r\n return strSubstring(value, 0, count);\r\n}\r\n\r\n/**\r\n * Returns a substring of the string starting from the right.\r\n *\r\n * `strRight()` extracts the number of characters from right of the string up to the count. In particular:\r\n * - If `count` is less than zero, strRight() returns an empty string.\r\n * - If `count` is less than `value.length', strRight() returns a new string with the `count` number of characters from the right of the string.\r\n * - If `count` is greater than `value.length`, then the value original value is returned.\r\n *\r\n * Any argument value that is NaN is treated as if it were 0.\r\n *\r\n * @since 0.4.2\r\n * @group String\r\n * @param value - The string value to return the substring from.\r\n * @param count - The number of characters to extract\r\n * @returns The substring based on the count number of characters from the right\r\n * @example\r\n * ```ts\r\n * strRight(\"Nevware21\", -1); // \"\"\r\n * strRight(\"Nevware21\", 0); // \"\"\r\n * strRight(\"Nevware21\", 1); // \"1\"\r\n * strRight(\"Nevware21\", 3); // \"e21\"\r\n * strRight(\"Nevware21\", 21); // \"Nevware21\"\r\n * ```\r\n */\r\n/*#__NO_SIDE_EFFECTS__*/\r\nexport function strRight(value: string, count: number): string {\r\n return count <= 0 ? EMPTY : (value[LENGTH] > count ? strSlice(value, -count) : value);\r\n}","/*\r\n * @nevware21/ts-utils\r\n * https://github.com/nevware21/ts-utils\r\n *\r\n * Copyright (c) 2022 NevWare21 Solutions LLC\r\n * Licensed under the MIT license.\r\n */\r\n\r\nimport { WellKnownSymbols, _wellKnownSymbolMap } from \"../symbol/well_known\";\r\nimport { throwTypeError } from \"../helpers/throw\";\r\nimport { POLYFILL_TAG, SYMBOL, TO_STRING } from \"../internal/constants\";\r\nimport { objHasOwn } from \"../object/has_own\";\r\nimport { asString } from \"../string/as_string\";\r\nimport { _GlobalPolySymbols, _getGlobalConfig } from \"../internal/global\";\r\nimport { strSubstring } from \"../string/substring\";\r\nimport { objKeys } from \"../object/object\";\r\n\r\nconst UNIQUE_REGISTRY_ID = \"_urid\";\r\nlet _polySymbols: _GlobalPolySymbols;\r\n\r\n/*#__NO_SIDE_EFFECTS__*/\r\nfunction _globalSymbolRegistry(): _GlobalPolySymbols {\r\n if (!_polySymbols) {\r\n let gblCfg = _getGlobalConfig();\r\n _polySymbols = gblCfg.gblSym = gblCfg.gblSym || { k: {}, s:{} };\r\n }\r\n\r\n return _polySymbols;\r\n}\r\n\r\nlet _wellKnownSymbolCache: { [key in keyof typeof WellKnownSymbols ]: symbol };\r\n\r\n/**\r\n * Returns a new (polyfill) Symbol object for the provided description that's guaranteed to be unique.\r\n * Symbols are often used to add unique property keys to an object that won't collide with keys any\r\n * other code might add to the object, and which are hidden from any mechanisms other code will\r\n * typically use to access the object. That enables a form of weak encapsulation, or a weak form of\r\n * information hiding.\r\n * @group Polyfill\r\n * @group Symbol\r\n * @param description - The description of the symbol\r\n * @returns A new polyfill version of a Symbol object\r\n */\r\n/*#__NO_SIDE_EFFECTS__*/\r\nexport function polyNewSymbol(description?: string | number): symbol {\r\n let theSymbol: symbol = {\r\n description: asString(description),\r\n toString: () => SYMBOL + \"(\" + description + \")\"\r\n } as symbol;\r\n \r\n // Tag the symbol so we know it a polyfill\r\n theSymbol[POLYFILL_TAG] = true;\r\n\r\n return theSymbol;\r\n}\r\n\r\n/**\r\n * Returns a Symbol object from the global symbol registry matching the given key if found.\r\n * Otherwise, returns a new symbol with this key.\r\n * @group Polyfill\r\n * @group Symbol\r\n * @param key key to search for.\r\n */\r\n/*#__NO_SIDE_EFFECTS__*/\r\nexport function polySymbolFor(key: string): symbol {\r\n let registry = _globalSymbolRegistry();\r\n if (!objHasOwn(registry.k, key)) {\r\n let newSymbol = polyNewSymbol(key);\r\n let regId = objKeys(registry.s).length;\r\n newSymbol[UNIQUE_REGISTRY_ID] = () => regId + \"_\" + newSymbol[TO_STRING]();\r\n registry.k[key] = newSymbol;\r\n registry.s[newSymbol[UNIQUE_REGISTRY_ID]()] = asString(key);\r\n }\r\n\r\n return registry.k[key];\r\n}\r\n\r\n/**\r\n * Returns a key from the global symbol registry matching the given Symbol if found.\r\n * Otherwise, returns a undefined.\r\n * @group Polyfill\r\n * @group Symbol\r\n * @param sym Symbol to find the key for.\r\n */\r\n/*#__NO_SIDE_EFFECTS__*/\r\nexport function polySymbolKeyFor(sym: symbol): string | undefined {\r\n if (!sym || !sym[TO_STRING] || strSubstring(sym[TO_STRING](), 0, 6) != SYMBOL) {\r\n throwTypeError((sym as any) + \" is not a symbol\");\r\n }\r\n\r\n const regId = sym[POLYFILL_TAG] && sym[UNIQUE_REGISTRY_ID] && sym[UNIQUE_REGISTRY_ID]();\r\n\r\n return regId ? _globalSymbolRegistry().s[regId] : undefined;\r\n}\r\n\r\n/**\r\n * Returns the polyfill version of a well-known global symbol, this will only return\r\n * known values.\r\n * @example\r\n * ```ts\r\n * // Always returns the polyfill version, even if Symbols are supported in the runtime\r\n * polyGetKnownSymbol(\"toStringTag\") === polyGetKnownSymbol(\"toStringTag\"); // true\r\n * polyGetKnownSymbol(WellKnownSymbols.toStringTag) === polyGetKnownSymbol(\"toStringTag\"); // true\r\n * polyGetKnownSymbol(\"toStringTag\") !== Symbol.toStringTag; // true\r\n * polyGetKnownSymbol(WellKnownSymbols.toStringTag) !== Symbol.toStringTag; // true\r\n * polyGetKnownSymbol(\"toStringTag\") !== polySymbolFor(\"toStringTag\"); // true\r\n * polyGetKnownSymbol(WellKnownSymbols.toStringTag) !== polySymbolFor(\"toStringTag\"); // true\r\n * polyGetKnownSymbol(\"toStringTag\") !== polyNewSymbol(\"toStringTag\"); // true\r\n * polyGetKnownSymbol(WellKnownSymbols.toStringTag) !== polyNewSymbol(\"toStringTag\"); // true\r\n * ```\r\n * @group Polyfill\r\n * @group Symbol\r\n * @param name - The property name to return (if it exists) for Symbol\r\n * @returns The value of the property if present\r\n */\r\n/*#__NO_SIDE_EFFECTS__*/\r\nexport function polyGetKnownSymbol(name: string | WellKnownSymbols): symbol {\r\n !_wellKnownSymbolCache && (_wellKnownSymbolCache = {} as any);\r\n let result: symbol;\r\n let knownName: WellKnownSymbols = _wellKnownSymbolMap[name];\r\n if (knownName) {\r\n result = _wellKnownSymbolCache[knownName] = _wellKnownSymbolCache[knownName] || polyNewSymbol(SYMBOL + \".\" + knownName);\r\n }\r\n\r\n return result\r\n}\r\n","/*\r\n * @nevware21/ts-utils\r\n * https://github.com/nevware21/ts-utils\r\n *\r\n * Copyright (c) 2022 NevWare21 Solutions LLC\r\n * Licensed under the MIT license.\r\n */\r\n\r\nimport { _GlobalTestHooks, _getGlobalConfig } from \"../internal/global\";\r\nimport { objDefineProp } from \"../object/define\";\r\nimport { ICachedValue } from \"./cache\";\r\n\r\n/**\r\n * @internal\r\n * Internal flag which is set by the public {@link setBypassLazyCache}, should not be externally exported\r\n */\r\nexport let _globalLazyTestHooks: _GlobalTestHooks;\r\n\r\nexport function _initTestHooks() {\r\n _globalLazyTestHooks = _getGlobalConfig();\r\n}\r\n\r\n/**\r\n * Interface of the object returned by the {@link getLazy} instance\r\n * @since 0.4.5\r\n * @group Lazy\r\n */\r\nexport interface ILazyValue extends ICachedValue {\r\n /**\r\n * Returns the current cached value from the lazy lookup, if the callback function has not yet occurred\r\n * accessing the value will cause the lazy evaluation to occur and the result will be returned.\r\n */\r\n v: T,\r\n\r\n /**\r\n * Identifies if this instance is bypassing the internal caching mechanism which is used for testing\r\n */\r\n b?: boolean\r\n}\r\n\r\n/**\r\n * Create and return an readonly {@link ILazyValue} instance which will cache and return the value returned\r\n * by the callback function. The callback function will only be called once, multiple access of the value\r\n * does not cause re-execution of the callback as the result from the first call is cached internally.\r\n * @since 0.4.5\r\n * @group Lazy\r\n * @param cb - The callback function to fetch the value to be lazily evaluated and cached\r\n * @returns A new readonly {@link ILazyValue} instance which wraps the callback and will be used to cache\r\n * the result of the callback\r\n * @example\r\n * ```ts\r\n * // This does not cause the evaluation to occur\r\n * let cachedValue = getLazy(() => callSomeExpensiveFunction());\r\n * let theValue;\r\n *\r\n * // Just checking if there is an object still does not cause the evaluation\r\n * if (cachedValue) {\r\n * // This will cause the evaluation to occur and the result will be cached\r\n * theValue = cachedValue.v;\r\n * }\r\n *\r\n * // Accessing the value again will not cause the re-evaluation to occur, it will just return the same\r\n * // result value again.\r\n * theValue === cachedValue.v; // true\r\n *\r\n * ```\r\n */\r\n/*#__NO_SIDE_EFFECTS__*/\r\nexport function getLazy(cb: () => T): ILazyValue {\r\n let lazyValue = { } as ILazyValue;\r\n !_globalLazyTestHooks && _initTestHooks();\r\n lazyValue.b = _globalLazyTestHooks.lzy;\r\n\r\n objDefineProp(lazyValue, \"v\", {\r\n configurable: true,\r\n get: function () {\r\n let result = cb();\r\n if (!_globalLazyTestHooks.lzy) {\r\n // Just replace the value\r\n objDefineProp(lazyValue, \"v\", {\r\n value: result\r\n });\r\n }\r\n\r\n lazyValue.b = _globalLazyTestHooks.lzy;\r\n\r\n return result;\r\n }\r\n });\r\n\r\n return lazyValue;\r\n}\r\n\r\n/**\r\n * Test Hook function used to cause the internal caching of objects to be bypassed, this should never\r\n * be enabled for production as it has additional performance impact caused by the repetitive creation\r\n * of the lazy wrappers.\r\n * @group Lazy\r\n * @since 0.5.0\r\n * @param newValue - When `true` will cause all new lazy implementations to bypass the cached lookup.\r\n */\r\nexport function setBypassLazyCache(newValue: boolean) {\r\n !_globalLazyTestHooks && _initTestHooks();\r\n _globalLazyTestHooks.lzy = newValue;\r\n}\r\n\r\n/**\r\n * Create and return a writable {@link ILazyValue} instance which will cache and return the value returned\r\n * by the callback function. The callback function will only be called once, multiple access of the value\r\n * does not cause re-execution of the callback as the result from the first call is cached internally. The\r\n * value may be set as many times as required, if the callback has not been called when you set the value\r\n * it will never get called.\r\n * @since 0.9.4\r\n * @group Lazy\r\n * @param cb - The callback function to fetch the value to be lazily evaluated and cached\r\n * @returns A new writable {@link ILazyValue} instance which wraps the callback and will be used to cache\r\n * the result of the callback\r\n * @example\r\n * ```ts\r\n * // This does not cause the evaluation to occur\r\n * let cachedValue = getWritableLazy(() => callSomeExpensiveFunction());\r\n * let theValue;\r\n *\r\n * // Just checking if there is an object still does not cause the evaluation\r\n * if (cachedValue) {\r\n * // This will cause the evaluation to occur and the result will be cached\r\n * theValue = cachedValue.v;\r\n * }\r\n *\r\n * // Accessing the value again will not cause the re-evaluation to occur, it will just return the same\r\n * // result value again.\r\n * theValue === cachedValue.v; // true\r\n *\r\n * // Setting the value\r\n * let cachedValue = getWritableLazy(() => callSomeExpensiveFunction());\r\n * let theValue = \"new Value\";\r\n *\r\n * // Just checking if there is an object still does not cause the evaluation\r\n * if (cachedValue) {\r\n * // This will set the value to be set explicitly and the callback\r\n * // will now never occur and the result will be cached\r\n * cachedValue.v = theValue;\r\n * }\r\n *\r\n * // Accessing the value again will cause the previously set value to be returned.\r\n * theValue === cachedValue.v; // true\r\n * ```\r\n */\r\nexport function getWritableLazy(cb: () => T): ILazyValue {\r\n let lazyValue = { } as ILazyValue;\r\n !_globalLazyTestHooks && _initTestHooks();\r\n lazyValue.b = _globalLazyTestHooks.lzy;\r\n\r\n let _setValue = (newValue: T) => {\r\n // Just replace the value\r\n objDefineProp(lazyValue, \"v\", {\r\n value: newValue,\r\n writable: true\r\n });\r\n\r\n if (lazyValue.b) {\r\n delete lazyValue.b;\r\n }\r\n };\r\n\r\n objDefineProp(lazyValue, \"v\", {\r\n configurable: true,\r\n get: function () {\r\n let result = cb();\r\n if (!_globalLazyTestHooks.lzy) {\r\n // Just replace the value\r\n _setValue(result);\r\n }\r\n \r\n if (_globalLazyTestHooks.lzy && lazyValue.b !== _globalLazyTestHooks.lzy) {\r\n lazyValue.b = _globalLazyTestHooks.lzy;\r\n }\r\n\r\n return result;\r\n },\r\n set: _setValue\r\n });\r\n\r\n return lazyValue;\r\n}\r\n","/*\r\n * @nevware21/ts-utils\r\n * https://github.com/nevware21/ts-utils\r\n *\r\n * Copyright (c) 2024 NevWare21 Solutions LLC\r\n * Licensed under the MIT license.\r\n */\r\n\r\nimport { NULL_VALUE } from \"../internal/constants\";\r\nimport { objDefineProp } from \"../object/define\";\r\n\r\n/**\r\n * A generic interface for holding a cached value\r\n * @since 0.10.5\r\n * @group Helpers\r\n * @group Cache\r\n * @typeParam T - The type of the value to be cached\r\n * @example\r\n * ```ts\r\n * let cachedValue: ICachedValue = {\r\n * v: \"some value\"\r\n * };\r\n * ```\r\n */\r\nexport interface ICachedValue {\r\n /**\r\n * Returns the current cached value\r\n */\r\n v: T,\r\n\r\n /**\r\n * Returns the current cached value\r\n */\r\n toJSON(): T;\r\n}\r\n\r\n/**\r\n * Create and return a readonly {@link ICachedValue} instance that is populated with the provided value.\r\n * This is useful when you want to cache a previously fetched value and return it without having to re-fetch\r\n * it again.\r\n * This is a lightweight version of {@link getLazy} which does not support any expiration or invalidation,\r\n * it also will not honor the {@link setBypassLazyCache} setting and will always return the provided value.\r\n * @since 0.10.5\r\n * @group Helpers\r\n * @group Cache\r\n * @typeParam T - The type of the value to be cached\r\n * @param value\r\n * @returns A new {@link ICachedValue} instance which wraps the provided value\r\n * @example\r\n * ```ts\r\n * let cachedValue = createCachedValue(\"some value\");\r\n * // cachedValue.v === \"some value\"\r\n *\r\n * JSON.stringify(cachedValue) === '{\"v\":\"some value\"}';\r\n * ```\r\n */\r\n/*#__NO_SIDE_EFFECTS__*/\r\nexport function createCachedValue(value: T): ICachedValue {\r\n return objDefineProp({\r\n toJSON: () => value\r\n }, \"v\", { value }) as ICachedValue;\r\n}\r\n\r\n/**\r\n * Create and return a readonly {@link ICachedValue} instance which will cache and return the value returned\r\n * by the callback function. The callback function will only be called once, multiple access of the value\r\n * will not cause re-execution of the callback as the result from the first call is cached internally.\r\n * This is a lightweight version of {@link getLazy} which does not support any expiration or invalidation,\r\n * it also will not honor the {@link setBypassLazyCache} setting and will always return the provided value.\r\n * @since 0.10.5\r\n * @group Helpers\r\n * @group Cache\r\n * @typeParam T - The type of the value to be cached\r\n * @param cb - The callback function to fetch the value to be lazily evaluated and cached\r\n * @returns\r\n */\r\n/*#__NO_SIDE_EFFECTS__*/\r\nexport function createDeferredCachedValue(cb: () => T): ICachedValue {\r\n let theValue: any = {\r\n toJSON: () => theValue.v\r\n };\r\n\r\n return objDefineProp(theValue as ICachedValue, \"v\", {\r\n get: () => {\r\n let result = cb();\r\n cb = NULL_VALUE;\r\n objDefineProp(theValue, \"v\", { value: result });\r\n return result;\r\n },\r\n configurable: true\r\n });\r\n}\r\n","/*\r\n * @nevware21/ts-utils\r\n * https://github.com/nevware21/ts-utils\r\n *\r\n * Copyright (c) 2022 NevWare21 Solutions LLC\r\n * Licensed under the MIT license.\r\n */\r\n\r\nimport { NULL_VALUE, UNDEF_VALUE } from \"../internal/constants\";\r\nimport { _getGlobalValue } from \"../internal/global\";\r\nimport { ILazyValue, _globalLazyTestHooks, _initTestHooks, getLazy } from \"./lazy\";\r\nimport { ICachedValue, createCachedValue } from \"./cache\";\r\nimport { safe } from \"./safe\";\r\n\r\nconst WINDOW = \"window\";\r\n\r\ndeclare let WorkerGlobalScope: any;\r\ndeclare let self: any;\r\n\r\nlet _cachedGlobal: ICachedValue;\r\n\r\n/**\r\n * @internal\r\n * @ignore\r\n * Returns a function which will return the named global object if available, will return `null` if the object is not available.\r\n * @param getFn - The function to use to get the global object\r\n * @param instName - The name of the global object to get, may be any valid PropertyKey (string, number or symbol)\r\n * @returns A function which will return the named global object if available, the funcion will return `null` if the object is not available.\r\n */\r\nexport function _getGlobalInstFn(getFn: (...args: unknown[]) => T, theArgs?: unknown[]): () => T | null | undefined {\r\n let cachedValue: ICachedValue;\r\n return function() {\r\n !_globalLazyTestHooks && _initTestHooks();\r\n if (!cachedValue || _globalLazyTestHooks.lzy) {\r\n cachedValue = createCachedValue(safe(getFn, theArgs).v);\r\n }\r\n \r\n return cachedValue.v;\r\n }\r\n}\r\n\r\n/**\r\n * Create and return an readonly {@link ILazyValue} instance which will cache and return the named global\r\n * value if available, will return `null` if the named global object is not available or if the runtime\r\n * throws an exception when attempting to access the global object.\r\n * Unlike {@link getInst} the value is cached after the first access, so if the global value changes after\r\n * the initial fetch the original cached value is still returned.\r\n * @since 0.9.5\r\n * @group Environment\r\n * @group Lazy\r\n * @group Safe\r\n * @param name The name of the global object to get, may be any valid PropertyKey (string, number or symbol)\r\n * @returns A new readonly {@link ILazyValue} instance which will lazily attempt to return the globally\r\n * available named instance.\r\n * @example\r\n * ```ts\r\n * // This does not cause the evaluation to occur\r\n * window.myGlobal = \"Hello\";\r\n * let cachedValue = lazySafeGetInst(\"myGlobal\");\r\n * // cachedValue.v === \"Hello\"\r\n *\r\n * window.myGlobal = \"Darkness\";\r\n * // cachedValue.v === \"Hello\"\r\n *\r\n * let promiseCls = lazySafeGetInst(\"Promise\");\r\n * // null if Promise is not supported in the runtime\r\n * // otherwise the Promise class.\r\n * ```\r\n */\r\n/*#__NO_SIDE_EFFECTS__*/\r\nexport function lazySafeGetInst(name: string | number | symbol) : ILazyValue {\r\n return getLazy(() => safe(getInst, [name]).v || UNDEF_VALUE);\r\n}\r\n\r\n/**\r\n * Returns the current global scope object, for a normal web page this will be the current\r\n * window, for a Web Worker this will be current worker global scope via \"self\". The internal\r\n * implementation returns the first available instance object in the following order\r\n * - globalThis (New standard)\r\n * - self (Will return the current window instance for supported browsers)\r\n * - window (fallback for older browser implementations)\r\n * - global (NodeJS standard)\r\n * - (When all else fails)\r\n * While the return type is a Window for the normal case, not all environments will support all\r\n * of the properties or functions. And this caches the lookup of the global as in some environments\r\n * this can be an expensive operation.\r\n * @group Environment\r\n * @param useCached - [Optional] used for testing to bypass the cached lookup, when `true` this will\r\n * cause the cached global to be reset.\r\n */\r\nexport function getGlobal(useCached?: boolean): Window {\r\n !_globalLazyTestHooks && _initTestHooks();\r\n if (!_cachedGlobal || useCached === false || _globalLazyTestHooks.lzy) {\r\n _cachedGlobal = createCachedValue(safe(_getGlobalValue).v || NULL_VALUE);\r\n }\r\n\r\n return _cachedGlobal.v;\r\n}\r\n\r\n/**\r\n * Return the named global object if available, will return null if the object is not available.\r\n * @group Environment\r\n * @param name The globally named object, may be any valid property key (string, number or symbol)\r\n * @param useCached - [Optional] used for testing to bypass the cached lookup, when `true` this will\r\n * cause the cached global to be reset.\r\n * @example\r\n * ```ts\r\n * // This does not cause the evaluation to occur\r\n * window.myGlobal = \"Hello\";\r\n * let cachedValue = getInst(\"myGlobal\");\r\n * // cachedValue === \"Hello\"\r\n *\r\n * window.myGlobal = \"Darkness\";\r\n * // getInst(\"myGlobal\") === \"Darkness\"\r\n *\r\n * let promiseCls = getInst(\"Promise\");\r\n * // May throw if the global is not supported by the runtime\r\n * // otherwise the Promise class.\r\n * ```\r\n */\r\n/*#__NO_SIDE_EFFECTS__*/\r\nexport function getInst(name: string | number | symbol, useCached?: boolean): T | null {\r\n let gbl: any;\r\n if (!_cachedGlobal || useCached === false) {\r\n gbl = getGlobal(useCached);\r\n } else {\r\n gbl = _cachedGlobal.v;\r\n }\r\n\r\n if (gbl && gbl[name]) {\r\n return gbl[name] as T;\r\n }\r\n\r\n // Test workaround, for environments where .window (when global == window) doesn't return the base window\r\n if (name === WINDOW) {\r\n // tslint:disable-next-line: no-angle-bracket-type-assertion\r\n try {\r\n return window as T;\r\n } catch (e) {\r\n // Ignore\r\n }\r\n }\r\n\r\n return NULL_VALUE;\r\n}\r\n\r\n/**\r\n * Identify whether the runtime contains a `document` object\r\n * @group Environment\r\n * @returns - True if a `document` exists\r\n */\r\n/*#__NO_SIDE_EFFECTS__*/\r\nexport function hasDocument(): boolean {\r\n return !!( /*#__PURE__*/getDocument());\r\n}\r\n\r\n/**\r\n * Return the global `document` instance.\r\n * @group Environment\r\n * @returns\r\n */\r\nexport const getDocument = (/*#__PURE__*/_getGlobalInstFn(getInst, [\"document\"]));\r\n\r\n/**\r\n * Identify whether the runtime contains a `window` object\r\n * @group Environment\r\n * @returns\r\n */\r\n/*#__NO_SIDE_EFFECTS__*/\r\nexport function hasWindow(): boolean {\r\n return !!( /*#__PURE__*/getWindow());\r\n}\r\n\r\n/**\r\n * Return the global `window` instance.\r\n * @group Environment\r\n * @returns\r\n */\r\nexport const getWindow = (/*#__PURE__*/_getGlobalInstFn(getInst, [WINDOW]));\r\n\r\n/**\r\n * Identify whether the runtimne contains a `navigator` object\r\n * @group Environment\r\n * @returns\r\n */\r\n/*#__NO_SIDE_EFFECTS__*/\r\nexport function hasNavigator(): boolean {\r\n return !!( /*#__PURE__*/getNavigator());\r\n}\r\n\r\n/**\r\n * Returns the global `navigator` instance\r\n * @group Environment\r\n * @returns\r\n */\r\nexport const getNavigator = (/*#__PURE__*/_getGlobalInstFn(getInst, [\"navigator\"]));\r\n\r\n/**\r\n * Identifies whether the runtime contains a `history` object\r\n * @group Environment\r\n * @returns\r\n */\r\n/*#__NO_SIDE_EFFECTS__*/\r\nexport function hasHistory(): boolean {\r\n return !!( /*#__PURE__*/getHistory());\r\n}\r\n\r\n/**\r\n * Returns the global `history` instance\r\n * @group Environment\r\n * @returns\r\n */\r\nexport const getHistory = (/*#__PURE__*/_getGlobalInstFn(getInst, [\"history\"]));\r\n\r\n/**\r\n * Simple method to determine if we are running in a node environment\r\n * @group Environment\r\n * @returns True if you are\r\n */\r\nexport const isNode = (/*#__PURE__*/_getGlobalInstFn(() => {\r\n return !!( /*#__PURE__*/safe(() => (process && (process.versions||{}).node)).v);\r\n}));\r\n\r\n/**\r\n * Helper to identify if you are running as a Dedicated, Shared or Service worker\r\n * @group Environment\r\n * @returns True if the environment you are in looks like a Web Worker\r\n */\r\nexport const isWebWorker = (/*#__PURE__*/_getGlobalInstFn(() => {\r\n return !!( /*#__PURE__*/safe(() => self && self instanceof WorkerGlobalScope).v);\r\n}));\r\n","/*\r\n * @nevware21/ts-utils\r\n * https://github.com/nevware21/ts-utils\r\n *\r\n * Copyright (c) 2022 NevWare21 Solutions LLC\r\n * Licensed under the MIT license.\r\n */\r\n\r\nimport { NULL_VALUE, SYMBOL, UNDEF_VALUE } from \"../internal/constants\";\r\nimport { polyGetKnownSymbol, polyNewSymbol, polySymbolFor, polySymbolKeyFor } from \"../polyfills/symbol\";\r\nimport { WellKnownSymbols, _wellKnownSymbolMap } from \"./well_known\";\r\nimport { _createIs } from \"../helpers/base\";\r\nimport { _globalLazyTestHooks, _initTestHooks } from \"../helpers/lazy\";\r\nimport { ICachedValue, createCachedValue } from \"../helpers/cache\";\r\nimport { safe } from \"../helpers/safe\";\r\nimport { getInst } from \"../helpers/environment\";\r\n\r\nlet _symbol: ICachedValue;\r\nlet _symbolFor: ICachedValue<(key: string) => symbol>;\r\nlet _symbolKeyFor: ICachedValue<(sym: symbol) => string | undefined>;\r\n\r\n/*#__NO_SIDE_EFFECTS__*/\r\nfunction _initSymbol() {\r\n _symbol = (/*#__PURE__*/createCachedValue(safe(getInst, [SYMBOL]).v));\r\n\r\n return _symbol;\r\n}\r\n\r\nfunction _getSymbolKey(key: string) {\r\n let gblSym = ((!_globalLazyTestHooks.lzy ? _symbol : 0) || _initSymbol());\r\n\r\n return (gblSym.v ? gblSym.v[key] : UNDEF_VALUE) as R;\r\n}\r\n\r\n/**\r\n * Checks if the type of value is a symbol.\r\n * @group Symbol\r\n * @param {any} value - Value to be checked.\r\n * @return {boolean} True if the value is a symbol, false otherwise.\r\n */\r\nexport const isSymbol: (value: any) => value is symbol = (/*#__PURE__*/_createIs(\"symbol\"));\r\n\r\n/**\r\n * Helper to identify whether the runtime support the Symbols either via native or an installed polyfill\r\n * @group Symbol\r\n * @returns true if Symbol's are support otherwise false\r\n */\r\n/*#__NO_SIDE_EFFECTS__*/\r\nexport function hasSymbol(): boolean {\r\n return !!( /*#__PURE__*/getSymbol());\r\n}\r\n\r\n/**\r\n * If Symbols are supported then attempt to return the named Symbol\r\n * @group Symbol\r\n * @returns The value of the named Symbol (if available)\r\n */\r\n/*#__NO_SIDE_EFFECTS__*/\r\nexport function getSymbol(): Symbol {\r\n !_globalLazyTestHooks && _initTestHooks();\r\n \r\n // Get the current lazy symbol or cause it to get initialized\r\n return ((!_globalLazyTestHooks.lzy ? _symbol : 0) || _initSymbol()).v;\r\n}\r\n\r\n/**\r\n * If Symbols are supported then get the property of the global Symbol, if Symbol's are\r\n * not supported and noPoly is true it returns null. Used to access the well known symbols.\r\n * @group Symbol\r\n * @param name - The property name to return (if it exists) for Symbol\r\n * @param noPoly - Flag indicating whether to return a polyfill if symbols are not supported.\r\n * @returns The value of the property if present\r\n * @example\r\n * ```ts\r\n * // If Symbol is supported in the runtime\r\n * getKnownSymbol(\"toStringTag\") === Symbol.toStringTag; // true\r\n * getKnownSymbol(WellKnownSymbols.toStringTag) === Symbol.toStringTag; // true\r\n * ```\r\n */\r\n/*#__NO_SIDE_EFFECTS__*/\r\nexport function getKnownSymbol(name: string | WellKnownSymbols, noPoly?: boolean): T {\r\n let knownName = _wellKnownSymbolMap[name];\r\n !_globalLazyTestHooks && _initTestHooks();\r\n\r\n // Get the current lazy symbol or cause it to get initialized\r\n let sym = ((!_globalLazyTestHooks.lzy ? _symbol : 0) || _initSymbol());\r\n \r\n return sym.v ? sym.v[knownName || name] : (!noPoly ? polyGetKnownSymbol(name) : UNDEF_VALUE);\r\n}\r\n\r\n/**\r\n * Returns a new unique Symbol value. If noPoly is true and symbols are not supported\r\n * then this will return null.\r\n * @group Symbol\r\n * @param description Description of the new Symbol object.\r\n * @param noPoly - Flag indicating whether to return a polyfil if symbols are not supported.\r\n * @returns The new symbol\r\n */\r\n/*#__NO_SIDE_EFFECTS__*/\r\nexport function newSymbol(description?: string | number, noPoly?: boolean): symbol {\r\n !_globalLazyTestHooks && _initTestHooks();\r\n\r\n // Get the current lazy symbol or cause it to get initialized\r\n let sym = ((!_globalLazyTestHooks.lzy ? _symbol : 0) || _initSymbol());\r\n\r\n return sym.v ? (sym.v as any)(description) : (!noPoly ? polyNewSymbol(description) : NULL_VALUE);\r\n}\r\n\r\n/**\r\n * Returns a Symbol object from the global symbol registry matching the given key if found.\r\n * Otherwise, returns a new symbol with this key. This will always return a polyfill if symbols\r\n * are not supported.\r\n * @group Symbol\r\n * @param key key to search for.\r\n */\r\n/*#__NO_SIDE_EFFECTS__*/\r\nexport function symbolFor(key: string): symbol {\r\n !_globalLazyTestHooks && _initTestHooks();\r\n\r\n // Cause lazy symbol to get initialized\r\n _symbolFor = ((!_globalLazyTestHooks.lzy ? _symbolFor : 0) || (/*#__PURE__*/createCachedValue(safe(_getSymbolKey, [\"for\"]).v)));\r\n\r\n return (_symbolFor.v || polySymbolFor)(key);\r\n}\r\n\r\n/**\r\n * Returns a key from the global symbol registry matching the given Symbol if found.\r\n * Otherwise, returns a undefined. This will always attempt to lookup the polyfill\r\n * implementation if symbols are not supported\r\n * @group Symbol\r\n * @param sym Symbol to find the key for.\r\n */\r\n/*#__NO_SIDE_EFFECTS__*/\r\nexport function symbolKeyFor(sym: symbol): string | undefined {\r\n !_globalLazyTestHooks && _initTestHooks();\r\n\r\n // Cause lazy symbol to get initialized\r\n _symbolKeyFor = ((!_globalLazyTestHooks.lzy ? _symbolKeyFor : 0) || (/*#__PURE__*/createCachedValue(safe(_getSymbolKey, [\"keyFor\"]).v)));\r\n\r\n return (_symbolKeyFor.v || polySymbolKeyFor)(sym);\r\n}\r\n","/*\r\n * @nevware21/ts-utils\r\n * https://github.com/nevware21/ts-utils\r\n *\r\n * Copyright (c) 2022 NevWare21 Solutions LLC\r\n * Licensed under the MIT license.\r\n */\r\n\r\nimport { ICachedValue, createCachedValue } from \"../helpers/cache\";\r\nimport { CALL, NULL_VALUE, UNDEF_VALUE } from \"../internal/constants\";\r\nimport { getKnownSymbol } from \"../symbol/symbol\";\r\nimport { WellKnownSymbols } from \"../symbol/well_known\";\r\nimport { isIterator } from \"./iterator\";\r\n\r\nlet _iterSymbol: ICachedValue;\r\n\r\n/**\r\n * Calls the provided `callbackFn` function once for each element in the iterator or iterator returned by\r\n * the iterable and processed in the same order as returned by the iterator. As with the {@link arrForEach}\r\n * you CAN stop / break the iteration by returning -1 from the`callbackFn` function.\r\n *\r\n * The order of processing is not reset if you add or remove elements to the iterator, the actual behavior\r\n * will depend on the iterator imeplementation.\r\n *\r\n * If the passed `iter` is both an Iterable and Iterator the Iterator interface takes preceedence.\r\n * @remarks\r\n * If Symbols are NOT supported then the iterable MUST be using the same polyFill for the well know symbols,\r\n * if you are targetting a mixed environment you SHOULD either\r\n * - only use the polyfill Symbol's provided by this library\r\n * - ensure that you add any symbol polyfills BEFORE these utilities\r\n * iterForOf expects a `synchronous` function.\r\n * iterForOf does not wait for promises. Make sure you are aware of the implications while using\r\n * promises (or async functions) as forEach callback.\r\n *\r\n * @since 0.4.2\r\n * @group Iterator\r\n * @typeParam T - Identifies the element type of the iterator\r\n * @param callbackfn A `synchronous` function that accepts up to three arguments. iterForOf calls the\r\n * callbackfn function one time for each element returned by the iterator.\r\n * @param thisArg An object to which the this keyword can refer in the callbackfn function. If thisArg is\r\n * omitted, null or undefined the iterator will be used as the this value.\r\n * @throws Any exception thrown while processing the iterator\r\n * @example\r\n * ```ts\r\n * const items = {\r\n * 'item1': 'value1',\r\n * 'item2': 'value2',\r\n * 'item3': 'value3\r\n * };\r\n * const copyItems = [];\r\n *\r\n * iterForOf(items, (item) => {\r\n * copyItems.push(item);\r\n * // May return -1 to abort the iteration\r\n * });\r\n * ```\r\n */\r\nexport function iterForOf(iter: Iterator | Iterable, callbackfn: (value: T, count?: number, iter?: Iterator) => void | number, thisArg?: any): void {\r\n if (iter) {\r\n if (!isIterator(iter)) {\r\n !_iterSymbol && (_iterSymbol = createCachedValue(getKnownSymbol(WellKnownSymbols.iterator)));\r\n iter = iter[_iterSymbol.v] ? iter[_iterSymbol.v]() : NULL_VALUE;\r\n }\r\n \r\n if (isIterator(iter)) {\r\n let err: { e: any } = UNDEF_VALUE;\r\n let iterResult: IteratorResult = UNDEF_VALUE;\r\n try {\r\n let count = 0;\r\n while(!(iterResult = iter.next()).done) {\r\n if (callbackfn[CALL](thisArg || iter, iterResult.value, count, iter) === -1) {\r\n break;\r\n }\r\n \r\n count++;\r\n }\r\n } catch (failed) {\r\n err = { e: failed };\r\n if (iter.throw) {\r\n iterResult = NULL_VALUE;\r\n iter.throw(err);\r\n }\r\n } finally {\r\n try {\r\n if (iterResult && !iterResult.done) {\r\n iter.return && iter.return(iterResult);\r\n }\r\n } finally {\r\n if (err) {\r\n // eslint-disable-next-line no-unsafe-finally\r\n throw err.e;\r\n }\r\n }\r\n }\r\n }\r\n }\r\n}\r\n","/*\r\n * @nevware21/ts-utils\r\n * https://github.com/nevware21/ts-utils\r\n *\r\n * Copyright (c) 2022 NevWare21 Solutions LLC\r\n * Licensed under the MIT license.\r\n */\r\n\r\nimport { getKnownSymbol } from \"../symbol/symbol\";\r\nimport { WellKnownSymbols } from \"../symbol/well_known\";\r\nimport { isFunction, isStrictNullOrUndefined } from \"../helpers/base\";\r\n\r\n/**\r\n * Checks if the type of value looks like an iterator instance (contains a next function).\r\n *\r\n * @since 0.4.0\r\n * @group Type Identity\r\n * @group Iterator\r\n * @typeParam T - Identifies the return type of the iterator defaults to any\r\n * @param value - The value to be checked\r\n * @returns {boolean} True if the value is an Iterator, otherwise false\r\n * @example\r\n * ```ts\r\n * isIterator(null); // false\r\n * isIterator(undefined); // false\r\n * isIterator(\"null\"); // false (Strings are iterable but not iterators)\r\n * isIterator([]); // false (Arrays are iterable but not iterators)\r\n * isIterator({\r\n * next: function() { return true }\r\n * }); // true, iterators must contain a \"next\" function\r\n * ```\r\n */\r\n/*#__NO_SIDE_EFFECTS__*/\r\nexport function isIterator(value: any): value is Iterator {\r\n return !!value && isFunction(value.next);\r\n}\r\n\r\n/**\r\n * Checks if the value looks like it is iterable, contains a [symbol.iterator].\r\n *\r\n * @since 0.4.0\r\n * @group Type Identity\r\n * @group Iterator\r\n * @typeParam T - Identifies the return type of the iterator\r\n * @param value - The value to be checked\r\n * @returns {boolean} True if the value is an Iterable, otherwise false\r\n * @example\r\n * ```ts\r\n * isIterable(null); // false\r\n * isIterable(undefined); // false\r\n * isIterable(\"null\"); // true (Strings are iterable)\r\n * isIterable([]); // true (Arrays are iterable)\r\n * ```\r\n */\r\n/*#__NO_SIDE_EFFECTS__*/\r\nexport function isIterable(value: any): value is Iterable {\r\n return !isStrictNullOrUndefined(value) && isFunction(value[getKnownSymbol(WellKnownSymbols.iterator)]);\r\n}","/*\r\n * @nevware21/ts-utils\r\n * https://github.com/nevware21/ts-utils\r\n *\r\n * Copyright (c) 2023 NevWare21 Solutions LLC\r\n * Licensed under the MIT license.\r\n */\r\n\r\nimport { ArrSlice, CALL } from \"../internal/constants\";\r\n\r\n/**\r\n * The `fnApply` function calls the specified `fn` function with the given `thisArg` as the `this` value,\r\n * and the optional `argArray` arguments provided as an array (or an Array-Like Object).\r\n *\r\n * Normally, when calling a function, the value of `this` inside the function is the object that the\r\n * function was accessed on. With `fnApply()`, you can assign an arbitrary value as this when calling an\r\n * existing function, without first attaching the function to the object as a property. This allows you\r\n * to use methods of one object as generic utility functions.\r\n *\r\n * You can also use any kind of object which is ArrayLike as the second parameter. In practice, this means\r\n * that it needs to have a length property, and integer (\"index\") properties in the range (0..length - 1).\r\n * For example, you could use a NodeList, or a custom object like `{ 'length': 2, '0': 'eat', '1': 'bananas' }`.\r\n * You can also use `arguments`.\r\n *\r\n * @since 0.9.8\r\n * @group Function\r\n *\r\n * @param fn - The function to be called\r\n * @param thisArg - The value of `this` provided for the call to `fn`. If the function is not in strict mode,\r\n * `null` and `undefined` will be replaced with the global object, and primitive values will be converted to objects.\r\n * @param argArray - An array-like object, specifying the arguments with which `fn` should be called, or `null` or\r\n * `undefined` if no arguments should be provided to the function.\r\n * @returns The result of calling the function with the specified `this` value and arguments.\r\n * @example\r\n * ```ts\r\n * // min / max number in an array\r\n * let max = fnApply(Math.max, null, [ 21, 42, 84, 168, 7, 3 ]);\r\n * // 168\r\n *\r\n * let min = fnApply(Math.min, null, [ 21, 42, 84, 168, 7, 3 ]);\r\n * // 3\r\n *\r\n * const module1 = {\r\n * prefix: \"Hello\",\r\n * x: 21,\r\n * getX() {\r\n * return this.x;\r\n * },\r\n * log(value: string) {\r\n * return this.prefix + \" \" + value + \" : \" + this.x\r\n * }\r\n * };\r\n *\r\n * // The 'this' parameter of 'getX' is bound to 'module'.\r\n * module1.getX(); // 21\r\n * module1.log(\"Darkness\"); // Hello Darkness : 21\r\n *\r\n * // Create a new function 'boundGetX' with the 'this' parameter bound to 'module'.\r\n * let module2 = {\r\n * prefix: \"my\",\r\n * x: 42\r\n * };\r\n *\r\n * // Call the function of module1 with module2 as it's this\r\n * fnApply(module1.getX, module2); // 42\r\n * fnApply(module1.log, module2, [ \"friend\" ]); // my friend : 42\r\n * ```\r\n */\r\nexport function fnApply any, T>(fn: F, thisArg: T, argArray?: ArrayLike): ReturnType {\r\n return fn.apply(thisArg, argArray);\r\n}\r\n\r\n/**\r\n * The `fnCall` function calls the function with the given `thisArg` as the `this` value and with\r\n * al of the `_args` provided as it's `arguments.\r\n *\r\n * > This is almost identical to `fnApply`, except that the function arguments are passed to `fnCall`\r\n * individually as a list, while with `fnApply` that are combined into a single array argument.\r\n *\r\n * Normally, when calling a function, the value of `this` inside the function is the object that the\r\n * function was accessed on. With `fnCall()`, you can pass an arbitrary value as the `this` when calling an\r\n * existing function, without first attaching the function to the object as a property. This allows you\r\n * to use methods of one object as generic utility functions.\r\n *\r\n * @since 0.9.8\r\n * @group Function\r\n *\r\n * @param fn - The function to be called\r\n * @param thisArg - The value of `this` provided for the call to `fn`. If the function is not in strict mode,\r\n * `null` and `undefined` will be replaced with the global object, and primitive values will be converted to objects.\r\n * @param _args - The zero or more arguments to be passed to the `fn` function.\r\n * @returns The result of calling the function with the specified `this` value and arguments.\r\n * @example\r\n * ```ts\r\n * // min / max number in an array\r\n * let max = fnCall(Math.max, null, 21, 42, 84, 168, 7, 3);\r\n * // 168\r\n *\r\n * let min = fnCall(Math.min, null, 21, 42, 84, 168, 7, 3);\r\n * // 3\r\n *\r\n * const module1 = {\r\n * prefix: \"Hello\",\r\n * x: 21,\r\n * getX() {\r\n * return this.x;\r\n * },\r\n * log(value: string) {\r\n * return this.prefix + \" \" + value + \" : \" + this.x\r\n * }\r\n * };\r\n *\r\n * // The 'this' parameter of 'getX' is bound to 'module'.\r\n * module1.getX(); // 21\r\n * module1.log(\"Darkness\"); // Hello Darkness : 21\r\n *\r\n * // Create a new function 'boundGetX' with the 'this' parameter bound to 'module'.\r\n * let module2 = {\r\n * prefix: \"my\",\r\n * x: 42\r\n * };\r\n *\r\n * // Call the function of module1 with module2 as it's this\r\n * fnCall(module1.getX, module2); // 42\r\n * fnCall(module1.log, module2, \"friend\"); // my friend : 42\r\n * ```\r\n */\r\nexport function fnCall any, T>(fn: F, thisArg: T, ...argArray: any[]): ReturnType;\r\n\r\n/**\r\n * The `fnCall` function calls the function with the given `thisArg` as the `this` value and with\r\n * al of the `_args` provided as it's `arguments.\r\n *\r\n * > This is almost identical to `fnApply`, except that the function arguments are passed to `fnCall`\r\n * individually as a list, while with `fnApply` that are combined into a single array argument.\r\n *\r\n * Normally, when calling a function, the value of `this` inside the function is the object that the\r\n * function was accessed on. With `fnCall()`, you can pass an arbitrary value as the `this` when calling an\r\n * existing function, without first attaching the function to the object as a property. This allows you\r\n * to use methods of one object as generic utility functions.\r\n *\r\n * @since 0.9.8\r\n * @group Function\r\n *\r\n * @param fn - The function to be called\r\n * @param thisArg - The value of `this` provided for the call to `fn`. If the function is not in strict mode,\r\n * `null` and `undefined` will be replaced with the global object, and primitive values will be converted to objects.\r\n * @param _args - The zero or more arguments to be passed to the `fn` function.\r\n * @returns The result of calling the function with the specified `this` value and arguments.\r\n * @example\r\n * ```ts\r\n * const module1 = {\r\n * prefix: \"Hello\",\r\n * x: 21,\r\n * getX() {\r\n * return this.x;\r\n * },\r\n * log(value: string) {\r\n * return this.prefix + \" \" + value + \" : \" + this.x\r\n * }\r\n * };\r\n *\r\n * // The 'this' parameter of 'getX' is bound to 'module'.\r\n * module1.getX(); // 21\r\n * module1.log(\"Darkness\"); // Hello Darkness : 21\r\n *\r\n * // Create a new function 'boundGetX' with the 'this' parameter bound to 'module'.\r\n * let module2 = {\r\n * prefix: \"my\",\r\n * x: 42\r\n * };\r\n *\r\n * // Call the function of module1 with module2 as it's this\r\n * fnCall(module1.getX, module2); // 42\r\n * fnCall(module1.log, module2, \"friend\"); // my friend : 42\r\n * ```\r\n */\r\nexport function fnCall any, T>(fn: F, thisArg: T): ReturnType {\r\n return fn.apply(thisArg, ArrSlice[CALL](arguments, 2));\r\n}\r\n\r\n/**\r\n * Creates a new function that when called will set the value of `thisArg` as the `this` keyword\r\n * value whrn calling the provided `fn` instance, and all of the arguments passed to the new\r\n * function will be passed along to the original provided instance.\r\n * @param fn - The function instance to be called\r\n * @param thisArg - The value to be used as the `this` when calling the `fn`\r\n * @returns The value returned by the original `fn` after executing with the provided `thisArg`.\r\n * @since 0.9.8\r\n * @group Function\r\n * @example\r\n * ```ts\r\n * const module1 = {\r\n * x: 21,\r\n * getX() {\r\n * return this.x;\r\n * },\r\n * };\r\n *\r\n * // The 'this' parameter of 'getX' is bound to 'module'.\r\n * console.log(module1.getX()); // 21\r\n *\r\n * // Create a new function 'boundGetX' with the 'this' parameter bound to 'module'.\r\n * let module2 = {\r\n * x: 42\r\n * };\r\n *\r\n * module2.getX = fnBind(module1.getX, module2);\r\n * module2.getX(); // 42\r\n *\r\n * // It can also be used to proxy to the original function from the new one\r\n * module2.getX = fnBind(module1.getX, module1);\r\n * module2.getX(); // 21\r\n * ```\r\n */\r\nexport function fnBind(fn: F, thisArg: T, ...argArray: any[]): F;\r\n\r\n/**\r\n * Creates a new function that when called will set the value of `thisArg` as the `this` keyword\r\n * value whrn calling the provided `fn` instance, and all of the arguments passed to the new\r\n * function will be passed along to the original provided instance.\r\n * @param fn - The function instance to be called\r\n * @param thisArg - The value to be used as the `this` when calling the `fn`\r\n * @returns The value returned by the original `fn` after executing with the provided `thisArg`.\r\n * @since 0.9.8\r\n * @group Function\r\n * @example\r\n * ```ts\r\n * const module1 = {\r\n * x: 21,\r\n * getX() {\r\n * return this.x;\r\n * },\r\n * };\r\n *\r\n * // The 'this' parameter of 'getX' is bound to 'module'.\r\n * console.log(module1.getX()); // 21\r\n *\r\n * // Create a new function 'boundGetX' with the 'this' parameter bound to 'module'.\r\n * let module2 = {\r\n * x: 42\r\n * };\r\n *\r\n * module2.getX = fnBind(module1.getX, module2);\r\n * module2.getX(); // 42\r\n *\r\n * // It can also be used to proxy to the original function from the new one\r\n * module2.getX = fnBind(module1.getX, module1);\r\n * module2.getX(); // 21\r\n * ```\r\n */\r\nexport function fnBind(fn: F, thisArg: T): F {\r\n return fn.bind.apply(fn, ArrSlice[CALL](arguments, 1));\r\n}\r\n","/*\r\n * @nevware21/ts-utils\r\n * https://github.com/nevware21/ts-utils\r\n *\r\n * Copyright (c) 2022 NevWare21 Solutions LLC\r\n * Licensed under the MIT license.\r\n */\r\n\r\nimport { isArray, isUndefined } from \"../helpers/base\";\r\nimport { isIterable, isIterator } from \"../iterator/iterator\";\r\nimport { iterForOf } from \"../iterator/forOf\";\r\nimport { fnApply } from \"../funcs/funcs\";\r\n\r\n/**\r\n * Appends the `elms` to the `target` where the elms may be an array, a single object\r\n * or an iterator object\r\n * @group Array\r\n * @group Iterator\r\n * @example\r\n * ```ts\r\n * let theArray = arrAppend([], 1);\r\n * arrAppend(theArray, [ 2, 3, 4 ]);\r\n * arrAppend(theArray, [ \"a\", \"b\", \"c\" ]);\r\n * // theArray is now [ 1, 2, 3, 4, \"a\", \"b\", \"c\" ]\r\n * ```\r\n * @param target - The target array\r\n * @param elms - The item, array of items an iterable or iterator object of items to add to the target\r\n * @returns The passed in target array\r\n * @example\r\n * ```ts\r\n * // Adding a single value\r\n * arrAppend([], undefined); // []\r\n * arrAppend([], 0); // [ 0 ]\r\n * arrAppend([1], undefined); // [ 1 ]\r\n * arrAppend([1], 2); // [ 1, 2 ]\r\n *\r\n * // Adding an array\r\n * arrAppend([], [] as number[]); // []\r\n * arrAppend([], [0]); // [ 0 ]\r\n * arrAppend([1], []); // [ 1 ]\r\n * arrAppend([1], [2]); // [ 1, 2 ]\r\n *\r\n * // Adding with an iterator\r\n * arrAppend([], ([] as number[]).values()); // []\r\n * arrAppend([], [0].values()); // [ 0 ]\r\n * arrAppend([1], [].keys()); // [ 1 ]\r\n * arrAppend([1], [2].values()); // [ 1, 2 ]\r\n * arrAppend([1], [2].keys()); // [ 1, 0 ] - 0 is from the index from the first element\r\n * ```\r\n */\r\nexport function arrAppend(target: T[], elms: T | T[] | Iterator): T[] {\r\n if (!isUndefined(elms) && target) {\r\n if (isArray(elms)) {\r\n // This is not just \"target.push(elms)\" but becomes effectively \"target.push(elms[0], elms[1], ...)\"\r\n fnApply(target.push, target, elms);\r\n } else if (isIterator(elms) || isIterable(elms)) {\r\n iterForOf(elms, (elm) => {\r\n target.push(elm);\r\n });\r\n } else {\r\n target.push(elms);\r\n }\r\n }\r\n\r\n return target;\r\n}\r\n","/*\r\n * @nevware21/ts-utils\r\n * https://github.com/nevware21/ts-utils\r\n *\r\n * Copyright (c) 2022 NevWare21 Solutions LLC\r\n * Licensed under the MIT license.\r\n */\r\n\r\nimport { CALL, LENGTH } from \"../internal/constants\";\r\n\r\n/**\r\n * Calls the provided `callbackFn` function once for each element in an array in ascending index order. It is not invoked for index properties\r\n * that have been deleted or are uninitialized. And unlike the ES6 forEach() you CAN stop or break the iteration by returning -1 from the\r\n * `callbackFn` function.\r\n *\r\n * The range (number of elements) processed by arrForEach() is set before the first call to the `callbackFn`. Any elements added beyond the range\r\n * or elements which as assigned to indexes already processed will not be visited by the `callbackFn`.\r\n * @group Array\r\n * @group ArrayLike\r\n * @typeParam T - Identifies the element type of the array\r\n * @param theArray - The array or array like object of elements to be searched.\r\n * @param callbackfn A `synchronous` function that accepts up to three arguments. arrForEach calls the callbackfn function one time for each element in the array.\r\n * @param thisArg An object to which the this keyword can refer in the callbackfn function. If thisArg is omitted, null or undefined\r\n * the array will be used as the this value.\r\n * @remarks\r\n * arrForEach expects a `synchronous` function.\r\n * arrForEach does not wait for promises. Make sure you are aware of the implications while using promises (or async functions) as forEach callback.\r\n * @example\r\n * ```ts\r\n * const items = ['item1', 'item2', 'item3'];\r\n * const copyItems = [];\r\n *\r\n * // before using for loop\r\n * for (let i = 0; i < items.length; i++) {\r\n * copyItems.push(items[i]);\r\n * }\r\n *\r\n * // before using forEach()\r\n * items.forEach((item) => {\r\n * copyItems.push(item);\r\n * });\r\n *\r\n * // after\r\n * arrForEach(items, (item) => {\r\n * copyItems.push(item);\r\n * // May return -1 to abort the iteration\r\n * });\r\n *\r\n * // Also supports input as an array like object\r\n * const items = { length: 3, 0: 'item1', 1: 'item2', 2: 'item3' };\r\n * ```\r\n */\r\nexport function arrForEach(theArray: ArrayLike, callbackfn: (value: T, index: number, array: T[]) => void | number, thisArg?: any): void {\r\n if (theArray) {\r\n const len = theArray[LENGTH] >>> 0;\r\n for (let idx = 0; idx < len; idx++) {\r\n if (idx in theArray) {\r\n if (callbackfn[CALL](thisArg || theArray, theArray[idx], idx, theArray) === -1) {\r\n break;\r\n }\r\n }\r\n }\r\n }\r\n}\r\n","/*\r\n * @nevware21/ts-utils\r\n * https://github.com/nevware21/ts-utils\r\n *\r\n * Copyright (c) 2022 NevWare21 Solutions LLC\r\n * Licensed under the MIT license.\r\n */\r\n\r\nimport { ArrProto } from \"../internal/constants\";\r\nimport { _unwrapFunction } from \"../internal/unwrapFunction\";\r\n\r\n/**\r\n * The arrIndexOf() method returns the first index at which a given element can be found in the array,\r\n * or -1 if it is not present.\r\n * `arrIndexOf()` compares searchElement to elements of the Array using strict equality (the same\r\n * method used by the === or triple-equals operator).\r\n * @group Array\r\n * @group ArrayLike\r\n * @typeParam T - Identifies the type of array elements\r\n * @param theArray - The array or array like object of elements to be searched.\r\n * @param searchElement - The element to locate in the array.\r\n * @param fromIndex - The index to start the search at. If the index is greater than or equal to\r\n * the array's length, -1 is returned, which means the array will not be searched. If the provided\r\n * index value is a negative number, it is taken as the offset from the end of the array.\r\n * Note: if the provided index is negative, the array is still searched from front to back. If the\r\n * provided index is 0, then the whole array will be searched. Default: 0 (entire array is searched).\r\n * @return The first index of the element in the array; -1 if not found.\r\n * @example\r\n * ```ts\r\n * const array = [2, 9, 9];\r\n * arrIndexOf(array, 2); // 0\r\n * arrIndexOf(array, 7); // -1\r\n * arrIndexOf(array, 9, 2); // 2\r\n * arrIndexOf(array, 2, -1); // -1\r\n * arrIndexOf(array, 2, -3); // 0\r\n *\r\n * let indices: number[] = [];\r\n * const array = ['a', 'b', 'a', 'c', 'a', 'd'];\r\n * const element = 'a';\r\n * let idx = arrIndexOf(array, element);\r\n * while (idx !== -1) {\r\n * indices.push(idx);\r\n * idx = arrIndexOf(array, element, idx + 1);\r\n * }\r\n * console.log(indices);\r\n * // [0, 2, 4]\r\n *\r\n * function updateVegetablesCollection (veggies, veggie) {\r\n * if (arrIndexOf(veggies, veggie) === -1) {\r\n * veggies.push(veggie);\r\n * console.log('New veggies collection is : ' + veggies);\r\n * } else {\r\n * console.log(veggie + ' already exists in the veggies collection.');\r\n * }\r\n * }\r\n *\r\n * let veggies = ['potato', 'tomato', 'chillies', 'green-pepper'];\r\n *\r\n * updateVegetablesCollection(veggies, 'spinach');\r\n * // New veggies collection is : potato,tomato,chillies,green-pepper,spinach\r\n * updateVegetablesCollection(veggies, 'spinach');\r\n * // spinach already exists in the veggies collection.\r\n *\r\n * // Array Like\r\n * let arrayLike = {\r\n * length: 3,\r\n * 0: \"potato\",\r\n * 1: \"tomato\",\r\n * 2: \"chillies\",\r\n * 3: \"green-pepper\" // Not checked as index is > length\r\n * };\r\n *\r\n * arrIndexOf(arrayLike, \"potato\"); // 0\r\n * arrIndexOf(arrayLike, \"tomato\"); // 1\r\n * arrIndexOf(arrayLike, \"chillies\"); 2\r\n * arrIndexOf(arrayLike, \"green-pepper\"); // -1\r\n * ```\r\n */\r\nexport const arrIndexOf: (theArray: ArrayLike, searchElement: T, fromIndex?: number) => number = (/*#__PURE__*/_unwrapFunction(\"indexOf\", ArrProto));\r\n\r\n/**\r\n * The arrLastIndexOf() method returns the last index at which a given element can be found in the array,\r\n * or -1 if it is not present.\r\n * `arrLastIndexOf()` compares searchElement to elements of the Array using strict equality (the same\r\n * method used by the === or triple-equals operator). [NaN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/NaN)\r\n * values are never compared as equal, so arrLastIndexOf() always returns -1 when searchElement is NaN.\r\n *\r\n * The arrLastIndexOf() method skips empty slots in sparse arrays.\r\n *\r\n * The arrLastIndexOf() method is generic. It only expects the this value to have a length property and integer-keyed properties.\r\n *\r\n * @since 0.8.0\r\n * @group Array\r\n * @group ArrayLike\r\n * @typeParam T - Identifies the type of array elements\r\n * @param theArray - The array or array like object of elements to be searched.\r\n * @param searchElement - The element to locate in the array.\r\n * @param fromIndex - Zero-based index at which to start searching backwards, converted to an integer.\r\n * - Negative index counts back from the end of the array — if fromIndex < 0, fromIndex + array.length is used.\r\n * - If fromIndex < -array.length, the array is not searched and -1 is returned. You can think of it conceptually\r\n * as starting at a nonexistent position before the beginning of the array and going backwards from there. There\r\n * are no array elements on the way, so searchElement is never found.\r\n * - If fromIndex >= array.length or fromIndex is omitted, array.length - 1 is used, causing the entire array to\r\n * be searched. You can think of it conceptually as starting at a nonexistent position beyond the end of the array and going backwards from there. It eventually reaches the real end position of the array, at which point it starts searching backwards through the actual array elements.\r\n * @return The first index of the element in the array; -1 if not found.\r\n * @example\r\n * ```ts\r\n * const numbers = [2, 5, 9, 2];\r\n * arrLastIndexOf(numbers, 2); // 3\r\n * arrLastIndexOf(numbers, 7); // -1\r\n * arrLastIndexOf(numbers, 2, 3); // 3\r\n * arrLastIndexOf(numbers, 2, 2); // 0\r\n * arrLastIndexOf(numbers, 2, -2); // 0\r\n * arrLastIndexOf(numbers, 2, -1); // 3\r\n *\r\n * let indices: number[] = [];\r\n * const array = [\"a\", \"b\", \"a\", \"c\", \"a\", \"d\"];\r\n * const element = \"a\";\r\n * let idx = arrLastIndexOf(array, element);\r\n * while (idx !== -1) {\r\n * indices.push(idx);\r\n * idx = arrLastIndexOf(array, element, idx ? idx - 1 : -(array.length + 1));\r\n * }\r\n * console.log(indices);\r\n * // [4, 2, 0]\r\n *\r\n * function updateVegetablesCollection (veggies, veggie) {\r\n * if (arrLastIndexOf(veggies, veggie) === -1) {\r\n * veggies.push(veggie);\r\n * console.log('New veggies collection is : ' + veggies);\r\n * } else {\r\n * console.log(veggie + ' already exists in the veggies collection.');\r\n * }\r\n * }\r\n *\r\n * let veggies = ['potato', 'tomato', 'chillies', 'green-pepper'];\r\n *\r\n * updateVegetablesCollection(veggies, 'spinach');\r\n * // New veggies collection is : potato,tomato,chillies,green-pepper,spinach\r\n * updateVegetablesCollection(veggies, 'spinach');\r\n * // spinach already exists in the veggies collection.\r\n *\r\n * // Array Like\r\n * let arrayLike = {\r\n * length: 3,\r\n * 0: \"potato\",\r\n * 1: \"tomato\",\r\n * 2: \"chillies\",\r\n * 3: \"green-pepper\" // Not checked as index is > length\r\n * };\r\n *\r\n * arrLastIndexOf(arrayLike, \"potato\"); // 0\r\n * arrLastIndexOf(arrayLike, \"tomato\"); // 1\r\n * arrLastIndexOf(arrayLike, \"chillies\"); 2\r\n * arrLastIndexOf(arrayLike, \"green-pepper\"); // -1\r\n * ```\r\n */\r\nexport const arrLastIndexOf: (theArray: ArrayLike, searchElement: T, fromIndex?: number) => number = (/*#__PURE__*/_unwrapFunction(\"lastIndexOf\", ArrProto));","/*\r\n * @nevware21/ts-utils\r\n * https://github.com/nevware21/ts-utils\r\n *\r\n * Copyright (c) 2022 NevWare21 Solutions LLC\r\n * Licensed under the MIT license.\r\n */\r\n\r\nimport { ArrProto } from \"../internal/constants\";\r\nimport { _unwrapFunction } from \"../internal/unwrapFunction\";\r\nimport { ArrMapCallbackFn } from \"./callbacks\";\r\n\r\n/**\r\n * The arrMap() method creates a new array populated with the results of calling a provided function on every\r\n * element in the calling array.\r\n *\r\n * `arrMap` calls a provided callbackFn function once for each element in an array, in order, and constructs\r\n * a new array from the results. callbackFn is invoked only for indexes of the array which have assigned\r\n * values (including undefined).\r\n *\r\n * It is not called for missing elements of the array; that is:\r\n * - indexes that have never been set;\r\n * - indexes which have been deleted.\r\n *\r\n * @since 0.3.3\r\n * @group Array\r\n * @group ArrayLike\r\n * @typeParam T - Identifies the type of the array elements\r\n * @typeParam R - Identifies the type of the elements returned by the callback function, defaults to T.\r\n * @param theArray - The array or array like object of elements to be searched.\r\n * @param callbackFn - The function that is called for evetn element of `theArray`.\r\n * @param thisArg - The value to use as the `this` when executing the `callbackFn`.\r\n * @example\r\n * ```ts\r\n * const numbers = [1, 4, 9];\r\n * const roots = arrMap(numbers, (num) => Math.sqrt(num));\r\n *\r\n * // roots is now [1, 2, 3]\r\n * // numbers is still [1, 4, 9]\r\n *\r\n * const kvArray = [{ key: 1, value: 10 },\r\n * { key: 2, value: 20 },\r\n * { key: 3, value: 30 }];\r\n *\r\n * const reformattedArray = arrMap(kvArray, ({ key, value}) => ({ [key]: value }));\r\n *\r\n * // reformattedArray is now [{1: 10}, {2: 20}, {3: 30}],\r\n *\r\n * // kvArray is still:\r\n * // [{key: 1, value: 10},\r\n * // {key: 2, value: 20},\r\n * // {key: 3, value: 30}]\r\n *\r\n * // Also supports Array Like objects with same output\r\n * const kvArray = {\r\n * length: 3,\r\n * 0: { key: 1, value: 10 },\r\n * 1: { key: 2, value: 20 },\r\n * 2: { key: 3, value: 30 }\r\n * };\r\n * ```\r\n */\r\nexport const arrMap: (theArray: ArrayLike, callbackFn: ArrMapCallbackFn, thisArg?: any) => R[] = (/*#__PURE__*/_unwrapFunction(\"map\", ArrProto));\r\n","/*\r\n * @nevware21/ts-utils\r\n * https://github.com/nevware21/ts-utils\r\n *\r\n * Copyright (c) 2022 NevWare21 Solutions LLC\r\n * Licensed under the MIT license.\r\n */\r\n\r\nimport { ArrSlice, CALL, NULL_VALUE } from \"../internal/constants\";\r\n\r\n/**\r\n * The arrSlice() method returns a shallow copy of a portion of an array into a new array object\r\n * selected from start to end (end not included) where start and end represent the index of items\r\n * in that array. The original array will not be modified.\r\n *\r\n * The `arrSlice()` method is a copying method. It does not alter this but instead returns a shallow\r\n * copy that contains some of the same elements as the ones from the original array.\r\n *\r\n * The `arrSlice()` method preserves empty slots. If the sliced portion is sparse, the returned arra\r\n * is sparse as well.\r\n *\r\n * The `arrSlice()` method is generic. It only expects the this value to have a length property and\r\n * integer-keyed properties.\r\n *\r\n * For both start and end, a negative index can be used to indicate an offset from the end of the array.\r\n * For example, -2 refers to the second to last element of the array.\r\n * @since 0.9.3\r\n * @group Array\r\n * @group ArrayLike\r\n * @param start Zero-based index at which to start extraction, converted to an integer.\r\n * - Negative index counts back from the end of the array — if start < 0, start + array.length is used.\r\n * - If start < -array.length or start is omitted, 0 is used.\r\n * - If start >= array.length, nothing is extracted.\r\n * @param end Zero-based index at which to end extraction, converted to an integer. slice() extracts\r\n * up to but not including end.\r\n * - Negative index counts back from the end of the array — if end < 0, end + array.length is used.\r\n * - If end < -array.length, 0 is used.\r\n * - If end >= array.length or end is omitted, array.length is used, causing all elements until the\r\n * end to be extracted.\r\n * - If end is positioned before or at start after normalization, nothing is extracted.\r\n * @example\r\n * ```ts\r\n * const lyrics = [\"Hello\", \"Darkness\", \"my\", \"old\", \"friend.\", \"I've\", \"come\", \"to\", \"talk\" ];\r\n *\r\n * arrSlice(lyrics); // [ \"Hello\", \"Darkness\", \"my\", \"old\", \"friend.\", \"I've\", \"come\", \"to\", \"talk\" ]\r\n * arrSlice(lyrics, 1, 3); // [ \"Darkness\", \"my\" ]\r\n * arrSlicw(lyrics, 2); // [ \"my\", \"old\", \"friend.\", \"I've\", \"come\", \"to\", \"talk\" ]\r\n * arrSlice(lyrics, 2, 4); // [ \"my\", \"old\" ]\r\n * arrSlice(lyrics, 1, 5); // [ \"Darkness\", \"my\", \"old\", \"friend.\" ]\r\n * arrSlice(lyrics, -2); // [ \"to\", \"talk\" ]\r\n * arrSlice(lyrics, 2, -1); // [ \"my\", \"old\", \"friend.\", \"I've\", \"come\", \"to\" ]\r\n * ```\r\n */\r\nexport function arrSlice(theArray: ArrayLike, start?: number, end?: number): T[] {\r\n return ((theArray ? theArray[\"slice\"] : NULL_VALUE) || ArrSlice).apply(theArray, ArrSlice[CALL](arguments, 1));\r\n}\r\n","/*\r\n * @nevware21/ts-utils\r\n * https://github.com/nevware21/ts-utils\r\n *\r\n * Copyright (c) 2022 NevWare21 Solutions LLC\r\n * Licensed under the MIT license.\r\n */\r\n\r\nimport { ArrProto } from \"../internal/constants\";\r\nimport { _unwrapFunctionWithPoly } from \"../internal/unwrapFunction\";\r\nimport { polyArrFind, polyArrFindIndex, polyArrFindLast, polyArrFindLastIndex } from \"../polyfills/array\";\r\nimport { ArrPredicateCallbackFn, ArrPredicateCallbackFn2 } from \"./callbacks\";\r\n\r\n/**\r\n * The arrFind() method returns the first element in the provided array that satisfies\r\n * the provided testing function. If no values satisfy the testing function, undefined\r\n * is returned.\r\n * - If you need the index of the found element in the array, use {@link arrFindIndex}.\r\n * - If you need to find the index of a value, use arrIndexOf(). (It's similar to {@link arrFindIndex}, but\r\n * checks each element for equality with the value instead of using a testing function.)\r\n * - If you need to find if a value exists in an array, use {@link arrIncludes}. Again, it checks each element for\r\n * equality with the value instead of using a testing function.\r\n * - If you need to find if any element satisfies the provided testing function, use {@link arrSome}.\r\n *\r\n * The arrFind() method is an iterative method. It calls a provided `callbackFn` function once for each element\r\n * in an array in ascending-index order, until `callbackFn` returns a truthy value. arrFind() then returns that\r\n * element and stops iterating through the array. If callbackFn never returns a truthy value, arrFind() returns\r\n * undefined.\r\n *\r\n * `callbackFn` is invoked for every index of the array, not just those with assigned values. Empty slots in\r\n * sparse arrays behave the same as undefined.\r\n *\r\n * arrFind() does not mutate the array on which it is called, but the function provided as callbackFn can.\r\n * Note, however, that the length of the array is saved before the first invocation of `callbackFn`. Therefore:\r\n * - `callbackFn` will not visit any elements added beyond the array's initial length when the call to arrFind() began.\r\n * - Changes to already-visited indexes do not cause callbackFn to be invoked on them again.\r\n * - If an existing, yet-unvisited element of the array is changed by callbackFn, its value passed to the\r\n * `callbackFn` will be the value at the time that element gets visited. Deleted elements are visited as if they\r\n * were undefined.\r\n * @since 0.8.0\r\n * @group Array\r\n * @group ArrayLike\r\n * @typeParam T - Identifies the base type of array elements\r\n * @typeParam E - Identifies a more specific instance of the base array type\r\n * @param theArray - The array or array like object of elements to be searched.\r\n * @param callbackFn A function that accepts up to three arguments of type {@link ArrPredicateCallbackFn} or\r\n * {@link ArrPredicateCallbackFn2}. The predicate function is called for each element in the thArray until\r\n * the predicate returns a value which is coercible to the Boolean value false, or until the end of the array.\r\n * @param thisArg - A value to use as this when executing callbackFn. Defaults to the array if not provided.\r\n * @return The first element in the array that satisfies the provided testing function. Otherwise, undefined\r\n * is returned.\r\n * @example\r\n * ```ts\r\n * const inventory = [\r\n * { name: \"apples\", quantity: 2 },\r\n * { name: \"bananas\", quantity: 0 },\r\n * { name: \"cherries\", quantity: 5 },\r\n * ];\r\n *\r\n * function isCherries(fruit) {\r\n * return fruit.name === \"cherries\";\r\n * }\r\n *\r\n * console.log(arrFind(inventory, isCherries));\r\n * // { name: 'cherries', quantity: 5 }\r\n *\r\n * function isPrime(element, index, array) {\r\n * let start = 2;\r\n * while (start <= Math.sqrt(element)) {\r\n * if (element % start++ < 1) {\r\n * return false;\r\n * }\r\n * }\r\n * return element > 1;\r\n * }\r\n *\r\n * console.log(arrFind([4, 6, 8, 12], isPrime)); // undefined, not found\r\n * console.log(arrFind([4, 5, 8, 12], isPrime)); // 5\r\n *\r\n * // Array Like\r\n * console.log(arrFind({ length: 4, 0: 4, 1: 6, 2: 8, 3: 12 }, isPrime)); // undefined, not found\r\n * console.log(arrFind({ length: 4:, 0: 4, 1: 5, 2: 8, 3: 12 }, isPrime)); // 5\r\n * ```\r\n */\r\nexport const arrFind = (/*#__PURE__*/_unwrapFunctionWithPoly(\"find\", ArrProto, polyArrFind) as (theArray: ArrayLike, callbackFn: ArrPredicateCallbackFn | ArrPredicateCallbackFn2, thisArg?: any) => T | E | undefined);\r\n\r\n/**\r\n * The arrFindIndex() method returns the index of the first element in an array that satisfies the provided testing\r\n * function. If no elements satisfy the testing function, -1 is returned.\r\n *\r\n * The arrFindIndex() is an iterative method. It calls a provided callbackFn function once for each element in an\r\n * array in ascending-index order, until callbackFn returns a truthy value. arrFindIndex() then returns the index\r\n * of that element and stops iterating through the array. If `callbackFn` never returns a truthy value, arrFindIndex()\r\n * returns -1.\r\n *\r\n * `callbackFn` is invoked for every index of the array, not just those with assigned values. Empty slots in sparse\r\n * arrays behave the same as undefined.\r\n *\r\n * arrFindIndex() does not mutate the array on which it is called, but the function provided as `callbackFn` can.\r\n * Note, however, that the length of the array is saved before the first invocation of callbackFn. Therefore:\r\n * - `callbackFn` will not visit any elements added beyond the array's initial length when the call to arrFindIndex() began.\r\n * - Changes to already-visited indexes do not cause `callbackFn` to be invoked on them again.\r\n * If an existing, yet-unvisited element of the array is changed by `callbackFn`, its value passed to the `callbackFn`\r\n * will be the value at the time that element gets visited. Deleted elements are visited as if they were undefined.\r\n * @since 0.8.0\r\n * @group Array\r\n * @group ArrayLike\r\n * @typeParam T - Identifies the base type of array elements\r\n * @typeParam E - Identifies a more specific instance of the base array type\r\n * @param theArray - The array or array like object of elements to be searched.\r\n * @param callbackFn A function that accepts up to three arguments of type {@link ArrPredicateCallbackFn} or\r\n * {@link ArrPredicateCallbackFn2}. The predicate function is called for each element in the thArray until\r\n * the predicate returns a value which is coercible to the Boolean value false, or until the end of the array.\r\n * @param thisArg - A value to use as this when executing callbackFn. Defaults to the array if not provided.\r\n * @return The index of the first element in the array that passes the test. Otherwise, -1.\r\n * @example\r\n * ```ts\r\n * const inventory: Array<{ name: string, quantity: number}> = [\r\n * { name: \"apples\", quantity: 2 },\r\n * { name: \"bananas\", quantity: 0 },\r\n * { name: \"cherries\", quantity: 5 }\r\n * ];\r\n *\r\n * function isCherries(fruit: { name: string, quantity: number}) {\r\n * return fruit.name === \"cherries\";\r\n * }\r\n *\r\n * arrFindIndex(inventory, isCherries); // 2\r\n *\r\n * function isPrime(element: number) {\r\n * if (element % 2 === 0 || element < 2) {\r\n * return false;\r\n * }\r\n *\r\n * for (let factor = 3; factor <= Math.sqrt(element); factor += 2) {\r\n * if (element % factor === 0) {\r\n * return false;\r\n * }\r\n * }\r\n * return true;\r\n * }\r\n *\r\n * arrFindIndex([4, 6, 8, 9, 12], isPrime) // -1\r\n * arrFindIndex([4, 6, 7, 9, 12], isPrime) // 2\r\n *\r\n * // Array Like\r\n * arrFindIndex({ length: 5, 0: 4, 1: 6, 2: 8, 3: 9, 4: 12 }, isPrime) // -1\r\n * arrFindIndex({ length: 5:, 0: 4, 1: 6, 2: 7, 3: 9, 4: 12 }, isPrime) // 2\r\n * ```\r\n */\r\nexport const arrFindIndex = (/*#__PURE__*/_unwrapFunctionWithPoly(\"findIndex\", ArrProto, polyArrFindIndex) as (theArray: ArrayLike, callbackFn: ArrPredicateCallbackFn | ArrPredicateCallbackFn2, thisArg?: any) => number);\r\n\r\n/**\r\n * The arrFindLast() method iterates the array in reverse order and returns the value of the first element that\r\n * satisfies the provided testing function. If no elements satisfy the testing function, undefined is returned.\r\n * - If you need the index of the found element in the array, use arrFindLastIndex().\r\n * - If you need to find the index of a value, use arrLastIndexOf(). (It's similar to arrFindLastIndex(), but checks\r\n * each element for equality with the value instead of using a testing function.)\r\n * - If you need to find if a value exists in an array, use {@link arrIncludes}. Again, it checks each element for\r\n * equality with the value instead of using a testing function.\r\n * - If you need to find if any element satisfies the provided testing function, use {@link arrSome}.\r\n *\r\n * The arrFindLast() method is an iterative method. It calls a provided callbackFn function once for each element\r\n * in an array in descending-index order, until callbackFn returns a truthy value. arrFindLast() then returns that\r\n * element and stops iterating through the array. If `callbackFn` never returns a truthy value, arrFindLast() returns\r\n * undefined.\r\n *\r\n * `callbackFn` is invoked for every index of the array, not just those with assigned values. Empty slots in sparse\r\n * arrays behave the same as undefined.\r\n *\r\n * arrFindLast() does not mutate the array on which it is called, but the function provided as `callbackFn` can.\r\n * Note, however, that the length of the array is saved before the first invocation of `callbackFn`. Therefore:\r\n * - `callbackFn` will not visit any elements added beyond the array's initial length when the call to arrFindLast() began.\r\n * - Changes to already-visited indexes do not cause callbackFn to be invoked on them again.\r\n * - If an existing, yet-unvisited element of the array is changed by `callbackFn`, its value passed to the `callbackFn`\r\n * will be the value at the time that element gets visited. Deleted elements are visited as if they were undefined.\r\n * @since 0.8.0\r\n * @group Array\r\n * @group ArrayLike\r\n * @typeParam T - Identifies the base type of array elements\r\n * @typeParam E - Identifies a more specific instance of the base array type\r\n * @param theArray - The array or array like object of elements to be searched.\r\n * @param callbackFn A function that accepts up to three arguments of type {@link ArrPredicateCallbackFn} or\r\n * {@link ArrPredicateCallbackFn2}. The predicate function is called for each element in the thArray until\r\n * the predicate returns a value which is coercible to the Boolean value false, or until the end of the array.\r\n * @param thisArg - A value to use as this when executing callbackFn. Defaults to the array if not provided.\r\n * @return The last element in the array that satisfies the provided testing function. Otherwise, undefined\r\n * is returned.\r\n * @example\r\n * ```ts\r\n * const inventory = [\r\n * { name: \"apples\", quantity: 2 },\r\n * { name: \"bananas\", quantity: 0 },\r\n * { name: \"cherries\", quantity: 5 },\r\n * ];\r\n *\r\n * function isCherries(fruit) {\r\n * return fruit.name === \"cherries\";\r\n * }\r\n *\r\n * console.log(arrFindLast(inventory, isCherries));\r\n * // { name: 'cherries', quantity: 5 }\r\n *\r\n * function isPrime(element, index, array) {\r\n * let start = 2;\r\n * while (start <= Math.sqrt(element)) {\r\n * if (element % start++ < 1) {\r\n * return false;\r\n * }\r\n * }\r\n * return element > 1;\r\n * }\r\n *\r\n * console.log(arrFindLast([4, 6, 8, 12], isPrime)); // undefined, not found\r\n * console.log(arrFindLast([4, 5, 7, 12], isPrime)); // 7\r\n *\r\n * // Array Like\r\n * console.log(arrFindLast({ length: 4, 0: 4, 1: 6, 2: 8, 3: 12 }, isPrime)); // undefined, not found\r\n * console.log(arrFindLast({ length: 4, 0: 4, 1: 5, 2: 7, 3: 12 }, isPrime)); // 7\r\n * ```\r\n */\r\nexport const arrFindLast = (/*#__PURE__*/_unwrapFunctionWithPoly(\"findLast\", ArrProto as any, polyArrFindLast) as (theArray: ArrayLike, callbackFn: ArrPredicateCallbackFn | ArrPredicateCallbackFn2, thisArg?: any) => T | E | undefined);\r\n\r\n/**\r\n * The arrFindLastIndex() method iterates the array in reverse order and returns the index of the first element that\r\n * satisfies the provided testing function. If no elements satisfy the testing function, -1 is returned.\r\n *\r\n * The arrFindLastIndex() method is an iterative method. It calls a provided `callbackFn` function once for each element\r\n * in an array in descending-index order, until callbackFn returns a truthy value. arrFindLastIndex() then returns the\r\n * index of that element and stops iterating through the array. If callbackFn never returns a truthy value, returns -1.\r\n *\r\n * `callbackFn` is invoked for every index of the array, not just those with assigned values. Empty slots in sparse arrays\r\n * behave the same as undefined.\r\n *\r\n * arrFindLastIndex() does not mutate the array on which it is called, but the function provided as callbackFn can.\r\n * Note, however, that the length of the array is saved before the first invocation of callbackFn. Therefore:\r\n * - `callbackFn` will not visit any elements added beyond the array's initial length when the call to arrFindLastIndex() began.\r\n * - Changes to already-visited indexes do not cause callbackFn to be invoked on them again.\r\n * - If an existing, yet-unvisited element of the array is changed by `callbackFn`, its value passed to the callbackFn\r\n * will be the value at the time that element gets visited. Deleted elements are visited as if they were undefined.\r\n * @since 0.8.0\r\n * @group Array\r\n * @group ArrayLike\r\n * @typeParam T - Identifies the base type of array elements\r\n * @typeParam E - Identifies a more specific instance of the base array type\r\n * @param theArray - The array or array like object of elements to be searched.\r\n * @param callbackFn A function that accepts up to three arguments of type {@link ArrPredicateCallbackFn} or\r\n * {@link ArrPredicateCallbackFn2}. The predicate function is called for each element in the thArray until\r\n * the predicate returns a value which is coercible to the Boolean value false, or until the end of the array.\r\n * @param thisArg - A value to use as this when executing callbackFn. Defaults to the array if not provided.\r\n * @return The index of the last (highest-index) element in the array that passes the test. Otherwise -1 if\r\n * no matching element is found.\r\n * @example\r\n * ```ts\r\n * const inventory: Array<{ name: string, quantity: number}> = [\r\n * { name: \"apples\", quantity: 2 },\r\n * { name: \"bananas\", quantity: 0 },\r\n * { name: \"cherries\", quantity: 5 }\r\n * ];\r\n *\r\n * let called = 0;\r\n * function isCherries(fruit: { name: string, quantity: number}) {\r\n * called++;\r\n * return fruit.name === \"cherries\";\r\n * }\r\n *\r\n * arrFindLastIndex(inventory, isCherries)' // 2\r\n * // called === 1\r\n *\r\n * called = 0;\r\n * function isPrime(element: number) {\r\n * called++;\r\n * if (element % 2 === 0 || element < 2) {\r\n * return false;\r\n * }\r\n * for (let factor = 3; factor <= Math.sqrt(element); factor += 2) {\r\n * if (element % factor === 0) {\r\n * return false;\r\n * }\r\n * }\r\n * return true;\r\n * }\r\n *\r\n * arrFindLastIndex([4, 6, 8, 9, 12], isPrime); // -1\r\n * // called === 5\r\n *\r\n * called = 0;\r\n * arrFindLastIndex([4, 6, 7, 9, 12], isPrime); // 2\r\n * // called === 3\r\n *\r\n * // Array Like\r\n * called = 0;\r\n * arrFindLastIndex({ length: 5: 0: 4, 1: 6, 2: 8, 3: 9, 4: 12 }, isPrime); // -1\r\n * // called === 5\r\n *\r\n * called = 0;\r\n * arrFindLastIndex({ length: 5: 0: 4, 1: 6, 2: 7, 3: 9, 4: 12 }, isPrime); // 2\r\n * // called === 3\r\n\r\n * ```\r\n */\r\nexport const arrFindLastIndex = (/*#__PURE__*/_unwrapFunctionWithPoly(\"findLastIndex\", ArrProto as any, polyArrFindLastIndex) as (theArray: ArrayLike, callbackFn: ArrPredicateCallbackFn | ArrPredicateCallbackFn2, thisArg?: any) => number);\r\n","/*\r\n * @nevware21/ts-utils\r\n * https://github.com/nevware21/ts-utils\r\n *\r\n * Copyright (c) 2022 NevWare21 Solutions LLC\r\n * Licensed under the MIT license.\r\n */\r\n\r\nimport { ArrProto } from \"../internal/constants\";\r\nimport { _unwrapFunction } from \"../internal/unwrapFunction\";\r\n\r\n/**\r\n * The `reducer` function called for {@link arrReduce}.\r\n * @group Array\r\n * @group ArrayLike\r\n * @typeParam T - Identifies the type of array elements\r\n * @typeParam R - Identifies the type of the return array elements (defaults to T)\r\n * @param previousValue - The value resulting from the previous call to callbackFn. On first call, initialValue if\r\n * specified, otherwise the value of array[0].\r\n * @param currentValue - The value of the current element. On first call, the value of array[0] if an initialValue\r\n * was specified, otherwise the value of array[1].\r\n * @param currentIndex - The index position of currentValue in the array. On first call, 0 if initialValue was\r\n * specified, otherwise 1.\r\n * @param array -The array being traversed.\r\n */\r\nexport type ArrReduceCallbackFn = (previousValue: T | R, currentValue: T, currentIndex: number, array: T[]) => R;\r\n\r\n/**\r\n * The arrReduce() method executes a user-supplied \"reducer\" callback function on each element of the array,\r\n * in order, passing in the return value from the calculation on the preceding element. The final result of\r\n * running the reducer across all elements of the array is a single value.\r\n *\r\n * The first time that the callback is run there is no \"return value of the previous calculation\". If supplied,\r\n * an initial value may be used in its place. Otherwise the array element at index 0 is used as the initial\r\n * value and iteration starts from the next element (index 1 instead of index 0).\r\n * @group Array\r\n * @group ArrayLike\r\n * @typeParam T - Identifies the type of array elements\r\n * @param theArray - The array or array like object of elements to be searched.\r\n * @param callbackfn A function that accepts up to four arguments. The reduce method calls the callbackfn function one time for each element in the array.\r\n * @param initialValue If initialValue is specified, it is used as the initial value to start the accumulation. The first call to the callbackfn function provides this value as an argument instead of an array value.\r\n * @returns The value that results from running the \"reducer\" callback function to completion over the entire array.\r\n * @example\r\n * ```ts\r\n * const getMax = (a: number, b: number) => Math.max(a, b);\r\n *\r\n * // callback is invoked for each element in the array starting at index 0\r\n * arrReduce([1, 100], getMax, 50); // 100\r\n * arrReduce([ 50], getMax, 10); // 50\r\n *\r\n * // callback is invoked once for element at index 1\r\n * arrReduce([1, 100], getMax); // 100\r\n *\r\n * // callback is not invoked\r\n * arrReduce([ 50], getMax); // 50\r\n * arrReduce([ ], getMax, 1); // 1\r\n *\r\n * arrReduce([ ], getMax); // throws TypeError\r\n *\r\n * // Also supports Array like objects\r\n * arrReduce({ length: 2, 0: 1, 1: 100 }, getMax, 50); // 100\r\n * arrReduce({ length: 1, 0: 50 }, getMax, 10); // 50\r\n *\r\n * // callback is invoked once for element at index 1\r\n * arrReduce({ length: 2, 0: 1, 1: 100 }, getMax); // 100\r\n *\r\n * // callback is not invoked\r\n * arrReduce({ length: 1, 0: 50 }, getMax); // 50\r\n * arrReduce({ length: 0 }, getMax, 1); // 1\r\n * ```\r\n */\r\nexport const arrReduce: (theArray: ArrayLike, callbackfn: ArrReduceCallbackFn, initialValue?: T | R) => R = (/*#__PURE__*/_unwrapFunction(\"reduce\", ArrProto));\r\n","/*\r\n * @nevware21/ts-utils\r\n * https://github.com/nevware21/ts-utils\r\n *\r\n * Copyright (c) 2022 NevWare21 Solutions LLC\r\n * Licensed under the MIT license.\r\n */\r\n\r\nimport { ICachedValue, createCachedValue } from \"../helpers/cache\";\r\nimport { ObjClass, __PROTO__ } from \"../internal/constants\";\r\nimport { objForEachKey } from \"./for_each_key\";\r\n\r\nlet _isProtoArray: ICachedValue;\r\n\r\n/**\r\n * The objSetPrototypeOf() method sets the prototype (i.e., the internal [Prototype] property) of a specified\r\n * object to another object or null.\r\n * @group Object\r\n * @param obj - The object which is to have it's prototype set.\r\n * @param proto - The object's new prototype (an object or null)\r\n * @returns The specified object.\r\n */\r\nexport function objSetPrototypeOf(obj: any, proto: object) {\r\n let fn = ObjClass[\"setPrototypeOf\"] ||\r\n // tslint:disable-next-line: only-arrow-functions\r\n function (d: any, b: any) {\r\n !_isProtoArray && (_isProtoArray = createCachedValue({ [__PROTO__]: [] } instanceof Array));\r\n _isProtoArray.v ? d[__PROTO__] = b : objForEachKey(b, (key: any, value: any) => d[key] = value );\r\n };\r\n\r\n return fn(obj, proto);\r\n}","/*\r\n * @nevware21/ts-utils\r\n * https://github.com/nevware21/ts-utils\r\n *\r\n * Copyright (c) 2022 NevWare21 Solutions LLC\r\n * Licensed under the MIT license.\r\n */\r\n\r\nimport { fnApply } from \"../funcs/funcs\";\r\nimport { ArrSlice, CALL, CONSTRUCTOR, NAME, NULL_VALUE, PROTOTYPE } from \"../internal/constants\";\r\nimport { objCreate } from \"../object/create\";\r\nimport { objDefine } from \"../object/define\";\r\nimport { objGetPrototypeOf } from \"../object/object\";\r\nimport { objSetPrototypeOf } from \"../object/set_proto\";\r\nimport { safe } from \"./safe\";\r\n\r\n/**\r\n * Defines the definition of the custom error constructor\r\n * Used by: {@link createCustomError}\r\n * @group Error\r\n */\r\nexport interface CustomErrorConstructor extends ErrorConstructor {\r\n new(message?: string): T;\r\n (message?: string): T;\r\n readonly prototype: T;\r\n}\r\n\r\n/**\r\n * @internal\r\n * @ignore\r\n */\r\n/*#__NO_SIDE_EFFECTS__*/\r\nfunction _createCustomError(name: string, d: any, b: any): T {\r\n safe(objDefine, [ d, NAME, { v: name, c: true, e: false }]);\r\n d = objSetPrototypeOf(d, b);\r\n function __() {\r\n this[CONSTRUCTOR] = d;\r\n safe(objDefine, [this, NAME, { v: name, c: true, e: false }]);\r\n }\r\n\r\n d[PROTOTYPE] = b === NULL_VALUE ? objCreate(b) : ((__ as any)[PROTOTYPE] = b[PROTOTYPE], new (__ as any)());\r\n\r\n return d;\r\n}\r\n\r\nfunction _setName(baseClass: any, name: string) {\r\n name && (baseClass[NAME] = name);\r\n //name && (baseClass[PROTOTYPE][NAME] = name);\r\n}\r\n\r\n/**\r\n * Create a Custom Error class which may be used to throw custom errors.\r\n * @group Error\r\n * @param name - The name of the Custom Error\r\n * @param constructCb - [Optional] An optional callback function to call when a\r\n * new Customer Error instance is being created.\r\n * @param errorBase - [Optional] (since v0.9.6) The error class to extend for this class, defaults to Error.\r\n * @returns A new Error `class`\r\n * @example\r\n * ```ts\r\n * import { createCustomError, isError } from \"@nevware21/ts-utils\";\r\n *\r\n * // For an error that just contains a message\r\n * let myCustomErrorError = createCustomError(\"MessageError\");\r\n *\r\n * try {\r\n * throw new myCustomErrorError(\"Error Message!\");\r\n * } catch(e) {\r\n * // e.name === MessageError\r\n * // isError(e) === true;\r\n * // Object.prototype.toString.call(e) === \"[object Error]\";\r\n * }\r\n *\r\n * // Or a more complex error object\r\n * interface MyCriticalErrorConstructor extends CustomErrorConstructor {\r\n * new(message: string, file: string, line: number, col: number): MyCriticalError;\r\n * (message: string, file: string, line: number, col: number): MyCriticalError;\r\n * }\r\n *\r\n * interface MyCriticalError extends Error {\r\n * readonly errorId: number;\r\n * readonly args: any[]; // Holds all of the arguments passed during construction\r\n * }\r\n *\r\n * let _totalErrors = 0;\r\n * let myCustomError = createCustomError(\"CriticalError\", (self, args) => {\r\n * _totalErrors++;\r\n * self.errorId = _totalErrors;\r\n * self.args = args;\r\n * });\r\n *\r\n * try {\r\n * throw new myCustomError(\"Not Again!\");\r\n * } catch(e) {\r\n * // e.name === CriticalError\r\n * // isError(e) === true;\r\n * // Object.prototype.toString.call(e) === \"[object Error]\";\r\n * }\r\n *\r\n * // ----------------------------------------------------------\r\n * // Extending another custom error class\r\n * // ----------------------------------------------------------\r\n *\r\n * let AppError = createCustomError(\"ApplicationError\");\r\n * let theAppError = new appError();\r\n *\r\n * isError(theAppError); // true\r\n * theAppError instanceof Error; // true\r\n * theAppError instanceof AppError; // true\r\n *\r\n * let StartupError = createCustomError(\"StartupError\", null, AppError);\r\n * let theStartupError = new StartupError();\r\n *\r\n * isError(theStartupError); // true\r\n * theStartupError instanceof Error; // true\r\n * theStartupError instanceof AppError; // true\r\n * theStartupError instanceof StartupError; // true\r\n * ```\r\n */\r\n/*#__NO_SIDE_EFFECTS__*/\r\nexport function createCustomError(\r\n name: string,\r\n constructCb?: ((self: any, args: IArguments) => void) | null,\r\n errorBase?: B): T {\r\n\r\n let theBaseClass = errorBase || Error;\r\n let orgName = theBaseClass[PROTOTYPE][NAME];\r\n let captureFn = Error.captureStackTrace;\r\n return _createCustomError(name, function (this: any) {\r\n let _this = this;\r\n let theArgs = arguments;\r\n try {\r\n safe(_setName, [theBaseClass, name]);\r\n let _self = fnApply(theBaseClass, _this, ArrSlice[CALL](theArgs)) || _this;\r\n if (_self !== _this) {\r\n // Looks like runtime error constructor reset the prototype chain, so restore it\r\n let orgProto = objGetPrototypeOf(_this);\r\n if (orgProto !== objGetPrototypeOf(_self)) {\r\n objSetPrototypeOf(_self, orgProto);\r\n }\r\n }\r\n\r\n // Make sure we only capture our stack details\r\n captureFn && captureFn(_self, _this[CONSTRUCTOR]);\r\n \r\n // Run the provided construction function\r\n constructCb && constructCb(_self, theArgs);\r\n \r\n return _self;\r\n } finally {\r\n safe(_setName, [theBaseClass, orgName]);\r\n }\r\n }, theBaseClass);\r\n}\r\n\r\n/**\r\n * @internal\r\n * @ignore\r\n */\r\nlet _unsupportedError: CustomErrorConstructor;\r\n\r\n/**\r\n * Throw a custom `UnsupportedError` Error instance with the given message.\r\n * @group Error\r\n * @param message - The message to include in the exception\r\n * @example\r\n * ```ts\r\n * import { throwUnsupported } from \"@nevware21/ts-utils\";\r\n *\r\n * if (!window) {\r\n * throwUnsupported(\"A window is needed for this operation\");\r\n * }\r\n * ```\r\n */\r\nexport function throwUnsupported(message?: string): never {\r\n if (!_unsupportedError) {\r\n // Lazily create the class\r\n _unsupportedError = createCustomError(\"UnsupportedError\");\r\n }\r\n\r\n throw new _unsupportedError(message);\r\n}\r\n","/*\r\n * @nevware21/ts-utils\r\n * https://github.com/nevware21/ts-utils\r\n *\r\n * Copyright (c) 2022 NevWare21 Solutions LLC\r\n * Licensed under the MIT license.\r\n */\r\n\r\nimport { FUNCTION, ObjClass, OBJECT, PROTOTYPE } from \"../internal/constants\";\r\nimport { dumpObj } from \"../helpers/diagnostics\";\r\nimport { throwTypeError } from \"../helpers/throw\";\r\nimport { _pureAssign, _pureRef } from \"../internal/treeshake_helpers\";\r\n\r\n/**\r\n * Creates an object that has the specified prototype, and that optionally contains specified properties. This helper exists to avoid adding a polyfil\r\n * for older browsers that do not define Object.create eg. ES3 only, IE8 just in case any page checks for presence/absence of the prototype implementation.\r\n * Note: For consistency this will not use the Object.create implementation if it exists as this would cause a testing requirement to test with and without the implementations\r\n * @group Object\r\n * @param obj Object to use as a prototype. May be null\r\n */\r\nexport const objCreate: (obj: any) => any = (/* #__PURE__*/_pureAssign((/* #__PURE__*/_pureRef(ObjClass as any, \"create\")), polyObjCreate));\r\n\r\n/**\r\n * Creates an object that has the specified prototype, and that optionally contains specified properties. This helper exists to avoid adding a polyfil\r\n * for older browsers that do not define Object.create eg. ES3 only, IE8 just in case any page checks for presence/absence of the prototype implementation.\r\n * Note: For consistency this will not use the Object.create implementation if it exists as this would cause a testing requirement to test with and without the implementations\r\n * @group Polyfill\r\n * @group Object\r\n * @param obj Object to use as a prototype. May be null\r\n */\r\n/*#__NO_SIDE_EFFECTS__*/\r\nexport function polyObjCreate(obj: any): any {\r\n if (!obj) {\r\n return {};\r\n }\r\n\r\n let type = typeof obj;\r\n if (type !== OBJECT && type !== FUNCTION) {\r\n throwTypeError(\"Prototype must be an Object or function: \" + dumpObj(obj));\r\n }\r\n\r\n function tempFunc() {}\r\n tempFunc[PROTOTYPE] = obj;\r\n\r\n return new (tempFunc as any)();\r\n}\r\n","/*\r\n * @nevware21/ts-utils\r\n * https://github.com/nevware21/ts-utils\r\n *\r\n * Copyright (c) 2022 NevWare21 Solutions LLC\r\n * Licensed under the MIT license.\r\n */\r\n\r\n/**\r\n * Return the number of milliseconds that have elapsed since January 1, 1970 00:00:00 UTC.\r\n *\r\n * To offer protection against timing attacks and fingerprinting, the precision of utcNow()\r\n * might get rounded depending on browser settings. In Firefox, the privacy.reduceTimerPrecision\r\n * preference is enabled by default and defaults to 20µs in Firefox 59; in 60 it will be 2ms.\r\n *\r\n * @since 0.4.4\r\n * @group Timer\r\n *\r\n * @returns A Number representing the milliseconds elapsed since the UNIX epoch.\r\n * @example\r\n * ```ts\r\n * let now = utcNow();\r\n * ```\r\n */\r\n/*#__NO_SIDE_EFFECTS__*/\r\nexport function utcNow() {\r\n return (Date.now || polyUtcNow)();\r\n}\r\n\r\n/**\r\n * Polyfill fallback to return the number of milliseconds that have elapsed since January 1, 1970 00:00:00 UTC.\r\n *\r\n * To offer protection against timing attacks and fingerprinting, the precision of utcNow()\r\n * might get rounded depending on browser settings. In Firefox, the privacy.reduceTimerPrecision\r\n * preference is enabled by default and defaults to 20µs in Firefox 59; in 60 it will be 2ms.\r\n *\r\n * @since 0.4.4\r\n * @group Timer\r\n * @group Polyfill\r\n *\r\n * @returns A Number representing the milliseconds elapsed since the UNIX epoch.\r\n * @example\r\n * ```ts\r\n * let now = polyUtcNow();\r\n * ```\r\n*/\r\n/*#__NO_SIDE_EFFECTS__*/\r\nexport function polyUtcNow() {\r\n return new Date().getTime();\r\n}\r\n","/*\r\n * @nevware21/ts-utils\r\n * https://github.com/nevware21/ts-utils\r\n *\r\n * Copyright (c) 2022 NevWare21 Solutions LLC\r\n * Licensed under the MIT license.\r\n */\r\n\r\nimport { isNullOrUndefined } from \"../helpers/base\";\r\nimport { dumpObj } from \"../helpers/diagnostics\";\r\nimport { throwTypeError } from \"../helpers/throw\";\r\nimport { EMPTY } from \"../internal/constants\";\r\n\r\n/*#__NO_SIDE_EFFECTS__*/\r\nfunction _createTrimFn(exp: RegExp): (value: string) => string {\r\n return function _doTrim(value: string): string {\r\n if (isNullOrUndefined(value)) {\r\n throwTypeError(\"strTrim called [\" + dumpObj(value) + \"]\")\r\n }\r\n \r\n if (value && value.replace) {\r\n value = value.replace(exp, EMPTY);\r\n }\r\n \r\n return value;\r\n }\r\n}\r\n\r\n/**\r\n * The trim() method removes whitespace from both ends of a string and returns a new string,\r\n * without modifying the original string. Whitespace in this context is all the whitespace\r\n * characters (space, tab, no-break space, etc.) and all the line terminator characters\r\n * (LF, CR, etc.).\r\n * @group Polyfill\r\n * @group String\r\n * @param value - The string value to be trimmed.\r\n * @returns A new string representing str stripped of whitespace from both its beginning and end.\r\n * If neither the beginning or end of str has any whitespace, a new string is still returned (essentially\r\n * a copy of str), with no exception being thrown.\r\n * To return a new string with whitespace trimmed from just one end, use `strTrimStart()` or `strTrimEnd()`.\r\n */\r\nexport const polyStrTrim = (/*#__PURE__*/_createTrimFn(/^\\s+|(?=\\s)\\s+$/g));\r\n\r\n/**\r\n * The `polyStrTrimStart()` method removes whitespace from the beginning of a string.\r\n * @group Polyfill\r\n * @group String\r\n * @param value - The value to be trimmed.\r\n * @returns A new string representing str stripped of whitespace from its beginning (left side).\r\n * If the beginning of str has no whitespace, a new string is still returned (essentially a copy of str),\r\n * with no exception being thrown.\r\n */\r\nexport const polyStrTrimStart = (/*#__PURE__*/_createTrimFn(/^\\s+/g));\r\n \r\n/**\r\n * The `polyStrTrimEnd()` method removes whitespace from the end of a string.\r\n * @group Polyfill\r\n * @group String\r\n * @param value - The value to be trimmed.\r\n * @returns A new string representing str stripped of whitespace from its end (right side).\r\n * If the end of str has no whitespace, a new string is still returned (essentially a copy of str),\r\n * with no exception being thrown.\r\n */\r\nexport const polyStrTrimEnd = (/*#__PURE__*/_createTrimFn(/(?=\\s)\\s+$/g));\r\n","/*\r\n * @nevware21/ts-utils\r\n * https://github.com/nevware21/ts-utils\r\n *\r\n * Copyright (c) 2022 NevWare21 Solutions LLC\r\n * Licensed under the MIT license.\r\n */\r\n\r\nimport { StrProto } from \"../internal/constants\";\r\nimport { _pureAssign } from \"../internal/treeshake_helpers\";\r\nimport { _unwrapFunctionWithPoly } from \"../internal/unwrapFunction\";\r\nimport { polyStrTrim, polyStrTrimEnd, polyStrTrimStart } from \"../polyfills/trim\";\r\n\r\n/**\r\n * The trim() method removes whitespace from both ends of a string and returns a new string,\r\n * without modifying the original string. Whitespace in this context is all the whitespace\r\n * characters (space, tab, no-break space, etc.) and all the line terminator characters\r\n * (LF, CR, etc.).\r\n * @group String\r\n * @param value - The string value to be trimmed.\r\n * @returns A new string representing str stripped of whitespace from both its beginning and end.\r\n * If neither the beginning or end of str has any whitespace, a new string is still returned (essentially\r\n * a copy of str), with no exception being thrown.\r\n * To return a new string with whitespace trimmed from just one end, use `strTrimStart()` or `strTrimEnd()`.\r\n */\r\nexport const strTrim: (value: string) => string = (/*#__PURE__*/_unwrapFunctionWithPoly(\"trim\", StrProto, polyStrTrim));\r\n\r\n/**\r\n * The `strTrimStart()` method removes whitespace from the beginning of a string.\r\n * @group String\r\n * @param value - The value to be trimmed.\r\n * @returns A new string representing str stripped of whitespace from its beginning (left side).\r\n * If the beginning of str has no whitespace, a new string is still returned (essentially a copy of str),\r\n * with no exception being thrown.\r\n */\r\nexport const strTrimStart: (value: string) => string = (/*#__PURE__*/_unwrapFunctionWithPoly(\"trimStart\", StrProto, polyStrTrimStart));\r\n\r\n/**\r\n * Alias for `strTrimStart()` method removes whitespace from the beginning of a string.\r\n * @group String\r\n * @param value - The value to be trimmed.\r\n * @returns A new string representing str stripped of whitespace from its beginning (left side).\r\n * If the beginning of str has no whitespace, a new string is still returned (essentially a copy of str),\r\n * with no exception being thrown.\r\n */\r\nexport const strTrimLeft = (/*#__PURE__*/_pureAssign(strTrimStart));\r\n\r\n/**\r\n * The `strTrimEnd()` method removes whitespace from the end of a string.\r\n * @group String\r\n * @param value - The value to be trimmed.\r\n * @returns A new string representing str stripped of whitespace from its end (right side).\r\n * If the end of str has no whitespace, a new string is still returned (essentially a copy of str),\r\n * with no exception being thrown.\r\n */\r\nexport const strTrimEnd: (value: string) => string = (/*#__PURE__*/_unwrapFunctionWithPoly(\"trimEnd\", StrProto, polyStrTrimEnd));\r\n\r\n/**\r\n * Alias for `strTrimEnd()` method removes whitespace from the end of a string.\r\n * @group String\r\n * @param value - The value to be trimmed.\r\n * @returns A new string representing str stripped of whitespace from its end (right side).\r\n * If the end of str has no whitespace, a new string is still returned (essentially a copy of str),\r\n * with no exception being thrown.\r\n */\r\nexport const strTrimRight = (/*#__PURE__*/_pureAssign(strTrimEnd));\r\n","/*\r\n * @nevware21/ts-utils\r\n * https://github.com/nevware21/ts-utils\r\n *\r\n * Copyright (c) 2022 NevWare21 Solutions LLC\r\n * Licensed under the MIT license.\r\n */\r\n\r\nimport { NULL_VALUE, TO_STRING, UNDEF_VALUE } from \"../internal/constants\";\r\nimport { asString } from \"../string/as_string\";\r\nimport { strCamelCase } from \"../string/conversion\";\r\nimport { strPadStart } from \"../string/pad\";\r\nimport { strUpper } from \"../string/upper_lower\";\r\nimport { isNumber, isString, isUndefined } from \"./base\";\r\nimport { dumpObj } from \"./diagnostics\";\r\n\r\nconst DBL_QUOTE = \"\\\"\";\r\nconst INVALID_JS_NAME = /([^\\w\\d_$])/g;\r\nlet _htmlEntityCache: { [key: string]: string};\r\n\r\n/**\r\n * Validates that the string name conforms to the JS IdentifierName specification and if not\r\n * normalizes the name so that it would. This method does not identify or change any keywords\r\n * meaning that if you pass in a known keyword the same value will be returned.\r\n * @since 0.9.0\r\n * @group Conversion\r\n * @group Value\r\n * @param jsName - The string value to validate\r\n * @param camelCase - Optionally (see [1]) convert into CamelCase with the leading character either\r\n * - `true` => lowercase\r\n * - 'false' => uppercase\r\n * - undefined => not converted\r\n * @return The original string name, if it conforms to the JS naming convention otherwise an encoded version.\r\n *\r\n * > **[1]**: Camel casing the name will remove all non-word characters from the result\r\n * so you will NOT end up with any leading, embedded or trailing `_` characters which may cause\r\n * duplicate results for different string values.\r\n * @example\r\n * ```ts\r\n * normalizeJsName(\"HelloDarkness\"); // \"HelloDarkness\"\r\n * normalizeJsName(\"Hello Darkness\"); // \"Hello_Darkness\"\r\n * normalizeJsName(\"hello Darkness\"); // \"hello_Darkness\"\r\n * normalizeJsName(\"hello Darkness\"); // \"hello_Darkness\"\r\n * normalizeJsName(\"hello.Darkness\"); // \"hello_Darkness\"\r\n * normalizeJsName(\"hello-Darkness\"); // \"hello_Darkness\"\r\n * normalizeJsName(\"hello_Darkness\"); // \"hello_Darkness\"\r\n * normalizeJsName(\"abc-123\"); // \"abc_123\"\r\n * normalizeJsName(\"0abc0\"); // \"0abc0\"\r\n * normalizeJsName(\"\\\"HelloDarkness\\\"\"); // \"_HelloDarkness_\"\r\n * normalizeJsName(\"\\\"Hello Darkness\\\"\"); // \"_Hello_Darkness_\"\r\n * normalizeJsName(\"\\\"hello Darkness\\\"\"); // \"_hello_Darkness_\"\r\n * normalizeJsName(\"\\\"hello Darkness\\\"\"); // \"_hello_Darkness_\"\r\n * normalizeJsName(\"\\\"hello .,#[]Darkness\\\"\"); // \"_hello______Darkness_\"\r\n *\r\n * normalizeJsName(\"HelloDarkness\", true); // \"helloDarkness\"\r\n * normalizeJsName(\"Hello Darkness\", true); // \"helloDarkness\"\r\n * normalizeJsName(\"hello Darkness\", true); // \"helloDarkness\"\r\n * normalizeJsName(\"hello Darkness\", true); // \"helloDarkness\"\r\n * normalizeJsName(\"hello.Darkness\", true); // \"helloDarkness\"\r\n * normalizeJsName(\"hello-Darkness\", true); // \"helloDarkness\"\r\n * normalizeJsName(\"hello_Darkness\", true); // \"helloDarkness\"\r\n * normalizeJsName(\"abc-123\", true); // \"abc123\"\r\n * normalizeJsName(\"0abc0\", true); // \"0abc0\"\r\n * normalizeJsName(\"\\\"HelloDarkness\\\"\", true); // \"helloDarkness\"\r\n * normalizeJsName(\"\\\"Hello Darkness\\\"\", true); // \"helloDarkness\"\r\n * normalizeJsName(\"hello \\\"Darkness\\\"\", true); // \"helloDarkness\"\r\n * normalizeJsName(\"hello \\\"Darkness\\\"\", true); // \"helloDarkness\"\r\n * normalizeJsName(\"\\\"hello .,#[]Darkness\\\"\", true); // \"helloDarkness\"\r\n * ```\r\n */\r\n/*#__NO_SIDE_EFFECTS__*/\r\nexport function normalizeJsName(jsName: string, camelCase?: boolean): string {\r\n let result = asString(jsName).replace(INVALID_JS_NAME, \"_\");\r\n\r\n return !isUndefined(camelCase) ? strCamelCase(result, !camelCase) : result;\r\n}\r\n\r\n/**\r\n * Encode the value into a JSON string, if the provided value is a string this will encode\r\n * any character that is not an alpha, numeric, space or some special characters as `\\uXXXX`\r\n * and will always be returned wrapped in double quotes `\"xxx\"`, if the value is any other\r\n * object it will be encoded using JSON.stringify() and if there is an exception encoding\r\n * with JSON.stringify() it will return the exception as a string using {@link dumpObj}().\r\n * @since 0.9.0\r\n * @group Conversion\r\n * @group Value\r\n * @param value - The value to be encoded as JSON\r\n * @param format - Identifies whether the JSON value should be formatted when an object\r\n * - `true` - Format with 4 spaces\r\n * - 'number' - The number of spaces to format with\r\n * - `false` (or not Truthy) - Do not format*\r\n * @returns A JSON encoded string representation of the value.\r\n * @example\r\n * ```ts\r\n * // String values\r\n * encodeAsJson(\"abc.123\"); // \"\\\"abc.123\\\"\"\r\n * encodeAsJson(\"321-abc\"); // \"\\\"321-abc\\\"\"\r\n * encodeAsJson(\"Hello darkness, my \\\"old\\\" friend...\"); // \"\\\"Hello darkness, my \\\\\\\"old\\\\\\\" friend...\\\"\"\r\n * encodeAsJson(\"Hello: Darkness\"); // \"\\\"Hello: Darkness\\\"\"\r\n * encodeAsJson(\"Hello\\\\u003A Darkness\"); // \"\\\"Hello\\\\\\\\u003A Darkness\\\"\"\r\n * encodeAsJson(\"`!@#$%^&*()_-+=[]{}:;'<>?\"); // \"\\\"\\\\u0060!@#$%^&*()_-+=[]{}:;\\\\u0027<>?\\\"\"\r\n * encodeAsJson(\"0\"); // \"\\\"0\\\"\"\r\n * encodeAsJson(\"1\"); // \"\\\"1\\\"\"\r\n *\r\n * encodeAsJson([]); // \"[]\"\r\n * encodeAsJson([\"A\"]); // \"[\\\"A\\\"]\"\r\n * encodeAsJson([0]); // \"[0]\"\r\n * encodeAsJson([false]); // \"[false]\"\r\n * encodeAsJson(new Array(1)); // \"[null]\"\r\n * encodeAsJson(true); // \"true\",\r\n * encodeAsJson(false); // \"false\"\r\n *\r\n * encodeAsJson({}); // \"{}\"\r\n * encodeAsJson({ Hello: \"Darkness\" }); // \"{\\\"Hello\\\":\\\"Darkness\\\"}\");\r\n * ```\r\n */\r\n/*#__NO_SIDE_EFFECTS__*/\r\nexport function encodeAsJson(value: T, format?: boolean | number): string {\r\n let result: string;\r\n\r\n if (isString(value)) {\r\n // encode if a character is not an alpha, numeric, space or some special characters\r\n result = DBL_QUOTE + value.replace(/[^\\w .,\\-!@#$%\\^&*\\(\\)_+={}\\[\\]:;|<>?]/g, (match) => {\r\n if(match === DBL_QUOTE || match === \"\\\\\") {\r\n return \"\\\\\" + match;\r\n }\r\n\r\n var hex = match.charCodeAt(0)[TO_STRING](16);\r\n return \"\\\\u\" + strPadStart(strUpper(hex), 4, \"0\");\r\n }) + DBL_QUOTE;\r\n } else {\r\n try {\r\n result = JSON.stringify(value, NULL_VALUE, format ? (isNumber(format) ? format : 4) : UNDEF_VALUE);\r\n } catch (e) {\r\n // Unable to convert to JSON\r\n result = DBL_QUOTE + dumpObj(e) + DBL_QUOTE;\r\n }\r\n }\r\n\r\n return result;\r\n}\r\n\r\n/**\r\n * Encode the provided string to a safe HTML form, converting the base `&`, `<`, `>`, `\\\"` and `'`\r\n * characters into their HTML encoded representations\r\n * @since 0.9.0\r\n * @group Conversion\r\n * @group Value\r\n * @param value - The string value to be converted into a HTML safe form\r\n * @returns The converted string as HTML\r\n * @example\r\n * ```ts\r\n * encodeAsHtml(\"HelloDarkness\"); // \"HelloDarkness\"\r\n * encodeAsHtml(\"Hello Darkness\"); // \"Hello Darkness\"\r\n * encodeAsHtml(\"hello.Darkness\"); // \"hello.Darkness\"\r\n * encodeAsHtml(\"hello-Darkness\"); // \"hello-Darkness\"\r\n * encodeAsHtml(\"hello_Darkness\"); // \"hello_Darkness\"\r\n * encodeAsHtml(\"abc-123\"); // \"abc-123\"\r\n * encodeAsHtml(\"0abc0\"); // \"0abc0\"\r\n * encodeAsHtml(\"\\\"HelloDarkness\\\"\"); // \""HelloDarkness"\"\r\n * encodeAsHtml(\"\\\"Hello Darkness\\\"\"); // \""Hello Darkness"\"\r\n * encodeAsHtml(\"\\\"hello Darkness\\\"\"); // \""hello Darkness"\"\r\n * encodeAsHtml(\"\\\"hello Darkness\\\"\"); // \""hello Darkness"\"\r\n * encodeAsHtml(\"\\\"hello .,#<[]>Darkness\\\"\"); // \""hello .,#<[]>Darkness"\"\r\n * encodeAsHtml(\"\"); // \"<script src="javascript:alert('Hello');"></script>\"\r\n * ```\r\n */\r\n/*#__NO_SIDE_EFFECTS__*/\r\nexport function encodeAsHtml(value: string) {\r\n !_htmlEntityCache && (_htmlEntityCache = {\r\n \"&\": \"amp\",\r\n \"<\": \"lt\",\r\n \">\": \"gt\",\r\n \"\\\"\": \"quot\",\r\n \"'\": \"#39\"\r\n });\r\n \r\n return asString(value).replace(/[&<>\"']/g, match => \"&\" + _htmlEntityCache[match] + \";\");\r\n}\r\n","/*\r\n * @nevware21/ts-utils\r\n * https://github.com/nevware21/ts-utils\r\n *\r\n * Copyright (c) 2022 NevWare21 Solutions LLC\r\n * Licensed under the MIT license.\r\n */\r\n\r\nimport { getWindow, hasWindow } from \"../helpers/environment\";\r\nimport { CALL, CONSTRUCTOR, FUNCTION, ObjClass, OBJECT, PROTOTYPE, TO_STRING } from \"../internal/constants\";\r\nimport { objHasOwnProperty } from \"./has_own_prop\";\r\nimport { objGetPrototypeOf } from \"./object\";\r\n\r\n// Use to cache the result of Object.cont\r\nlet _fnToString: () => string;\r\nlet _objCtrFnString: string;\r\nlet _gblWindow: Window;\r\n\r\n/**\r\n * Checks to see if the past value is a plain object (not a class/array) value.\r\n * Object are considered to be \"plain\" if they are created with no prototype `Object.create(null)`\r\n * or by using the Object global (native) function, all other \"objects\" ar\r\n * @since 0.4.4\r\n * @group Type Identity\r\n * @group Object\r\n * @param value - The value to check\r\n * @returns true if `value` is a normal plain object\r\n * @example\r\n * ```ts\r\n * console.log(isPlainObject({ 0: 'a', 1: 'b', 2: 'c' })); // true\r\n * console.log(isPlainObject({ 100: 'a', 2: 'b', 7: 'c' })); // true\r\n * console.log(isPlainObject(objCreate(null))); // true\r\n *\r\n * const myObj = objCreate({}, {\r\n * getFoo: {\r\n * value() { return this.foo; }\r\n * }\r\n * });\r\n * myObj.foo = 1;\r\n * console.log(isPlainObject(myObj)); // true\r\n *\r\n * console.log(isPlainObject(['a', 'b', 'c'])); // false\r\n * console.log(isPlainObject(new Date())); // false\r\n * console.log(isPlainObject(new Error(\"An Error\"))); // false\r\n * console.log(isPlainObject(null)); // false\r\n * console.log(isPlainObject(undefined)); // false\r\n * console.log(isPlainObject(\"null\")); // false\r\n * console.log(isPlainObject(\"undefined\")); // false\r\n * console.log(isPlainObject(\"1\")); // false\r\n * console.log(isPlainObject(\"aa\")); // false\r\n * ```\r\n */\r\n/*#__NO_SIDE_EFFECTS__*/\r\nexport function isPlainObject(value: any): value is object {\r\n if (!value || typeof value !== OBJECT) {\r\n return false;\r\n }\r\n\r\n if (!_gblWindow) {\r\n // Lazily cache the current global window value and default it to \"true\" (so we bypass this check in the future)\r\n _gblWindow = hasWindow() ? getWindow() : (true as any);\r\n }\r\n\r\n let result = false;\r\n if (value !== _gblWindow) {\r\n\r\n if (!_objCtrFnString) {\r\n // Lazily caching what the runtime reports as the object function constructor (as a string)\r\n // Using an current function lookup to find what this runtime calls a \"native\" function\r\n _fnToString = Function[PROTOTYPE][TO_STRING];\r\n _objCtrFnString = _fnToString[CALL](ObjClass);\r\n }\r\n\r\n try {\r\n let proto = objGetPrototypeOf(value);\r\n\r\n // No prototype so looks like an object created with Object.create(null)\r\n result = !proto;\r\n if (!result) {\r\n if (objHasOwnProperty(proto, CONSTRUCTOR)) {\r\n proto = proto[CONSTRUCTOR]\r\n }\r\n \r\n result = !!(proto && typeof proto === FUNCTION && _fnToString[CALL](proto) === _objCtrFnString);\r\n }\r\n } catch (ex) {\r\n // Something went wrong, so it's not an object we are playing with\r\n }\r\n }\r\n\r\n return result;\r\n}\r\n","/*\r\n * @nevware21/ts-utils\r\n * https://github.com/nevware21/ts-utils\r\n *\r\n * Copyright (c) 2022 NevWare21 Solutions LLC\r\n * Licensed under the MIT license.\r\n */\r\n\r\nimport { arrForEach } from \"../array/forEach\";\r\nimport { isArray, isDate, isNullOrUndefined, isPrimitiveType } from \"../helpers/base\";\r\nimport { CALL, FUNCTION, NULL_VALUE, OBJECT } from \"../internal/constants\";\r\nimport { objDefine } from \"./define\";\r\nimport { isPlainObject } from \"./is_plain_object\";\r\n\r\n/**\r\n * @internal\r\n * @ignore\r\n * Provides the current context while performing a deep copy\r\n */\r\ninterface _DeepCopyContext {\r\n handler: ObjDeepCopyHandler;\r\n src: any;\r\n path?: Array;\r\n}\r\n\r\n/**\r\n * @internal\r\n * @ignore\r\n * Defines the type used for tracking visited objects during deep copy to identify recursive\r\n * objects.\r\n */\r\ninterface _RecursiveVisitMap {\r\n k: any;\r\n v: any;\r\n}\r\n\r\n/**\r\n * @internal\r\n * @ignore\r\n * Generic Object deep copy handler which creates a new plain object and copies enumerable properties from\r\n * the source to the new target plain object. The source object does not have to be a plain object.\r\n * @param details - The details object for the current property being copied\r\n * @returns true if the handler processed the field.\r\n */\r\n/*#__NO_SIDE_EFFECTS__*/\r\nfunction _defaultDeepCopyHandler(details: IObjDeepCopyHandlerDetails): boolean {\r\n // Make sure we at least copy plain objects\r\n details.value && plainObjDeepCopyHandler(details);\r\n\r\n // Always return true so that the iteration completes\r\n return true;\r\n}\r\n\r\n/**\r\n * @internal\r\n * @ignore\r\n * The ordered default deep copy handlers\r\n */\r\nconst defaultDeepCopyHandlers: ObjDeepCopyHandler[] = [\r\n arrayDeepCopyHandler,\r\n plainObjDeepCopyHandler,\r\n functionDeepCopyHandler,\r\n dateDeepCopyHandler\r\n];\r\n\r\n/**\r\n * @internal\r\n * @ignore\r\n * Helper function used for detecting and handling recursive properties\r\n * @param visitMap - The current map of objects that have been visited\r\n * @param source - The value (object) to be copied\r\n * @param newPath - The new access path from the origin to the current property\r\n * @param cb - The callback function to call if the current object has not already been processed.\r\n * @returns The new deep copied property, may be incomplete as the object is recursive and is still in the process of being copied\r\n */\r\n/*#__NO_SIDE_EFFECTS__*/\r\nfunction _getSetVisited(visitMap: _RecursiveVisitMap[], source: any, newPath: Array, cb: (newEntry: _RecursiveVisitMap) => void) {\r\n let theEntry: _RecursiveVisitMap;\r\n arrForEach(visitMap, (entry) => {\r\n if (entry.k === source) {\r\n theEntry = entry;\r\n return -1;\r\n }\r\n });\r\n\r\n if (!theEntry) {\r\n // Add the target to the visit map so that deep nested objects refer to the single instance\r\n // Even if we have not finished processing it yet.\r\n theEntry = { k: source, v: source };\r\n visitMap.push(theEntry);\r\n\r\n // Now call the copy callback so that it populates the target\r\n cb(theEntry);\r\n }\r\n\r\n return theEntry.v;\r\n}\r\n\r\n/**\r\n * @internal\r\n * @ignore\r\n * Internal helper which performs the recursive deep copy\r\n * @param visitMap - The current map of objects that have been visited\r\n * @param value - The value being copied\r\n * @param ctx - The current copy context\r\n * @param key - [Optional] the current `key` for the value from the source object\r\n * @returns The new deep copied instance of the value.\r\n */\r\nfunction _deepCopy(visitMap: _RecursiveVisitMap[], value: T, ctx: _DeepCopyContext, key?: string | number | symbol): T {\r\n let userHandler = ctx.handler;\r\n let newPath = ctx.path ? (key ? ctx.path.concat(key) : ctx.path) : [];\r\n\r\n let newCtx: _DeepCopyContext = {\r\n handler: ctx.handler,\r\n src: ctx.src,\r\n path: newPath\r\n };\r\n\r\n const theType = typeof value;\r\n let isPlain = false;\r\n let isPrim = value === NULL_VALUE;\r\n if (!isPrim) {\r\n if (value && theType === OBJECT) {\r\n isPlain = isPlainObject(value);\r\n } else {\r\n isPrim = isPrimitiveType(theType);\r\n }\r\n }\r\n\r\n let details: IObjDeepCopyHandlerDetails = {\r\n type: theType,\r\n isPrim: isPrim,\r\n isPlain: isPlain,\r\n value: value,\r\n result: value,\r\n path: newPath,\r\n origin: ctx.src,\r\n copy: (source: T, newKey?: string | number | symbol): T => {\r\n return _deepCopy(visitMap, source, newKey ? newCtx : ctx, newKey);\r\n },\r\n copyTo: (target: T, source: T): T => {\r\n return _copyProps(visitMap, target, source, newCtx);\r\n }\r\n };\r\n\r\n if (!details.isPrim) {\r\n return _getSetVisited(visitMap, value, newPath, (newEntry) => {\r\n\r\n // Use an accessor to set the new value onto the new entry\r\n objDefine(details, \"result\", {\r\n g: function () {\r\n return newEntry.v;\r\n },\r\n s: function (newValue: any) {\r\n newEntry.v = newValue;\r\n }\r\n });\r\n\r\n let idx = 0;\r\n let handler = userHandler;\r\n while (!(handler || (idx < defaultDeepCopyHandlers.length ? defaultDeepCopyHandlers[idx++] : _defaultDeepCopyHandler))[CALL](ctx, details)) {\r\n handler = NULL_VALUE;\r\n }\r\n });\r\n }\r\n\r\n // Allow the user handler to override the provided value\r\n if (userHandler && userHandler[CALL](ctx, details)) {\r\n return details.result;\r\n }\r\n\r\n return value;\r\n}\r\n\r\n/**\r\n * @internal\r\n * @ignore\r\n * Internal helper to copy all of the enumerable properties from the source object to the new target object\r\n * @param visitMap - The current map of objects that have been visited\r\n * @param target - The target object to copy the properties to.\r\n * @param source - The source object to copy the properties from.\r\n * @param ctx - The current deep copy context\r\n * @returns The populated target object\r\n */\r\nfunction _copyProps(visitMap: _RecursiveVisitMap[], target: T, source: T, ctx: _DeepCopyContext) {\r\n if (!isNullOrUndefined(source)) {\r\n // Copy all properties (not just own properties)\r\n for (const key in source) {\r\n // Perform a deep copy of the object\r\n target[key] = _deepCopy(visitMap, source[key], ctx, key);\r\n }\r\n }\r\n\r\n return target;\r\n}\r\n\r\n/**\r\n * Object helper to copy all of the enumerable properties from the source object to the target, the\r\n * properties are copied via {@link objDeepCopy}. Automatic handling of recursive properties was added in v0.4.4\r\n * @group Object\r\n * @param target - The target object to populated\r\n * @param source - The source object to copy the properties from\r\n * @param handler - An optional callback that lets you provide / overide the deep cloning (Since 0.4.4)\r\n * @returns The target object\r\n * @example\r\n * ```ts\r\n * let a: any = { a: 1 };\r\n * let b: any = { b: 2, d: new Date(), e: new TestClass(\"Hello Darkness\") };\r\n * a.b = b; // { a: 1, b: { b: 2} }\r\n * b.a = a; // { a: 1, b: { b: 2, a: { a: 1, { b: 2, a: ... }}}}\r\n *\r\n * function copyHandler(details: IObjDeepCopyHandlerDetails) {\r\n * // details.origin === a\r\n * // details.path[] is the path to the current value\r\n * if (details.value && isDate(details.value)) {\r\n * // So for the date path === [ \"b\", \"d\" ] which represents\r\n * // details.origin[\"b\"][\"d\"] === The Date\r\n *\r\n * // Create a clone the Date object and set as the \"newValue\"\r\n * details.value = new Date(details.value.getTime());\r\n *\r\n * // Return true to indicate that we have \"handled\" the conversion\r\n * // See objDeepCopy example for just reusing the original value (just don't replace details.value)\r\n * return true;\r\n * }\r\n *\r\n * return false;\r\n * }\r\n *\r\n * let c: any = objCopyProps({}, a, copyHandler);\r\n *\r\n * assert.notEqual(a, c, \"check a and c are not the same\");\r\n * assert.ok(c !== c.b.a, \"The root object won't be the same for the target reference as are are copying properties to our target\");\r\n * assert.ok(c.b === c.b.a.b, \"Check that the 2 'b' references are the same object\");\r\n * assert.ok(c.b.a === c.b.a.b.a, \"Check that the 2 'a' references are the same object\");\r\n * assert.ok(c.b.d === c.b.a.b.d, \"Check that the 2 'd' references are the same object\");\r\n * assert.ok(isDate(c.b.d), \"The copied date is still real 'Date' instance\");\r\n * assert.notEqual(c.b.d, a.b.d, \"And the copied date is not the same as the original\");\r\n * assert.equal(c.b.d.getTime(), a.b.d.getTime(), \"But the dates are the same\");\r\n *\r\n * assert.ok(isObject(c.b.d), \"The copied date is now an object\");\r\n * ```\r\n */\r\nexport function objCopyProps(target: T, source: any, handler?: ObjDeepCopyHandler) {\r\n let ctx: _DeepCopyContext = {\r\n handler: handler,\r\n src: source,\r\n path: []\r\n };\r\n\r\n return _copyProps([], target, source, ctx);\r\n}\r\n\r\n/**\r\n * Context details passed to the deep copy handler to allow it parse the current value based on the original source\r\n * and path to reach the current value. The provided value should be updated with the value to by copied into the\r\n * new deep copy and will be used when the handler returns true.\r\n * @since 0.4.4\r\n * @group Object - Deep Copy\r\n */\r\nexport interface IObjDeepCopyHandlerDetails {\r\n /**\r\n * Identifies the type of the value as per `typeof value`, saves each check having to process this value.\r\n */\r\n type: string;\r\n\r\n /**\r\n * Identifies whether the type of the value is considered to be a primitive value\r\n */\r\n isPrim: boolean;\r\n\r\n /**\r\n * Identifies whether the type is a plain object or not, this also saves each handler from checking\r\n * the `type`, currently the type will also be \"object\" if this is `true`.\r\n * @since 0.9.6\r\n */\r\n isPlain: boolean;\r\n\r\n /**\r\n * The current value to be processed, replace this value with the new deep copied value to use when returning\r\n * true from the handler. Ignored when the handler returns false.\r\n */\r\n readonly value: any;\r\n\r\n /**\r\n * Replace this value with the new deep copied value (defaults to the same as the value property) this value will be\r\n * used when returning true from the handler. Ignored when the handler returns false.\r\n */\r\n result: any;\r\n\r\n /**\r\n * A array of keys from the orginal source (origin) object which lead to the current value\r\n */\r\n path: Array;\r\n\r\n /**\r\n * The original source object passed into the `objDeepCopy()` or `objCopyProps()` functions.\r\n */\r\n origin?: any;\r\n\r\n /**\r\n * Continue the deep copy with the current context and recursive checks, effectively calls {@link objDeepCopy}\r\n * but keeps the current context and recursive references.\r\n * @param source - The source object to be copied\r\n */\r\n copy(source: T, key?: string | number | symbol): T;\r\n\r\n /**\r\n * Continue the deep copy with the current context and recursive checks by copying all of the properties\r\n * from the source to the target instance, effectively calls {@link objCopyProps} but keeps the current context\r\n * and recursive references.\r\n * @param target - The target object to populated\r\n * @param source - The source object to copy the properties from\r\n */\r\n copyTo(target: T, source: T): T;\r\n}\r\n\r\n/**\r\n * An optional deep copy handler that lets you provide your own logic for deep copying objects, will\r\n * only be called once per object/property combination, so if an object is recursively included it\r\n * will only get called for the first instance.\r\n * Handlers SHOULD assign the \"result\" value with the new target instance BEFORE performing any additional deep copying,\r\n * so any recursive objects will get a reference to the new instance and not keep attempting to create new copies.\r\n * @since 0.4.4\r\n * @group Object - Deep Copy\r\n * @return true if handled and the value in details should be used otherwise false to continue with the default handling\r\n * The library includes several helpers which can be reused by any user provided handler\r\n * - {@link functionDeepCopyHandler} - Used to copy functions\r\n * - {@link arrayDeepCopyHandler} - Used to copy arrays\r\n * - {@link plainObjDeepCopyHandler} - Used to copy plain objects\r\n * - {@link dateDeepCopyHandler} - Used to copy date instances\r\n */\r\nexport type ObjDeepCopyHandler = (details: IObjDeepCopyHandlerDetails) => boolean;\r\n\r\n/**\r\n * Performs a deep copy of the source object, this is designed to work with base (plain) objects, arrays and primitives\r\n * if the source object contains class objects they will either be not cloned or may be considered non-operational after\r\n * performing a deep copy. ie. This is performing a deep copy of the objects properties so that altering the copy will\r\n * not mutate the source object hierarchy.\r\n * Automatic handling of recursive properties was added in v0.4.4.\r\n * @group Object\r\n * @group Object - Deep Copy\r\n * @param source - The source object to be copied\r\n * @param handler - An optional callback that lets you provide / overide the deep cloning (Since 0.4.4)\r\n * @return A new object which contains a deep copy of the source properties\r\n * @example\r\n * ```ts\r\n * let a: any = { a: 1 };\r\n * let b: any = { b: 2, d: new Date(), e: new TestClass(\"Hello Darkness\") };\r\n * a.b = b; // { a: 1, b: { b: 2} }\r\n * b.a = a; // { a: 1, b: { b: 2, a: { a: 1, { b: 2, a: ... }}}}\r\n *\r\n * function copyHandler(details: IObjDeepCopyHandlerDetails) {\r\n * // details.origin === a\r\n * // details.path[] is the path to the current value\r\n * if (details.value && isDate(details.value)) {\r\n * // So for the date path === [ \"b\", \"d\" ] which represents\r\n * // details.origin[\"b\"][\"d\"] === The Date\r\n *\r\n * // Return true to indicate that we have \"handled\" the conversion\r\n * // Which in this case will reuse the existing instance (as we didn't replace details.value)\r\n * // See objCopyProps example for replacing the Date instance\r\n * return true;\r\n * }\r\n *\r\n * return false;\r\n * }\r\n *\r\n * let c: any = objDeepCopy(a, copyHandler);\r\n *\r\n * assert.notEqual(a, c, \"check a and c are not the same\");\r\n * assert.ok(c === c.b.a, \"The root object won't be the same for the target reference\");\r\n * assert.ok(c.b === c.b.a.b, \"Check that the 2 'b' references are the same object\");\r\n * assert.ok(c.b.a === c.b.a.b.a, \"Check that the 2 'a' references are the same object\");\r\n * assert.ok(c.b.d === c.b.a.b.d, \"Check that the 2 'd' references are the same object\");\r\n * assert.ok(isDate(c.b.d), \"The copied date is still real 'Date' instance\");\r\n * assert.equal(c.b.d, a.b.d, \"And the copied date is the original date\");\r\n * assert.equal(c.b.d.getTime(), a.b.d.getTime(), \"But the dates are the same\");\r\n * assert.ok(isObject(c.b.d), \"The copied date is now an object\");\r\n * assert.ok(!isError(c.b.e), \"The copied error is no longer a real 'Error' instance\");\r\n * assert.ok(isObject(c.b.e), \"The copied error is now an object\");\r\n * assert.equal(42, c.b.e.value, \"Expect that the local property was copied\");\r\n * ```\r\n */\r\n/*#__NO_SIDE_EFFECTS__*/\r\nexport function objDeepCopy(source: T, handler?: ObjDeepCopyHandler): T {\r\n let ctx: _DeepCopyContext = {\r\n handler: handler,\r\n src: source\r\n };\r\n\r\n return _deepCopy([], source, ctx);\r\n}\r\n\r\n/**\r\n * Deep copy handler to identify and copy arrays.\r\n * @since 0.4.4\r\n * @group Object - Deep Copy\r\n * @param details - The details object for the current property being copied\r\n * @returns `true` if the current value is a function otherwise `false`\r\n */\r\nexport function arrayDeepCopyHandler(details: IObjDeepCopyHandlerDetails): boolean {\r\n let value = details.value;\r\n if (isArray(value)) {\r\n // Assign the \"result\" value before performing any additional deep Copying, so any recursive object get a reference to this instance\r\n let target: any[] = details.result = [];\r\n target.length = value.length;\r\n\r\n // Copying all properties as arrays can contain non-indexed based properties\r\n details.copyTo(target, value);\r\n return true;\r\n }\r\n\r\n return false;\r\n}\r\n\r\n/**\r\n * Deep copy handler to identify and copy Date instances.\r\n * @since 0.4.4\r\n * @group Object - Deep Copy\r\n * @param details - The details object for the current property being copied\r\n * @returns `true` if the current value is a function otherwise `false`\r\n */\r\nexport function dateDeepCopyHandler(details: IObjDeepCopyHandlerDetails) {\r\n let value = details.value;\r\n if (isDate(value)) {\r\n details.result = new Date(value.getTime());\r\n return true;\r\n }\r\n\r\n return false;\r\n}\r\n\r\n/**\r\n * Deep copy handler to identify and copy functions. This handler just returns the original\r\n * function so the original function will be assigned to any new deep copied instance.\r\n * @since 0.4.4\r\n * @group Object - Deep Copy\r\n * @param details - The details object for the current property being copied\r\n * @returns `true` if the current value is a function otherwise `false`\r\n */\r\nexport function functionDeepCopyHandler(details: IObjDeepCopyHandlerDetails): boolean {\r\n if (details.type === FUNCTION) {\r\n return true;\r\n }\r\n\r\n return false;\r\n}\r\n\r\n/**\r\n * Deep copy handler to identify and copy plain objects.\r\n * @since 0.4.4\r\n * @group Object - Deep Copy\r\n * @param details - The details object for the current property being copied\r\n * @returns `true` if the current value is a function otherwise `false`\r\n */\r\nexport function plainObjDeepCopyHandler(details: IObjDeepCopyHandlerDetails): boolean {\r\n let value = details.value;\r\n if (value && details.isPlain) {\r\n // Assign the \"result\" value before performing any additional deep Copying, so any recursive object get a reference to this instance\r\n let target = details.result = {};\r\n details.copyTo(target, value);\r\n return true;\r\n }\r\n\r\n return false;\r\n}\r\n","/*\r\n * @nevware21/ts-utils\r\n * https://github.com/nevware21/ts-utils\r\n *\r\n * Copyright (c) 2022 NevWare21 Solutions LLC\r\n * Licensed under the MIT license.\r\n */\r\n\r\nimport { arrForEach } from \"../array/forEach\";\r\nimport { ArrSlice, CALL } from \"../internal/constants\";\r\nimport { objCopyProps, objDeepCopy } from \"../object/copy\";\r\n\r\n/**\r\n * @internal\r\n * @ignore\r\n */\r\nfunction _doExtend(target: T, theArgs: any[]): any {\r\n arrForEach(theArgs, (theArg) => {\r\n objCopyProps(target, theArg);\r\n });\r\n\r\n return target;\r\n}\r\n\r\n/**\r\n * Create a new object by merging the passed arguments, this is effectively the same as calling `objExtend({}, ...theArgs)` where\r\n * all of the arguments are added to a new object that is returned.\r\n * @group Object\r\n * @param target - The original object to be extended.\r\n * @param theArgs - The optional number of arguments to be copied\r\n * @returns - A new object or the original\r\n */\r\nexport function deepExtend(target: T, ...theArgs: any): T & any;\r\n\r\n/**\r\n * Create a new object by merging the passed arguments, this is effectively the same as calling `objExtend({}, ...theArgs)` where\r\n * all of the arguments are added to a new object that is returned.\r\n * @group Object\r\n * @param target - The original object to be extended.\r\n * @param objN - The optional number of arguments to be copied\r\n * @returns - A new object or the original\r\n */\r\nexport function deepExtend(target: T, obj1?: T1, obj2?: T2, obj3?: T3, obj4?: T4, obj5?: T5, obj6?: T6): T & T1 & T2 & T3 & T4 & T5 & T6 {\r\n return _doExtend(objDeepCopy(target) || {}, ArrSlice[CALL](arguments));\r\n}\r\n \r\n/**\r\n * Extend the target object by merging the passed arguments into it\r\n * @group Object\r\n * @param target - The object to be extended or overwritten\r\n * @param theArgs - The optional number of arguments to be copied\r\n * @returns - A new object or the original\r\n */\r\nexport function objExtend(target: T, ...theArgs: any): T & any;\r\n\r\n/**\r\n * Extend the target object by merging the passed arguments into it\r\n * @group Object\r\n * @param target - The object to be extended or overwritten\r\n * @param objN - The optional number of arguments to be copied\r\n * @returns - A new object or the original\r\n */\r\nexport function objExtend(target: T, obj1?: T1, obj2?: T2, obj3?: T3, obj4?: T4, obj5?: T5, obj6?: T6): T & T1 & T2 & T3 & T4 & T5 & T6 {\r\n return _doExtend(target || {}, ArrSlice[CALL](arguments));\r\n}\r\n\r\n ","/*\r\n * @nevware21/ts-utils\r\n * https://github.com/nevware21/ts-utils\r\n *\r\n * Copyright (c) 2022 NevWare21 Solutions LLC\r\n * Licensed under the MIT license.\r\n */\r\n\r\nimport { LENGTH } from \"../internal/constants\";\r\nimport { _unwrapProp } from \"../internal/unwrapFunction\";\r\n\r\n/**\r\n * Interface to identify that an object contains the length property used as a type\r\n * constraint for {@link getLength}\r\n *\r\n * @since 0.4.2\r\n * @group String\r\n * @group Array\r\n * @group Object\r\n */\r\nexport interface IGetLength {\r\n\r\n /**\r\n * Identifies the property that returns the length of the instance\r\n */\r\n length: unknown;\r\n}\r\n\r\n/**\r\n * Helper to return the length value of an object, this will return the value\r\n * of the \"length\" property. Generally used to return the length of a string or array.\r\n *\r\n * @since 0.4.2\r\n * @group Array\r\n * @group String\r\n * @group String\r\n * @group Array\r\n * @group Object\r\n * @param value - The value to return the length property from, must contain a `length` property\r\n * @example\r\n * ```ts\r\n * getLength(\"\"); // returns 0\r\n * getLength(\"Hello World\"); // returns 11\r\n * getLength([]); // returns 0;\r\n * getLength([0, 1, 2, 3]); // returns 4;\r\n * getLength({ length: 42}); // returns 42\r\n * getLength({ length: () => 53; }); // returns the function that if called would return 53\r\n * ```\r\n */\r\nexport const getLength: (value: T) => T[\"length\"] = (/*#__PURE__*/_unwrapProp(LENGTH));\r\n","/*\r\n * @nevware21/ts-utils\r\n * https://github.com/nevware21/ts-utils\r\n *\r\n * Copyright (c) 2022 NevWare21 Solutions LLC\r\n * Licensed under the MIT license.\r\n */\r\n\r\nimport { ICachedValue, createCachedValue } from \"./cache\";\r\nimport { utcNow } from \"./date\";\r\nimport { getInst } from \"./environment\";\r\nimport { _globalLazyTestHooks, _initTestHooks } from \"./lazy\";\r\nimport { safe } from \"./safe\";\r\n\r\nlet _perf: ICachedValue\r\n\r\n/**\r\n * Identify whether the runtimne contains a `performance` object\r\n *\r\n * @since 0.4.4\r\n * @group Environment\r\n * @returns\r\n */\r\n/*#__NO_SIDE_EFFECTS__*/\r\nexport function hasPerformance(): boolean {\r\n return !!getPerformance();\r\n}\r\n\r\n/**\r\n * Returns the global `performance` Object if available, which can be used to\r\n * gather performance information about the current document. It serves as the\r\n * point of exposure for the Performance Timeline API, the High Resolution Time\r\n * API, the Navigation Timing API, the User Timing API, and the Resource Timing API.\r\n *\r\n * @since 0.4.4\r\n * @group Environment\r\n * @returns The global performance object if available.\r\n */\r\n/*#__NO_SIDE_EFFECTS__*/\r\nexport function getPerformance(): Performance {\r\n !_globalLazyTestHooks && _initTestHooks();\r\n if (!_perf || _globalLazyTestHooks.lzy) {\r\n _perf = createCachedValue(safe(getInst, [\"performance\"]).v);\r\n }\r\n \r\n return _perf.v;\r\n}\r\n\r\n/**\r\n * Returns the number of milliseconds that has elapsed since the time origin, if\r\n * the runtime does not support the `performance` API it will fallback to return\r\n * the number of milliseconds since the unix epoch.\r\n *\r\n * @since 0.4.4\r\n * @group Timer\r\n *\r\n * @returns The number of milliseconds as a `DOMHighResTimeStamp` double value or\r\n * an integer depending on the runtime.\r\n * @example\r\n * ```ts\r\n * let now = perfNow();\r\n * ```\r\n */\r\n/*#__NO_SIDE_EFFECTS__*/\r\nexport function perfNow(): number {\r\n let perf = getPerformance();\r\n if (perf && perf.now) {\r\n return perf.now();\r\n }\r\n\r\n return utcNow();\r\n}\r\n\r\n/**\r\n * Return the number of milliseconds that have elapsed since the provided `startTime`\r\n * the `startTime` MUST be obtained from {@link perfNow} to ensure the correct elapsed\r\n * value is returned.\r\n *\r\n * @since 0.4.4\r\n * @group Timer\r\n *\r\n * @param startTime - The startTime obtained from `perfNow`\r\n * @returns The number of milliseconds that have elapsed since the startTime.\r\n * @example\r\n * ```ts\r\n * let start = perfNow();\r\n * // Do some work\r\n * let totalTime = elapsedTime(start);\r\n * ```\r\n */\r\n/*#__NO_SIDE_EFFECTS__*/\r\nexport function elapsedTime(startTime: number): number {\r\n return perfNow() - startTime;\r\n}","/*\r\n * @nevware21/ts-utils\r\n * https://github.com/nevware21/ts-utils\r\n *\r\n * Copyright (c) 2023 NevWare21 Solutions LLC\r\n * Licensed under the MIT license.\r\n */\r\n\r\nimport { NULL_VALUE, StrProto } from \"../internal/constants\";\r\nimport { _unwrapFunction, _unwrapFunctionWithPoly } from \"../internal/unwrapFunction\";\r\nimport { polyStrSymSplit } from \"../polyfills/split\";\r\nimport { hasSymbol } from \"../symbol/symbol\";\r\n\r\n/**\r\n * The `strSplit()` splits a string into substrings using the pattern and divides a String\r\n * into an ordered list of substrings by searching for the pattern, puts these substrings\r\n * into an array, and returns the array.\r\n * @since 0.9.1\r\n * @group String\r\n * @param value - The string value to be split into substrings.\r\n * @param separator - The pattern describing where each split should occur. Can be undefined, a\r\n * string, or an object with a [`Symbol.split`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Symbol/split)\r\n * method (if supported) — the typical example being a regular expression. Omitting separator or\r\n * passing undefined causes strSplit() to return an array with the calling string as a single\r\n * element. All values that are not undefined or objects with a `@@split` method are coerced to strings.\r\n * @param limit - A non-negative integer specifying a limit on the number of substrings to be\r\n * included in the array. If provided, splits the string at each occurrence of the specified\r\n * separator, but stops when limit entries have been placed in the array. Any leftover text is\r\n * not included in the array at all.\r\n * - The array may contain fewer entries than limit if the end of the string is reached before\r\n * the limit is reached.\r\n * - If limit is 0, [] is returned.\r\n * @return An Array of strings, split at each point where the separator occurs in the given string.\r\n * @example\r\n * ```ts\r\n * strSplit(\"Oh brave new world that has such people in it.\", \" \");\r\n * // [ \"Oh\", \"brave\", \"new\", \"world\", \"that\", \"has\", \"such\", \"people\", \"in\", \"it.\" ]\r\n *\r\n * strSplit(\"Jan,Feb,Mar,Apr,May,Jun,Jul,Aug,Sep,Oct,Nov,Dec\", \",\");\r\n * // [ \"Jan\", \"Feb\", \"Mar\", \"Apr\", \"May\", \"Jun\", \"Jul\", \"Aug\", \"Sep\", \"Oct\", \"Nov\", \"Dec\" ]\r\n * ```\r\n */\r\nexport const strSplit: (value: string, separator: string | RegExp, limit?: number) => string[] = (/*#__PURE__*/_unwrapFunction(\"split\", StrProto));\r\n\r\n/**\r\n * The `strSymSplit()` splits a string into substrings using the [`Symbol.split`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Symbol/split)\r\n * method from the splitter object to provide custom behavior. If the runtime supports symbols\r\n * then the default runtime `split` method will be called, It will use {@link getKnownSymbol}\r\n * to get the {@link WellKnownSymbols.split} symbol which will return the runtime symbol or the\r\n * polyfill symbol when not supported by the runtime.\r\n * @since 0.9.1\r\n * @group String\r\n * @param value - The string value to be split into substrings.\r\n * @param splitter - The object which contains a Symbol.split method, Omitting splitter or passing\r\n * an object that doesn't contain a Symbol.split causes it to return an array with the calling\r\n * string as a single element.\r\n * @param limit - A non-negative integer specifying a limit on the number of substrings to be\r\n * included in the array. If provided, splits the string at each occurrence of the specified\r\n * separator, but stops when limit entries have been placed in the array. Any leftover text is\r\n * not included in the array at all.\r\n * - The array may contain fewer entries than limit if the end of the string is reached before\r\n * the limit is reached.\r\n * - If limit is 0, [] is returned.\r\n * @return An Array of strings, split at each point where the separator occurs in the given string.\r\n * @example\r\n * ```ts\r\n * const splitByNumber = {\r\n * [Symbol.split]: (str: string) => {\r\n * let num = 1;\r\n * let pos = 0;\r\n * const result = [];\r\n * while (pos < str.length) {\r\n * const matchPos = strIndexOf(str, asString(num), pos);\r\n * if (matchPos === -1) {\r\n * result.push(strSubstring(str, pos));\r\n * break;\r\n * }\r\n * result.push(strSubstring(str, pos, matchPos));\r\n * pos = matchPos + asString(num).length;\r\n * num++;\r\n * }\r\n * return result;\r\n * }\r\n * };\r\n *\r\n * const myString = \"a1bc2c5d3e4f\";\r\n * console.log(strSymSplit(myString, splitByNumber)); // [ \"a\", \"bc\", \"c5d\", \"e\", \"f\" ]\r\n * ```\r\n */\r\nexport const strSymSplit: (value: string, splitter: { [Symbol.split](string: string, limit?: number): string[]; }, limit?: number) => string[] = (/*#__PURE__*/_unwrapFunctionWithPoly(\"split\", StrProto, !hasSymbol() ? polyStrSymSplit : NULL_VALUE));\r\n","/*\r\n * @nevware21/ts-utils\r\n * https://github.com/nevware21/ts-utils\r\n *\r\n * Copyright (c) 2022 NevWare21 Solutions LLC\r\n * Licensed under the MIT license.\r\n */\r\n\r\nimport { arrForEach } from \"../array/forEach\";\r\nimport { isNullOrUndefined } from \"./base\";\r\nimport { strSplit } from \"../string/split\";\r\nimport { iterForOf } from \"../iterator/forOf\";\r\n\r\n/**\r\n * Get the named value from the target object where the path may be presented by a string which\r\n * contains \".\" characters to separate the nested objects of the heirarchy / path to the value.\r\n * @since 0.9.1\r\n * @group Value\r\n * @param target - The source object that contains the value\r\n * @param path - The path identifing the location where the value should be located\r\n * @param defValue - If the final value or any intervening object in the heirarchy is not present\r\n * the default value will be returned\r\n * @returns The value located based on the path or the defaule value\r\n * @example\r\n * ```ts\r\n * let theValue = {\r\n * Hello: {\r\n * Darkness: {\r\n * my: \"old\"\r\n * }\r\n * },\r\n * friend: \"I've\",\r\n * come: {\r\n * to: {\r\n * see: \"you\"\r\n * }\r\n * }\r\n * };\r\n *\r\n * let value = getValueByKey(theValue, \"Hello.Darkness.my\", \"friend\");\r\n * // value === \"my\"\r\n *\r\n * let value = getValueByKey(theValue, \"My.Old\", \"friend\");\r\n * // value === \"friend\"\r\n *\r\n * let value = getValueByKey(theValue, \"come.to\", \"friend\");\r\n * // value === { see: \"you\" }\r\n *\r\n * let value = getValueByKey(theValue, \"friend\", \"friend\");\r\n * // value === \"I've\"\r\n * ```\r\n */\r\n/*#__NO_SIDE_EFFECTS__*/\r\nexport function getValueByKey(target: T, path: string, defValue?: V): V {\r\n if (!path || !target) {\r\n return defValue;\r\n }\r\n\r\n let parts = strSplit(path, \".\");\r\n let cnt = parts.length;\r\n\r\n for (let lp = 0; lp < cnt && !isNullOrUndefined(target); lp++) {\r\n target = target[parts[lp]];\r\n }\r\n\r\n return (!isNullOrUndefined(target) ? target : defValue) as V;\r\n}\r\n\r\n/**\r\n * Get the named value from the target object where the path is represented by the string iterator\r\n * or iterable to separate the nested objects of the heirarchy / path to the value. If the target\r\n * does not contain the full path the iterator will not be completed.\r\n *\r\n * The order of processing of the iterator is not reset if you add or remove elements to the iterator,\r\n * the actual behavior will depend on the iterator imeplementation.\r\n *\r\n * If the passed `iter` is both an Iterable and Iterator the Iterator interface takes preceedence.\r\n * @since 0.9.1\r\n * @group Value\r\n * @param target - The source object that contains the value\r\n * @param iter - The iter identifying the path of the final key value\r\n * @param defValue - If the final value or any intervening object in the heirarchy is not present\r\n * the default value will be returned\r\n * @returns The value located based on the path or the defaule value\r\n * @example\r\n * ```ts\r\n * let theValue = {\r\n * Hello: {\r\n * Darkness: {\r\n * my: \"old\"\r\n * }\r\n * },\r\n * friend: \"I've\",\r\n * come: {\r\n * to: {\r\n * see: \"you\"\r\n * }\r\n * }\r\n * };\r\n *\r\n * let value = getValueByKey(theValue, [\"Hello\", \"Darkness\", \"my\"], \"friend\");\r\n * // value === \"my\"\r\n *\r\n * let value = getValueByKey(theValue, [\"My\", \"Old\"], \"friend\");\r\n * // value === \"friend\"\r\n *\r\n * let value = getValueByKey(theValue, [\"come\", \"to\"], \"friend\");\r\n * // value === { see: \"you\" }\r\n *\r\n * let value = getValueByKey(theValue, [\"friend\"], \"friend\");\r\n * // value === \"I've\"\r\n * ```\r\n */\r\n/*#__NO_SIDE_EFFECTS__*/\r\nexport function getValueByIter