moderndash 3.3.2 → 3.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +35 -5
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +100 -56
- package/dist/index.js +33 -5
- package/dist/index.js.map +1 -1
- package/package.json +3 -2
package/dist/index.cjs
CHANGED
|
@@ -52,6 +52,7 @@ __export(src_exports, {
|
|
|
52
52
|
memoize: () => memoize,
|
|
53
53
|
merge: () => merge,
|
|
54
54
|
minCalls: () => minCalls,
|
|
55
|
+
move: () => move,
|
|
55
56
|
omit: () => omit,
|
|
56
57
|
pascalCase: () => pascalCase,
|
|
57
58
|
pick: () => pick,
|
|
@@ -61,6 +62,7 @@ __export(src_exports, {
|
|
|
61
62
|
randomInt: () => randomInt,
|
|
62
63
|
randomString: () => randomString,
|
|
63
64
|
range: () => range,
|
|
65
|
+
replaceLast: () => replaceLast,
|
|
64
66
|
retry: () => retry,
|
|
65
67
|
round: () => round,
|
|
66
68
|
set: () => set,
|
|
@@ -89,9 +91,8 @@ module.exports = __toCommonJS(src_exports);
|
|
|
89
91
|
// src/array/chunk.ts
|
|
90
92
|
function chunk(array, chunkSize) {
|
|
91
93
|
const intSize = Math.trunc(chunkSize);
|
|
92
|
-
if (array.length === 0 || intSize < 1)
|
|
94
|
+
if (array.length === 0 || intSize < 1)
|
|
93
95
|
return [];
|
|
94
|
-
}
|
|
95
96
|
let index = 0;
|
|
96
97
|
let resultIndex = 0;
|
|
97
98
|
const result = new Array(Math.ceil(array.length / intSize));
|
|
@@ -204,6 +205,25 @@ function intersection(...arraysOrCompareFn) {
|
|
|
204
205
|
return intersection2;
|
|
205
206
|
}
|
|
206
207
|
|
|
208
|
+
// src/array/move.ts
|
|
209
|
+
function move(array, fromIndex, toIndex) {
|
|
210
|
+
if (fromIndex < 0 || fromIndex >= array.length)
|
|
211
|
+
throw new Error(`Invalid 'fromIndex': ${fromIndex}. Must be between 0 and ${array.length - 1}.`);
|
|
212
|
+
if (toIndex < 0 || toIndex >= array.length)
|
|
213
|
+
throw new Error(`Invalid 'toIndex': ${toIndex}. Must be between 0 and ${array.length - 1}.`);
|
|
214
|
+
if (fromIndex === toIndex)
|
|
215
|
+
return array;
|
|
216
|
+
const item = array[fromIndex];
|
|
217
|
+
if (fromIndex < toIndex)
|
|
218
|
+
for (let index = fromIndex; index < toIndex; index++)
|
|
219
|
+
array[index] = array[index + 1];
|
|
220
|
+
else
|
|
221
|
+
for (let index = fromIndex; index > toIndex; index--)
|
|
222
|
+
array[index] = array[index - 1];
|
|
223
|
+
array[toIndex] = item;
|
|
224
|
+
return array;
|
|
225
|
+
}
|
|
226
|
+
|
|
207
227
|
// src/array/range.ts
|
|
208
228
|
function* range(start, end, step = 1) {
|
|
209
229
|
if (start > end)
|
|
@@ -226,9 +246,9 @@ function shuffle(array) {
|
|
|
226
246
|
}
|
|
227
247
|
|
|
228
248
|
// src/array/sort.ts
|
|
229
|
-
function sort(array, ...
|
|
249
|
+
function sort(array, ...criteria) {
|
|
230
250
|
return [...array].sort((a, b) => {
|
|
231
|
-
for (const { order, by } of
|
|
251
|
+
for (const { order, by } of criteria) {
|
|
232
252
|
const aValue = by ? by(a) : a;
|
|
233
253
|
const bValue = by ? by(b) : b;
|
|
234
254
|
if (aValue < bValue) {
|
|
@@ -556,7 +576,7 @@ function omit(object, keysToOmit) {
|
|
|
556
576
|
}
|
|
557
577
|
|
|
558
578
|
// src/object/set.ts
|
|
559
|
-
var validPathRegex = /^
|
|
579
|
+
var validPathRegex = /^[^.[\]]+(?:\.[^.[\]]+)*(?:\[\d+])*(?:\.[^.[\]]+(?:\[\d+])*)*$/;
|
|
560
580
|
var pathSplitRegex = /\.|(?=\[)/g;
|
|
561
581
|
var matchBracketsRegex = /[[\]]/g;
|
|
562
582
|
function set(obj, path, value) {
|
|
@@ -802,6 +822,14 @@ function pascalCase(str) {
|
|
|
802
822
|
return pascalCase2;
|
|
803
823
|
}
|
|
804
824
|
|
|
825
|
+
// src/string/replaceLast.ts
|
|
826
|
+
function replaceLast(str, searchFor, replaceWith) {
|
|
827
|
+
const index = str.lastIndexOf(searchFor);
|
|
828
|
+
if (index === -1)
|
|
829
|
+
return str;
|
|
830
|
+
return str.slice(0, index) + replaceWith + str.slice(index + searchFor.length);
|
|
831
|
+
}
|
|
832
|
+
|
|
805
833
|
// src/string/snakeCase.ts
|
|
806
834
|
function snakeCase(str) {
|
|
807
835
|
str = deburr(str);
|
|
@@ -983,6 +1011,7 @@ function isUrl(str) {
|
|
|
983
1011
|
memoize,
|
|
984
1012
|
merge,
|
|
985
1013
|
minCalls,
|
|
1014
|
+
move,
|
|
986
1015
|
omit,
|
|
987
1016
|
pascalCase,
|
|
988
1017
|
pick,
|
|
@@ -992,6 +1021,7 @@ function isUrl(str) {
|
|
|
992
1021
|
randomInt,
|
|
993
1022
|
randomString,
|
|
994
1023
|
range,
|
|
1024
|
+
replaceLast,
|
|
995
1025
|
retry,
|
|
996
1026
|
round,
|
|
997
1027
|
set,
|
package/dist/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts","../src/array/chunk.ts","../src/array/count.ts","../src/helpers/fastArrayFlat.ts","../src/array/difference.ts","../src/array/dropRightWhile.ts","../src/array/dropWhile.ts","../src/array/group.ts","../src/array/unique.ts","../src/array/intersection.ts","../src/array/range.ts","../src/array/shuffle.ts","../src/array/sort.ts","../src/array/takeRightWhile.ts","../src/array/takeWhile.ts","../src/crypto/hash.ts","../src/crypto/randomInt.ts","../src/crypto/randomElem.ts","../src/crypto/randomFloat.ts","../src/crypto/randomString.ts","../src/decorator/toDecorator.ts","../src/function/debounce.ts","../src/decorator/decDebounce.ts","../src/function/maxCalls.ts","../src/decorator/decMaxCalls.ts","../src/function/memoize.ts","../src/decorator/decMemoize.ts","../src/function/minCalls.ts","../src/decorator/decMinCalls.ts","../src/function/throttle.ts","../src/decorator/decThrottle.ts","../src/function/times.ts","../src/number/sum.ts","../src/number/average.ts","../src/number/median.ts","../src/number/round.ts","../src/validate/isPlainObject.ts","../src/object/flatKeys.ts","../src/object/merge.ts","../src/object/pick.ts","../src/object/omit.ts","../src/object/set.ts","../src/promise/queue.ts","../src/promise/races.ts","../src/promise/sleep.ts","../src/promise/retry.ts","../src/promise/timeout.ts","../src/promise/tryCatch.ts","../src/string/splitWords.ts","../src/string/deburr.ts","../src/string/camelCase.ts","../src/string/capitalize.ts","../src/string/escapeHtml.ts","../src/string/escapeRegExp.ts","../src/string/kebabCase.ts","../src/string/pascalCase.ts","../src/string/snakeCase.ts","../src/string/titleCase.ts","../src/string/trim.ts","../src/string/trimEnd.ts","../src/string/trimStart.ts","../src/string/unescapeHtml.ts","../src/validate/isEmpty.ts","../src/validate/isEqual.ts","../src/validate/isUrl.ts"],"sourcesContent":["export * from \"./array\";\nexport * from \"./crypto\";\nexport * from \"./decorator\";\nexport * from \"./function\";\nexport * from \"./number\";\nexport * from \"./object\";\nexport * from \"./promise\";\nexport * from \"./string\";\nexport * from \"./type\";\nexport * from \"./validate\";\n","/**\n * Creates an array of elements split into groups the length of size. If array can't be split evenly, the final chunk will be the remaining elements.\n *\n * @example\n * chunk(['a', 'b', 'c', 'd'], 2)\n * // => [['a', 'b'], ['c', 'd']]\n *\n * chunk(['a', 'b', 'c', 'd'], 3)\n * // => [['a', 'b', 'c'], ['d']]\n * @param chunkSize The length of each chunk\n * @param array The array to chunk.\n * @template TElem The type of the array elements.\n * @returns Returns the new array of chunks.\n */\n\nexport function chunk<TElem>(array: readonly TElem[], chunkSize: number): TElem[][] {\n const intSize = Math.trunc(chunkSize);\n if (array.length === 0 || intSize < 1) {\n return [];\n }\n \n let index = 0;\n let resultIndex = 0;\n const result = new Array(Math.ceil(array.length / intSize)) as TElem[][];\n\n while (index < array.length) {\n result[resultIndex++] = array.slice(index, (index += intSize));\n }\n\n return result;\n}\n","/**\n * Creates an object with counts of occurrences of items in the array.\n *\n * @example\n * const users = [\n * { 'user': 'barney', 'active': true, age: 36 },\n * { 'user': 'betty', 'active': false, age: 36 },\n * { 'user': 'fred', 'active': true, age: 40 }\n * ]\n *\n * count(users, value => value.active ? 'active' : 'inactive');\n * // => { 'active': 2, 'inactive': 1 }\n *\n * count(users, value => value.age);\n * // => { 36: 2, 40: 1 }\n *\n * @param criteria The criteria to count by.\n * @param array The array or record to iterate over.\n * @template TElem The type of the array elements.\n * @returns Returns the composed aggregate object.\n */\n\nexport function count<TElem, TKey extends PropertyKey>(array: readonly TElem[], criteria: (value: TElem) => TKey): Record<TKey, number> {\n const result = {} as Record<TKey, number>;\n for (const value of array) {\n const key = criteria(value);\n\n // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition\n result[key] = (result[key] ?? 0) + 1;\n }\n return result;\n}","// native array.flat is much slower than this - node 19\nexport function fastArrayFlat<TElem>(arrays: (readonly TElem[])[]): readonly TElem[] {\n let result = arrays.shift() ?? [];\n\n for (const array of arrays) {\n result = [...result, ...array];\n }\n\n return result;\n}","import type { CompareFunction } from \"@helpers/ArrayTypeUtils.js\";\nimport type { ArrayMinLength } from \"@type/ArrayMinLength.js\";\n\nimport { fastArrayFlat } from \"@helpers/fastArrayFlat.js\";\n\n/**\n * Create a new array with values from the first array that are not present in the other arrays.\n * \n * Optionally, use a compare function to determine the comparison of elements (default is `===`).\n * \n * @example\n * difference([2, 1], [2, 3], [6])\n * // => [1]\n *\n * // ---- Custom compare function ----\n * const compareByFloor = (a, b) => Math.floor(a) === Math.floor(b);\n * difference([1.2, 3.1], [1.3, 2.4], compareByFloor)\n * // => [3.1]\n *\n * // ---- Only compare by id ----\n * const arr1 = [{ id: 1, name: 'Yeet' }, { id: 3, name: 'John' }];\n * const arr2 = [{ id: 3, name: 'Carl' }, { id: 4, name: 'Max' }];\n *\n * difference(arr1, arr2, (a, b) => a.id === b.id)\n * // => [{ id: 1, name: 'Yeet' }]\n * @param arraysOrCompareFn Two or more arrays with an optional compare function at the end.\n * @template TElem The type of the array elements.\n * @template TArrays The type of the arrays provided.\n * @returns Returns the new array of filtered values.\n */\n\nexport function difference<TElem>(...arraysOrCompareFn: ArrayMinLength<TElem[], 2>): TElem[];\nexport function difference<TArrays extends ArrayMinLength<unknown[], 2>>(...arraysOrCompareFn: [...TArrays, CompareFunction<TArrays>]): TArrays[0];\nexport function difference<TArrays extends ArrayMinLength<unknown[], 2>, TElem>(...arraysOrCompareFn: ArrayMinLength<TElem[], 2> | [...TArrays, CompareFunction<TArrays>]): TArrays[0] {\n const compareFnProvided = typeof arraysOrCompareFn.at(-1) === \"function\";\n const compareFunction = compareFnProvided && arraysOrCompareFn.pop() as CompareFunction<TArrays>;\n\n const arrays = arraysOrCompareFn as TArrays;\n const firstArray = arrays.shift()!;\n const combinedRestArray = fastArrayFlat(arrays);\n\n if (!compareFunction) {\n const restSet = new Set(combinedRestArray);\n return firstArray.filter(element => !restSet.has(element));\n }\n\n const difference: TArrays[0] = [];\n for (const element of firstArray) {\n if (combinedRestArray.every(item => !compareFunction(element, item))) {\n difference.push(element);\n }\n }\n\n return difference;\n}","/**\n * Creates a slice of `array` excluding elements dropped from the end. \n * Elements are dropped until `predicate` returns falsy.\n *\n * @example\n * const users = [\n * { 'user': 'barney', 'active': false },\n * { 'user': 'fred', 'active': true },\n * { 'user': 'pebbles', 'active': true }\n * ]\n *\n * dropRightWhile(users, user => user.active)\n * // => objects for ['barney']\n * @param predicate The function invoked per iteration.\n * @param array The array to query.\n * @template TElem The type of the array elements.\n * @returns Returns the slice of `array`.\n */\n\nexport function dropRightWhile<TElem>(array: readonly TElem[], predicate: (value: TElem) => boolean) {\n let i = array.length;\n while (i > 0 && predicate(array[i - 1])) {\n i--;\n }\n return array.slice(0, i);\n}\n","/**\n * Creates a slice of `array` excluding elements dropped from the beginning. \n * Elements are dropped until `predicate` returns falsy.\n *\n * @example\n * const users = [\n * { 'user': 'barney', 'active': true },\n * { 'user': 'fred', 'active': true },\n * { 'user': 'pebbles', 'active': false }\n * ]\n *\n * dropWhile(users, user => user.active)\n * // => objects for ['pebbles']\n * @param predicate The function invoked per iteration.\n * @param array The array to query.\n * @template TElem The type of the array elements.\n * @returns Returns the slice of `array`.\n */\n\nexport function dropWhile<TElem>(array: readonly TElem[], predicate: (value: TElem) => boolean): TElem[] {\n const index = array.findIndex(x => !predicate(x));\n return array.slice(index === -1 ? array.length : index);\n}\n","/**\n * Creates an object with grouped items in the array.\n *\n * @example\n * group([6.1, 4.2, 6.3], Math.floor)\n * // => { 4: [4.2], 6: [6.1, 6.3] }\n *\n * group([6.1, 4.2, 6.3], value => value > 5 ? '>5' : '<=5')\n * // => { '<=5': [4.2], '>5': [6.1, 6.3] }\n * \n * @param collection The array or object to iterate over.\n * @param getGroupKey A function that returns the group id for each item.\n * @template TElem The type of the array elements.\n * @returns An object with grouped items.\n */\n\nexport function group<TElem, TKey extends PropertyKey>(array: readonly TElem[], getGroupKey: (elem: TElem) => TKey): Record<TKey, TElem[]> {\n const result = {} as Record<TKey, TElem[]>;\n for (const elem of array) {\n const key = getGroupKey(elem);\n // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition\n (result[key] ??= []).push(elem);\n }\n return result;\n}","/**\n * Creates a duplicate-free version of an array, in which only the first occurrence of each element is kept. \n * The order of result values is determined by the order they occur in the array.\n *\n * A compare function is optional to specify how the array is compared (default is `===`).\n * \n * @example\n * unique([2, 1, 2])\n * // => [2, 1]\n * \n * // compare by object values\n * const users = [\n * { id: 1, name: 'john' },\n * { id: 2, name: 'john' },\n * { id: 2, name: 'john' },\n * ]\n * \n * unique(users, isEqual)\n * // => [{ id: 1, name: 'john' }, { id: 2, name: 'john' }]\n * \n * // compare by id\n * unique(users, (a, b) => a.name === b.name)\n * // => [{ id: 1, name: 'john' }]\n *\n * @param array The array to inspect.\n * @param iteratee The iteratee invoked per element.\n * @template TElem The type of the array elements.\n * @returns Returns the new duplicate free array.\n */\n\nexport function unique<TElem>(array: readonly TElem[], compareFn?: (a: TElem, b: TElem) => boolean): TElem[] {\n // Arrays optimized with native Set\n if (!compareFn)\n return [...new Set(array)];\n\n const uniqueArray: TElem[] = [];\n for (const value of array) {\n let isUnique = true;\n \n for (const uniqueValue of uniqueArray) {\n if (compareFn(value, uniqueValue)) {\n isUnique = false;\n break;\n }\n }\n \n if (isUnique)\n uniqueArray.push(value);\n }\n \n return uniqueArray;\n}\n","import type { CompareFunction } from \"@helpers/ArrayTypeUtils.js\";\nimport type { ArrayMinLength } from \"@type/ArrayMinLength.js\";\n\nimport { fastArrayFlat } from \"@helpers/fastArrayFlat.js\";\n\nimport { unique } from \"./unique.js\";\n\n/**\n * Create an array with unique values that are present in all arrays. \n * The order of the values is based on the first array. \n * \n * Optionally, use a compare function for element comparison (default is `===`).\n * @example\n * intersection([2, 1], [2, 3], [6, 2])\n * // => [2]\n *\n * // ---- Custom compare function ----\n * const compareFn = (a, b) => Math.floor(a) === Math.floor(b);\n * \n * intersection([1.2, 1.1], [1.3, 2.4], compareFn)\n * // => [1.2]\n *\n * // ---- Only compare by id ----\n * const arr1 = [{ id: 1, name: 'Yeet' }, { id: 3, name: 'John' }];\n * const arr2 = [{ id: 3, name: 'Carl' }, { id: 4, name: 'Max' }];\n *\n * intersection(arr1, arr2, (a, b) => a.id === b.id)\n * // => [{ id: 3, name: 'John' }]\n * @param arraysOrCompareFn Two or more arrays with an optional compare function at the end.\n * @template TElem The type of the array elements.\n * @template TArrays The type of the arrays provided.\n * @returns Returns the new array of intersecting values.\n */\n\nexport function intersection<TElem>(...arraysOrCompareFn: ArrayMinLength<TElem[], 2>): TElem[];\nexport function intersection<TArrays extends ArrayMinLength<unknown[], 2>>(...arraysOrCompareFn: [...TArrays, CompareFunction<TArrays>]): TArrays[0];\nexport function intersection<TArrays extends ArrayMinLength<unknown[], 2>, TElem>(...arraysOrCompareFn: ArrayMinLength<TElem[], 2> | [...TArrays, CompareFunction<TArrays>]): TArrays[0] {\n const compareFnProvided = typeof arraysOrCompareFn.at(-1) === \"function\";\n const compareFunction = compareFnProvided && arraysOrCompareFn.pop() as CompareFunction<TArrays>;\n\n const arrays = arraysOrCompareFn as TArrays;\n const firstArray = unique(arrays.shift()!);\n const combinedRestArray = fastArrayFlat(arrays);\n\n if (!compareFunction) {\n const restSet = new Set(combinedRestArray);\n return firstArray.filter(element => restSet.has(element));\n }\n \n const intersection: TArrays[0] = [];\n\n for (const element of firstArray) {\n if (combinedRestArray.some(item => compareFunction(element, item))) {\n intersection.push(element);\n }\n }\n\n return intersection;\n}\n","/**\n * Generates an iterable sequence of numbers starting from `start`, up to and including `end`,\n * with a given `step` between each number.\n *\n * @example\n * for (const num of range(1, 5)) {\n * console.log(num);\n * }\n * // => 1 2 3 4 5\n * \n * // Generate an array of even numbers between 0 and 10:\n * const arr = [...range(0, 10, 2)];\n * // => [0, 2, 4, 6, 8, 10]\n * \n * @param start The starting number of the sequence.\n * @param end The end number of the sequence.\n * @param step The step between each number in the sequence. Defaults to 1.\n *\n * @returns An iterable sequence of numbers between `start` and `end`, inclusive, with increments of `step`.\n */\nexport function* range(start: number, end: number, step = 1): Generator<number> {\n if (start > end)\n throw new Error(\"The start of the range must be less than or equal to the end.\");\n\n if (step <= 0)\n throw new Error(\"The step must be greater than 0.\");\n \n for (let i = start; i <= end; i += step) {\n yield i;\n }\n}","/**\n * Creates a new array of shuffled values, using the Fisher-Yates-Durstenfeld Shuffle algorithm.\n *\n * @example\n * shuffle([1, 2, 3, 4])\n * // => [4, 1, 3, 2]\n * @param array The array or object to shuffle.\n * @template TElem The type of the array elements.\n * @returns Returns a new shuffled array.\n */\n\nexport function shuffle<TElem>(array: readonly TElem[]): TElem[] {\n const shuffledArray = [...array];\n \n for (let index = shuffledArray.length - 1; index > 0; index--) {\n const randomIndex = Math.floor(Math.random() * (index + 1));\n [shuffledArray[index], shuffledArray[randomIndex]] = [shuffledArray[randomIndex], shuffledArray[index]];\n }\n \n return shuffledArray;\n}","\n/**\n * Creates a new sorted array in ascending or descending order based on one or multiple sorting criteria.\n * \n * @example\n * sort([1, 2, 3, 4], { order: 'desc' })\n * // => [4, 3, 2, 1]\n * \n * // --- Sorting by multiple properties ---\n * const array = [{ a: 2, b: 1 }, { a: 1, b: 2 }, { a: 1, b: 1 }];\n * \n * sort(array,\n * { order: 'asc', by: item => item.a },\n * { order: 'desc', by: item => item.b }\n * )\n * // => [{ a: 1, b: 2 }, { a: 1, b: 1 }, { a: 2, b: 1 }]\n * @param array The array to sort.\n * @param orders The sorting criteria, one or multiple objects with properties order (either 'asc' or 'desc') and by (iteratee function to sort based on a specific property).\n * @param orders.order - The order to sort in, either 'asc' or 'desc'.\n * @param orders.by - The iteratee function to sort based on a specific property.\n * @template TElem The type of the array elements.\n * @returns Returns a new sorted array.\n*/\nexport function sort<TElem>(array: readonly TElem[], ...orders: { order?: \"asc\" | \"desc\", by?: (item: TElem) => number | bigint | Date | string }[]): TElem[] {\n return [...array].sort((a, b) => {\n for (const { order, by } of orders) {\n const aValue = by ? by(a) : a;\n const bValue = by ? by(b) : b;\n if (aValue < bValue) {\n return order === \"desc\" ? 1 : -1; \n }\n if (aValue > bValue) {\n return order === \"desc\" ? -1 : 1;\n }\n }\n return 0;\n });\n}","/**\n * Creates a slice of `array` with elements taken from the end. \n * Elements are taken until `predicate` returns falsy.\n * \n * @example\n * const users = [\n * { 'user': 'barney', 'active': false },\n * { 'user': 'fred', 'active': true },\n * { 'user': 'pebbles', 'active': true }\n * ]\n *\n * takeRightWhile(users, user => user.active)\n * // => objects for ['fred', 'pebbles']\n * @param predicate The function invoked per iteration.\n * @param array The array to query.\n * @template TElem The type of the array elements.\n * @returns Returns the slice of `array`.\n */\n\nexport function takeRightWhile<TElem>(array: readonly TElem[], predicate: (elem: TElem) => boolean): TElem[] {\n const result: TElem[] = [];\n\n for (let i = array.length - 1; i >= 0; i--) {\n if (predicate(array[i])) {\n result.unshift(array[i]);\n } else {\n break;\n }\n }\n\n return result;\n}\n","/**\n * Creates a slice of `array` with elements taken from the beginning. \n * Elements are taken until `predicate` returns falsy.\n *\n * @example\n * const users = [\n * { 'user': 'barney', 'active': true },\n * { 'user': 'fred', 'active': true },\n * { 'user': 'pebbles', 'active': false }\n * ]\n *\n * takeWhile(users, user => user.active)\n * // => objects for ['barney', 'fred']\n * @param predicate The function invoked per iteration.\n * @param array The array to query.\n * @template TElem The type of the array elements.\n * @returns Returns the slice of `array`.\n */\n\nexport function takeWhile<TElem>(array: readonly TElem[], predicate: (elem: TElem) => boolean): TElem[] {\n const result: TElem[] = [];\n\n for (const element of array) {\n if (predicate(element)) {\n result.push(element);\n } else {\n break;\n }\n }\n\n return result;\n}\n","import type { Jsonifiable } from \"@type/Jsonifiable.js\";\n\ntype SupportedAlgorithms = \"SHA-256\" | \"SHA-384\" | \"SHA-512\";\n\nlet textEncoder: TextEncoder | undefined;\n\n/**\n * Generates a hash from the given data using the specified algorithm.\n *\n * It uses the Web Crypto API to generate the hash.\n * \n * *Note: If you need a secure hash use a specialized library like [crypto-js](https://www.npmjs.com/package/crypto-js) instead.*\n * \n * @example\n * // Hash a string using the default algorithm (SHA-256)\n * await hash('hello world'); \n * // => \"b94d27b9934d3e08a52e52d7da7dabfac484efe37a53...\"\n *\n * // Hash an object using the SHA-512 algorithm\n * await hash({ foo: 'bar', baz: 123 }, 'SHA-512');\n * // => \"d8f3c752c6820e580977099368083f4266b569660558...\"\n * \n * @param data The data to hash, either as a string or a JSON-serializable object.\n * @param algorithm The hashing algorithm to use. Defaults to 'SHA-256'.\n * @returns A Promise that resolves to the hexadecimal representation of the hash.\n *\n * @throws {DOMException} If the specified algorithm is not supported by the Web Crypto API.\n */\n\nexport async function hash(data: Jsonifiable, algorithm: SupportedAlgorithms = \"SHA-256\"): Promise<string> {\n textEncoder ??= new TextEncoder();\n\n const dataBuffer = typeof data === \"string\"\n ? textEncoder.encode(data) \n : textEncoder.encode(JSON.stringify(data));\n \n const hashBuffer = await crypto.subtle.digest(algorithm, dataBuffer);\n const hashArray = [...new Uint8Array(hashBuffer)];\n const hexValues = hashArray.map(b => b.toString(16).padStart(2, \"0\"));\n return hexValues.join(\"\");\n}\n","\n/**\n * Generates a random integer between two given numbers, including those numbers.\n * \n * It uses `crypto.getRandomValues` to generate the random number.\n * @example\n * randomInt(1, 10) \n * // => 5\n * \n * @param min The smallest integer that can be generated.\n * @param max The largest integer that can be generated.\n * \n * @returns A random integer between `min` and `max`, including `min` and `max`.\n */\n\nexport function randomInt(min: number, max: number): number {\n // Taken from https://stackoverflow.com/a/41452318\n if (!Number.isInteger(min) || !Number.isInteger(max))\n throw new TypeError(\"min and max must be integers\");\n\n if (min >= max) \n throw new Error(\"max must be greater than min\");\n\n const range = max - min + 1;\n const randomBytes = Math.ceil(Math.log2(range) / 8);\n const maxRandNumber = Math.pow(256, randomBytes);\n const randomBuffer = new Uint8Array(randomBytes);\n\n let randomValue: number;\n do {\n crypto.getRandomValues(randomBuffer);\n randomValue = 0;\n for (let index = 0; index < randomBytes; index++) {\n // eslint-disable-next-line no-bitwise\n randomValue = (randomValue << 8) + randomBuffer[index];\n }\n // rerun if randomValue is bigger than range\n } while (randomValue >= maxRandNumber - (maxRandNumber % range));\n\n return min + (randomValue % range);\n}\n","import { randomInt } from \"./randomInt.js\";\n\n/**\n * Gets a random element an array. A single element is returned by default. \n * Specify the `multi` parameter to get an array of multiple random elements.\n *\n * If the array is empty, `undefined` is returned. \n * If `multi` is defined it returns an empty array.\n * \n * It uses `crypto.getRandomValues` to get the random element.\n * @example\n * randomElem([1, 2, 3, 4])\n * // => 2\n *\n * randomElem([1, 2, 3, 4], 2)\n * // => [3, 1]\n * @param array The array to sample.\n * @returns Returns the random element.\n */\n\nexport function randomElem<TArr>(array: TArr[]): TArr | undefined;\nexport function randomElem<TArr>(array: TArr[], multi: number): TArr[];\nexport function randomElem<TArr>(array: TArr[], multi?: number): TArr | undefined | TArr[] {\n if (multi === undefined) {\n if (array.length === 0) return undefined;\n return getSingleElement(array);\n }\n\n if (multi && array.length === 0) return [];\n\n // Multiple samples\n const result = new Array<TArr>(multi);\n for (let i = 0; i < multi; i++) {\n result[i] = getSingleElement(array);\n }\n return result;\n}\n\nfunction getSingleElement<TArr>(array: TArr[]): TArr {\n const randomIndex = randomInt(0, array.length - 1);\n return array[randomIndex];\n}","/* eslint-disable no-bitwise */\nconst shiftLeft20Bits = 2 ** 20;\nconst shiftRight52Bits = 2 ** -52;\n\n/**\n * Generates a random float between two given numbers, including those numbers.\n * \n * It uses `crypto.getRandomValues` to generate the random number.\n * @example\n * randomFloat(1, 10) \n * // => 1.123456789\n * \n * @param min The smallest float that can be generated.\n * @param max The largest float that can be generated.\n * \n * @returns A random float between `min` and `max`, including `min` and `max`.\n */\n\nexport function randomFloat(min: number, max: number): number {\n if (min >= max) {\n throw new Error(\"max must be greater than min\");\n }\n const range = max - min;\n const randomBuffer = new Uint32Array(2);\n crypto.getRandomValues(randomBuffer);\n\n // keep all 32 bits of the the first, top 20 of the second for 52 random bits\n const mantissa = (randomBuffer[0] * shiftLeft20Bits) + (randomBuffer[1] >>> 12);\n\n // shift all 52 bits to the right of the decimal point\n const randomFloat = mantissa * shiftRight52Bits;\n return min + (randomFloat * range);\n}","import { randomInt } from \"./randomInt.js\";\n\nconst DEFAULT_CHARSET = \"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789\";\n\n/**\n * Generates a random string of the specified length.\n * The default charset is alphanumeric characters.\n * \n * It uses `crypto.getRandomValues` to generate the random string.\n * \n * @example\n * randomString(8);\n * // => \"JWw1p6rD\"\n *\n * randomString(16, 'abc');\n * // => \"cbaacbabcabccabc\"\n * @param length The length of the string to generate.\n * @param charSet The set of characters to use when generating the string. Defaults to alphanumeric characters.\n * @returns A random string of the specified length.\n */\n\nexport function randomString(length: number, charSet = DEFAULT_CHARSET): string {\n if (charSet.length <= 0) return \"\";\n\n let result = \"\";\n for (let index = 0; index < length; index++) {\n const randomIndex = randomInt(0, charSet.length - 1);\n result += charSet[randomIndex];\n }\n\n return result;\n}","import type { GenericFunction } from \"@type/GenericFunction.js\";\n\ntype Tail<T extends unknown[]> = T extends [infer _Head, ...infer Tail] ? Tail : never;\n\n/**\n * Transforms a function that takes a function as first argument into a decorator function.\n * \n * @example\n * ```typescript\n * function log(func: Function, message: string) {\n * return function (...args: unknown[]) {\n * console.log(message);\n * return func(...args);\n * };\n * }\n * \n * const logger = toDecorator(log);\n * \n * class TestClass {\n * @logger(\"Hello world!\")\n * testMethod() {\n * return 1; \n * }\n * }\n * \n * const instance = new TestClass();\n * instance.testMethod(); \n * // => Log \"Hello World\" and return 1\n * ```\n * @param func The function to transform.\n * @returns A decorator function that can be used to decorate a method.\n */\n\nexport function toDecorator<TFunc extends GenericFunction<TFunc>>(func: TFunc) {\n return function (...args: Tail<Parameters<TFunc>>) {\n return function (_target: unknown, _key: string, descriptor: PropertyDescriptor) {\n const creatorArgs = [descriptor.value, ...args] as Parameters<TFunc>;\n descriptor.value = func(...creatorArgs);\n };\n };\n}","import type { GenericFunction } from \"@type/GenericFunction.js\";\n\n/**\n * Creates a debounced version of a function. Only calling it after a specified amount of time has passed without any new calls.\n * \n * **Methods:** \n * - `cancel` will cancel the next invocation of the debounced function. \n * - `flush` will immediately invoke the debounced function and cancel any pending invocations. \n * \n * This function can be used as a decorator with {@link decDebounce}.\n * \n * @example\n * const sayHello = (name: string) => console.log(`Hello, ${name}!`);\n * const debouncedSayHello = debounce(sayHello, 200);\n * \n * debouncedSayHello(\"John\");\n * debouncedSayHello(\"Jane\");\n * // => Only the second invocation of `debouncedSayHello` is executed, after a delay of 200ms.\n * @param func The function to debounce.\n * @param wait The number of milliseconds to wait before invoking `func`.\n * @returns A debounced version of `func` with `cancel` and `flush` methods.\n */\n\nexport function debounce<TFunc extends GenericFunction<TFunc>>(func: TFunc, wait: number): TFunc & {\n cancel: () => void;\n flush: () => void;\n} {\n let timeoutId: NodeJS.Timeout | undefined;\n const debounced = function (this: unknown, ...args: Parameters<TFunc>) {\n clearTimeout(timeoutId);\n timeoutId = setTimeout(() => func.apply(this, args), wait);\n };\n\n /** Cancels the next invocation of the debounced function. */\n debounced.cancel = function () {\n clearTimeout(timeoutId);\n timeoutId = undefined;\n };\n\n /** Immediately invokes the debounced function and cancels any pending invocations. */\n debounced.flush = function (this: unknown, ...args: Parameters<TFunc>) {\n if (timeoutId) {\n clearTimeout(timeoutId);\n timeoutId = undefined;\n }\n func.apply(this, args);\n };\n\n return debounced as TFunc & { cancel: () => void; flush: () => void };\n}","import { toDecorator } from \"@decorator/toDecorator.js\";\nimport { debounce } from \"@function/debounce.js\";\n\n/**\n * Debounces the decorated function. Only calling it after a specified amount of time has passed without any new calls.\n * \n * Look at {@link debounce} for the non-decorator version.\n * \n * *Requires the [experimentalDecorators](https://www.typescriptlang.org/tsconfig#experimentalDecorators) flag to be set.*\n * \n * @example\n * ```typescript\n * class TestClass {\n * @decDebounce(100)\n * testMethod(str: string) {\n * console.log(\"Debounced:\", str);\n * }\n * }\n * \n * const instance = new TestClass();\n * instance.testMethod(\"Hello\");\n * instance.testMethod(\"World\");\n * // => Only the second invocation of `debouncedSayHello` is executed, after a delay of 1000ms.\n * ```\n * @param wait Milliseconds to wait before invoking the decorated function after the last invocation.\n */\n\nexport function decDebounce(wait: number) {\n return toDecorator(debounce)(wait);\n}\n","import type { GenericFunction } from \"@type/GenericFunction.js\";\n\n/**\n * Creates a function that invokes the given function as long as it's called `<= n` times.\n * \n * Subsequent calls to the created function return the result of the last `func` invocation.\n *\n * This function can be used as a decorator with {@link decMaxCalls}.\n * @example\n * let count = 0;\n * const addCount = () => ++count;\n *\n * // Allow addCount to be invoked twice.\n * const limitAddCount = maxCalls(addCount, 2)\n *\n * limitAddCount() // => 1\n * limitAddCount() // => 2\n * limitAddCount() // => 2\n * // => `limitAddCount` is invoked twice and the result is cached.\n * @param n The number of calls before the cached result is returned.\n * @param func The function to restrict.\n * @returns Returns the new restricted function.\n */\n\nexport function maxCalls<TFunc extends GenericFunction<TFunc>>(func: TFunc, n: number): TFunc {\n let count = 0;\n let result: ReturnType<TFunc>;\n return function (this: unknown, ...args: Parameters<TFunc>): ReturnType<TFunc> {\n if (count < n) {\n count += 1;\n result = func.apply(this, args);\n }\n return result;\n } as TFunc;\n}\n","import { toDecorator } from \"@decorator/toDecorator.js\";\nimport { maxCalls } from \"@function/maxCalls.js\";\n\n/**\n * Only invokes the decorated function as long as it's called `<= n` times. \n * Subsequent calls to the decorated function return the result of the last invocation.\n * \n * Look at {@link maxCalls} for the non-decorator version.\n * \n * *Requires the [experimentalDecorators](https://www.typescriptlang.org/tsconfig#experimentalDecorators) flag to be set.*\n * \n * @example\n * ```typescript\n * class TestClass {\n * private count = 0;\n * @decMaxCalls(2)\n * testMethod() {\n * return ++this.count;\n * }\n * }\n * const instance = new TestClass();\n * instance.testMethod(); // => 1 \n * instance.testMethod(); // => 2\n * instance.testMethod(); // => 2\n * ```\n * @param n The number of calls before the cached result is returned.\n */\n\nexport function decMaxCalls(n: number) {\n return toDecorator(maxCalls)(n);\n}","import type { GenericFunction } from \"@type/GenericFunction.js\";\n\nconst defaultResolver = (...args: unknown[]) => JSON.stringify(args);\n\n/**\n * Creates a function that memoizes the result of a given function.\n * \n * The cache key is determined by the `resolver` or by the arguments from the function call.\n *\n * **Options:**\n * - `resolver` A function that determines the cache key based on the arguments provided.\n * - `ttl` the time to live for the cache entries in milliseconds.\n * \n * **Properties:**\n * - `cache` The cache is an instance of `Map` and can be used to clear or inspect the cache. \n * It can be replaced by a custom cache that matches the `Map` interface.\n * \n * \n * This function can be used as a decorator with {@link decMemoize}.\n * \n * @example\n * ```typescript\n * function fibonacci(n: number) {\n * if (n <= 1) return n;\n * return fibonacci(n - 1) + fibonacci(n - 2);\n * }\n *\n * const memoizedFib = memoize(fibonacci, { ttl: 1000 })\n * \n * memoizedFib(40) // => 102334155\n * memoizedFib(40) // => 102334155 (cache hit)\n * setTimeout(() => memoizedFib(40), 1000) // => 102334155 (cache miss)\n * \n * // Cached values are exposed as the `cache` property.\n * memoizedFib.cache.get(\"40\") // => [value, timestamp]\n * memoizedFib.cache.set(\"40\", [1234, Date.now()])\n * memoizedFib.cache.clear()\n * \n * // This is the default way to create cache keys.\n * const defaultResolver = (...args: unknown[]) => JSON.stringify(args)\n * ```\n * @param func The function to have its output memoized.\n * @param options The options object with optional `resolver` and `ttl` parameters.\n * @param options.resolver - A function that determines the cache key for storing the result based on the arguments provided.\n * @param options.ttl - The time to live for the cache in milliseconds.\n * @template TFunc The type of the function to memoize.\n * @template Cache The type of the cache storage.\n * @returns Returns the new memoized function.\n */\n\nexport function memoize<TFunc extends GenericFunction<TFunc>, Cache extends Map<string, [ReturnType<TFunc>, number]>>(\n func: TFunc, options: { resolver?: (...args: Parameters<TFunc>) => string, ttl?: number; } = {}\n): TFunc & { cache: Cache } {\n const resolver = options.resolver ?? defaultResolver;\n const ttl = options.ttl;\n const cache = new Map() as Cache;\n\n const memoizedFunc = function (this: unknown, ...args: Parameters<TFunc>): ReturnType<TFunc> {\n const key = resolver(...args);\n if (cache.has(key)) {\n const [cacheResult, cacheTime] = cache.get(key)!;\n if (ttl === undefined || (Date.now() - cacheTime < ttl)) {\n return cacheResult;\n }\n }\n const result = func.apply(this, args);\n cache.set(key, [result, Date.now()]);\n return result;\n };\n\n memoizedFunc.cache = cache;\n return memoizedFunc as TFunc & { cache: Cache };\n} ","import { toDecorator } from \"@decorator/toDecorator.js\";\nimport { memoize } from \"@function/memoize.js\";\n\n/**\n * Memoizes the decorated function. \n * The cache key is either determined by the provided resolver or by the arguments used in the memoized function.\n * \n * **Options:**\n * - `resolver` A function that determines the cache key for storing the result based on the arguments provided.\n * - `ttl` sets the time to live for the cache in milliseconds. After `ttl` milliseconds, the next call to the memoized function will result in a cache miss.\n * \n * Look at {@link memoize} for the non-decorator version.\n * \n * *Requires the [experimentalDecorators](https://www.typescriptlang.org/tsconfig#experimentalDecorators) flag to be set.*\n * \n * @example\n * ```typescript\n * class TestClass {\n * @decMemoize({ ttl: 1000 })\n * testMethod(a: number, b: number) {\n * return a + b;\n * }\n * }\n * const instance = new TestClass();\n * instance.testMethod(1, 2); // => 3\n * instance.testMethod(1, 2); // => 3 (cached)\n * \n * // After 1 second:\n * instance.testMethod(1, 2); // => 3 (cache miss)\n * ```\n * @param options The options object.\n * @param options.resolver - A function that determines the cache key for storing the result based on the arguments provided.\n * @param options.ttl - The time to live for the cache in milliseconds.\n */\n\nexport function decMemoize(options: Parameters<typeof memoize>[1] = {}) {\n return toDecorator(memoize)(options);\n}","import type { GenericFunction } from \"@type/GenericFunction.js\";\n\n/**\n * Creates a function that invokes the given function once it's called more than `n` times. \n * Returns undefined until the minimum call count is reached.\n * \n * This function can be used as a decorator with {@link decMinCalls}.\n * @example\n * const caution = () => console.log(\"Caution!\");\n * const limitedCaution = minCalls(caution, 2);\n *\n * limitedCaution()\n * limitedCaution()\n * limitedCaution()\n * // => `caution` is invoked on the third call.\n * @param n The number of calls before the given function is invoked.\n * @param func The function to restrict.\n * @returns Returns the new restricted function.\n */\n\nexport function minCalls<TFunc extends GenericFunction<TFunc>>(func: TFunc, n: number) {\n let count = 1;\n return function (this: unknown, ...args: Parameters<TFunc>): ReturnType<TFunc> | undefined {\n if (count > n) {\n return func.apply(this, args);\n }\n count += 1;\n };\n}","import { toDecorator } from \"@decorator/toDecorator.js\";\nimport { minCalls } from \"@function/minCalls.js\";\n\n/** \n * Only invokes the decorated function after it's called more than `n` times.\n * \n * Look at {@link minCalls} for the non-decorator version.\n * \n * *Requires the [experimentalDecorators](https://www.typescriptlang.org/tsconfig#experimentalDecorators) flag to be set.*\n * @example\n * ```typescript\n * class TestClass {\n * @decMinCalls(2)\n * testMethod() {\n * return 1;\n * }\n * }\n * const instance = new TestClass();\n * instance.testMethod(); // => undefined\n * instance.testMethod(); // => undefined\n * instance.testMethod(); // => 1\n * ```\n * @param n The number of calls before the decorated function is invoked.\n */\n\nexport function decMinCalls(n: number) {\n return toDecorator(minCalls)(n);\n}","import type { GenericFunction } from \"@type/GenericFunction.js\";\n\n/**\n * Generates a function that invokes the given function at most once per every `wait` milliseconds.\n * \n * This function can be used as a decorator with {@link decThrottle}.\n * @example\n * const throttled = throttle(() => console.log(\"Throttled!\"), 1000);\n * \n * throttled();\n * throttled();\n * // => \"Throttled!\" is logged once per second.\n * @param func The function to throttle.\n * @param wait The number of milliseconds to throttle invocations to.\n * @returns Returns the new throttled function.\n */\n\nexport function throttle<TFunc extends GenericFunction<TFunc>>(func: TFunc, wait: number): TFunc {\n let inThrottle = false;\n return function (this: unknown, ...args: Parameters<TFunc>) {\n if (!inThrottle) {\n func.apply(this, args);\n inThrottle = true;\n setTimeout(() => (inThrottle = false), wait);\n }\n } as TFunc;\n}\n \n","import { toDecorator } from \"@decorator/toDecorator.js\";\nimport { throttle } from \"@function/throttle.js\";\n\n/**\n * The decorated function is invoked at most once per every `wait` milliseconds.\n * \n * Look at {@link throttle} for the non-decorator version.\n * \n * *Requires the [experimentalDecorators](https://www.typescriptlang.org/tsconfig#experimentalDecorators) flag to be set.*\n * \n * @example\n * ```typescript\n * class TestClass {\n * @decThrottle(1000)\n * testMethod() {\n * console.log(\"Throttled!\");\n * }\n * }\n * \n * const instance = new TestClass();\n * instance.testMethod(); // => \"Throttled!\" is logged once per second.\n * instance.testMethod(); // nothing happens\n * ```\n * @param wait The number of milliseconds to wait between invocations.\n */\n\nexport function decThrottle(wait: number) {\n return toDecorator(throttle)(wait);\n}","/**\n * Invokes a function `n` times, returning an array of the results of\n * each invocation.\n * \n * @example\n * times(index => console.log(\"Run\", index), 3)\n * // => \"Run 0\" | \"Run 1\" | \"Run 2\"\n * times(Math.random, 3)\n * // => [0.123, 0.456, 0.789]\n * times(() => 0, 4)\n * // => [0, 0, 0, 0]\n * @param n The number of times to invoke `func`.\n * @param func The function invoked per iteration.\n * @returns Returns an array of results.\n */\n\nexport function times<TInput>(func: (index: number) => TInput, n: number): TInput[] {\n const result: TInput[] = [];\n for (let i = 0; i < n; i++) {\n result.push(func(i));\n }\n return result;\n}","/**\n * Calculates the sum of an array of numbers.\n * \n * Returns `NaN` if the input array is empty.\n * @example\n * sum([1, 2, 3, 4, 5]) // => 15\n * \n * @param numbers The input array of numbers\n * @returns The sum of the input array \n */\n\nexport function sum(numbers: readonly number[]): number {\n if (numbers.length === 0)\n return NaN;\n return numbers.reduce((total, current) => total + current, 0);\n}","import { sum } from \"@number/sum.js\";\n\n/**\n * Calculates the average of an array of numbers\n * \n * Returns `NaN` if the input array is empty.\n * @example\n * average([1, 2, 3, 4, 5]) // => 3\n * \n * @param numbers The input array of numbers\n * @returns The average of the input array, or NaN if the input array is empty\n */\n\nexport function average(numbers: readonly number[]): number {\n if (numbers.length === 0)\n return NaN;\n return sum(numbers) / numbers.length;\n}","/**\n * Calculates the median of an array of numbers\n * \n * Returns `NaN` if the input array is empty.\n * @example\n * median([1, 2, 3, 4, 5]) // => 3\n * median([1, 2, 3, 4, 5, 6]) // => 3.5\n * \n * @param numbers The input array of numbers\n * @returns The median of the input array\n */\n\nexport function median(numbers: readonly number[]): number {\n if (numbers.length === 0)\n return NaN;\n const sortedArray = [...numbers].sort((a, b) => a - b);\n const mid = Math.floor(sortedArray.length / 2);\n return sortedArray.length % 2 === 0 ? ((sortedArray[mid - 1] + sortedArray[mid]) / 2) : sortedArray[mid];\n}","/**\n * Rounds a number to the given precision.\n *\n * @example\n * round(1.23456, 2); // => 1.23\n * round(1.235, 1); // => 1.2\n * round(1234.56); // => 1234.56\n * \n * @param number The number to be rounded.\n * @param precision The number of decimal places to round to. Defaults to 2.\n * @returns The rounded number.\n */\n\nexport function round(number: number, precision = 2): number {\n const factor = Math.pow(10, precision);\n return Math.round((number + Number.EPSILON) * factor) / factor;\n}","import type { PlainObject } from \"@type/PlainObject.js\";\n\n/**\n * Checks if the value is a plain object.\n * \n * @example\n * isPlainObject({}) // => true\n * isPlainObject({ a: 1 }) // => true\n * isPlainObject(null) // => false\n * isPlainObject('1') // => false\n * isPlainObject([]) // => false\n * isPlainObject(new Function()) // => false\n * isPlainObject(new Date()) // => false\n * @param value The value to check\n * @returns Boolean indicating if the value is a plain object\n */\n\nexport function isPlainObject(value: unknown): value is PlainObject {\n return value?.constructor === Object;\n}","import type { PlainObject } from \"@type/PlainObject.js\";\n\nimport { isPlainObject } from \"@validate/isPlainObject.js\";\n\n/**\n * Flattens an object into a single level object.\n * \n * @example\n * const obj = { a: { b: 2, c: [{ d: 3 }, { d: 4 }] } };\n * flatKeys(obj);\n * // => { 'a.b': 2, 'a.c[0].d': 3, 'a.c[1].d': 4 }\n * \n * @param obj The object to flatten.\n * @template TObj The type of the object to flatten.\n * @returns A new object with flattened keys.\n */\n\nexport function flatKeys<TObj extends PlainObject>(obj: TObj): Record<string, unknown> {\n const flatObject: Record<string, unknown> = {};\n \n for (const [key, value] of Object.entries(obj)) {\n addToResult(key, value, flatObject);\n }\n \n return flatObject;\n}\n\nfunction addToResult(prefix: string, value: unknown, flatObject: Record<string, unknown>) {\n if (isPlainObject(value)) {\n const flatObj = flatKeys(value);\n for (const [flatKey, flatValue] of Object.entries(flatObj)) {\n flatObject[`${prefix}.${flatKey}`] = flatValue;\n }\n } else if (Array.isArray(value)) {\n for (const [index, element] of value.entries()) {\n addToResult(`${prefix}[${index}]`, element, flatObject);\n }\n\n } else {\n flatObject[prefix] = value;\n }\n}\n","import type { ArrayMinLength } from \"@type/ArrayMinLength.js\";\nimport type { PlainObject } from \"@type/PlainObject.js\";\n\nimport { isPlainObject } from \"@validate/isPlainObject.js\";\n\n/**\n * This function combines two or more objects into a single new object. Arrays and other types are overwritten.\n * \n * @example\n * // ---- Nested objects are merged ----\n * merge({ a: 1 }, { b: 2 }, { c: 3, d: { e: 4 } }) \n * // => { a: 1, b: 2, c: 3, d: { e: 4 } }\n *\n * // ---- Other types are overwritten ----\n * merge({ a: [1, 2] }, { a: [3, 4] })\n * // => { a: [3, 4] }\n * \n * merge({ a: 1 }, { a: \"Yes\" })\n * // => { a: \"Yes\" }\n * @param target The target object\n * @param sources The source objects\n * @template TTarget The type of the target object\n * @template TSources The type of the source objects\n * @returns A new merged object\n */\n\nexport function merge<TTarget extends PlainObject, TSources extends ArrayMinLength<PlainObject, 1>>(target: TTarget, ...sources: TSources): MergeDeepObjects<[TTarget, ...TSources]> {\n const targetCopy = { ...target };\n for (const source of sources) {\n for (const [key, value] of Object.entries(source)) {\n (targetCopy as PlainObject)[key] = isPlainObject(value) && isPlainObject(targetCopy[key]) \n ? merge(targetCopy[key] as PlainObject, value) \n : value;\n }\n }\n return targetCopy as MergeDeepObjects<[TTarget, ...TSources]>; \n}\n\ntype OptionalPropertyNames<T> =\n { [K in keyof T]-?: (PlainObject extends { [P in K]: T[K] } ? K : never) }[keyof T];\n\ntype SpreadProperties<L, R, K extends keyof L & keyof R> =\n { [P in K]: L[P] | Exclude<R[P], undefined> };\n\ntype Id<T> = T extends infer U ? { [K in keyof U]: U[K] } : never;\n\ntype SpreadTwo<L, R> = Id<\n& Pick<L, Exclude<keyof L, keyof R>>\n& Pick<R, Exclude<keyof R, OptionalPropertyNames<R>>>\n& Pick<R, Exclude<OptionalPropertyNames<R>, keyof L>>\n& SpreadProperties<L, R, OptionalPropertyNames<R> & keyof L>\n>;\n\ntype MergeDeepObjects<A extends readonly [...unknown[]]> = A extends [infer L, ...infer R] ?\n SpreadTwo<L, MergeDeepObjects<R>> : unknown;\n","import type { PlainObject } from \"@type/PlainObject.js\";\n\n/**\n * Creates an object composed of the picked `object` properties.\n *\n * @example\n * const object = { 'a': 1, 'b': '2', 'c': 3 }\n *\n * pick(object, ['a', 'c'])\n * // => { 'a': 1, 'c': 3 }\n * @param object The source object.\n * @param keysToPick The property paths to pick.\n * @template TObj The type of the object.\n * @returns Returns the new object.\n */\n\nexport function pick<TObj extends PlainObject, Key extends keyof TObj>(object: TObj, keysToPick: Key[]): Pick<TObj, Key> {\n const result = {} as Pick<TObj, Key>;\n for (const key of keysToPick) {\n result[key] = object[key];\n }\n return result;\n}\n","import type { PlainObject } from \"@type/PlainObject.js\";\n\nimport { pick } from \"./pick.js\";\n\n/**\n * Omit specified keys from an object\n *\n * @example\n * const obj = {a: 1, b: 2, c: 3};\n * omit(obj, ['a', 'b']);\n * // => {c: 3}\n *\n * @param object The object to filter\n * @param keysToOmit The keys to exclude from the returned object\n * @template TObj The type of the object\n * @returns - An object without the specified keys\n */\n\nexport function omit<TObj extends PlainObject, Key extends keyof TObj>(object: TObj, keysToOmit: Key[]): Omit<TObj, Key> {\n const keys = Object.keys(object);\n const filteredKeys = keys.filter(key => !keysToOmit.includes(key as Key)) as Exclude<keyof TObj, Key>[];\n\n return pick(object, filteredKeys);\n}","import type { PlainObject } from \"@type/PlainObject.js\";\n\nimport { isPlainObject } from \"@validate/isPlainObject.js\";\n\nconst validPathRegex = /^(?:[^.[\\]]+(?:\\[\\d+])*(?:\\.|\\[\\d+]))+(?:[^.[\\]]+(?:\\[\\d+])*)+$/;\nconst pathSplitRegex = /\\.|(?=\\[)/g;\nconst matchBracketsRegex = /[[\\]]/g;\n\n/**\n * Sets the value at path of object. If a portion of path doesn’t exist, it’s created.\n * \n * @example\n * const obj = { a: { b: 2 } };\n * set(obj, 'a.c', 1);\n * // => { a: { b: 2, c: 1 } }\n * \n * // `[number]` can be used to access array elements\n * set(obj, 'a.c[0]', 'hello');\n * // => { a: { b: 2, c: ['hello'] } }\n * \n * // numbers with dots are treated as keys\n * set(obj, 'a.c.0.d', 'world');\n * // => { a: { b: 2, c: { 0: { d: 'world' } } }\n * \n * // supports numbers in keys\n * set(obj, 'a.e0.a', 1);\n * // => { a: { e0: { a: 1 } } }\n * \n * @param obj The object to modify.\n * @param path The path of the property to set.\n * @param value The value to set.\n * @template TObj The type of the object.\n * @returns The modified object.\n */\n\nexport function set(obj: PlainObject, path: string, value: unknown): PlainObject {\n if (!validPathRegex.test(path))\n throw new Error(\"Invalid path, look at the examples for the correct format.\");\n\n const pathParts = path.split(pathSplitRegex);\n let currentObj: PlainObject = obj;\n for (let index = 0; index < pathParts.length; index++) {\n const key = pathParts[index].replace(matchBracketsRegex, \"\");\n\n if (index === pathParts.length - 1) {\n currentObj[key] = value;\n break;\n }\n\n const nextElemIn = pathParts[index + 1].startsWith(\"[\") ? \"array\" : \"object\";\n if (currentObj[key] === undefined) {\n currentObj[key] = nextElemIn === \"array\" ? [] : {};\n } else if (nextElemIn === \"array\" && !Array.isArray(currentObj[key])) {\n currentObj[key] = [];\n } else if (nextElemIn === \"object\" && !isPlainObject(currentObj[key])) {\n currentObj[key] = {};\n }\n currentObj = currentObj[key] as PlainObject;\n }\n\n return obj;\n}","/**\n * A class for managing a queue of async functions that runs a set number concurrently. \n * If for example you have 10 async functions and you want to run 3 at a time, you can use this class.\n * \n * If the queue is paused, the queue will not run any more async functions until it is resumed.\n * \n * **Methods:**\n * - `add` - adds a async function or array of functions to the queue. Returns a promise that resolves when the added function(s) finish.\n * - `clear` - clears the queue.\n * - `pause` - pauses the queue.\n * - `resume` - resumes the queue. \n * - `getQueue` - returns the current queue.\n * - `isPaused` - returns whether the queue is paused.\n * \n * @example\n * // Create a queue that can run 3 tasks concurrently\n * const queue = new Queue(3);\n * \n * queue.add(() => fetch('https://example.com'));\n * \n * queue.add(async () => {\n * const response = await fetch('https://example.com');\n * return response.json();\n * });\n * \n * // Add an array of tasks to the queue and wait for them to resolve\n * await queue.add([\n * () => fetch('https://apple.com'),\n * () => fetch('https://microsoft.com')\n * ]);\n * // => [Response, Response]\n */\n\nexport class Queue {\n private running = 0;\n private maxConcurrent: number;\n private paused = false;\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n private queue: { asyncFn: () => Promise<any>, resolve: (value: any) => void, reject: (reason?: any) => void }[] = [];\n\n /**\n * @constructor\n * @param maxConcurrent The maximum number of async functions to run concurrently.\n */\n constructor(maxConcurrent: number) {\n this.maxConcurrent = maxConcurrent;\n }\n\n /**\n * Add async functions or an array of async functions to the queue.\n * \n * @param asyncFn The async function(s) to add to the queue.\n * @returns A promise that resolves when the added function(s) finishes.\n */\n add<TProm, TAsyncFn extends () => Promise<TProm>>(asyncFn: TAsyncFn): Promise<TProm>;\n add<TProm, TAsyncFn extends () => Promise<TProm>>(asyncFn: TAsyncFn[]): Promise<TProm[]>;\n add<TProm, TAsyncFn extends () => Promise<TProm>>(asyncFn: TAsyncFn | TAsyncFn[]): Promise<TProm> | Promise<TProm[]> {\n if (Array.isArray(asyncFn)) {\n const promises = asyncFn.map((fn) => this.buildWaitingPromise(fn));\n return Promise.all(promises);\n } else {\n return this.buildWaitingPromise(asyncFn);\n } \n }\n\n private buildWaitingPromise<TProm>(asyncFn: () => Promise<TProm>): Promise<TProm> {\n return new Promise((resolve, reject) => {\n this.queue.push({ asyncFn, resolve, reject });\n this.run();\n });\n } \n\n private run() {\n while (this.queue.length > 0 && this.running < this.maxConcurrent && !this.paused) {\n this.running++;\n const queueElement = this.queue.shift()!;\n void queueElement.asyncFn()\n .then((result) => {\n queueElement.resolve(result);\n }).catch((error) => {\n queueElement.reject(error);\n }).finally(() => {\n this.running--;\n this.run();\n });\n }\n }\n\n /** Removes all the tasks from the queue */\n clear() {\n for (const queueElement of this.queue) {\n queueElement.reject(new Error(\"Queue cleared\"));\n }\n this.queue = [];\n }\n\n /** Pauses the execution of the queue */\n pause() {\n this.paused = true;\n }\n\n /** Resumes the execution of the tasks in the queue */\n resume() {\n this.paused = false;\n this.run();\n }\n\n /** Return the tasks added to the queue */\n getQueue() {\n return this.queue.map((queueElement) => queueElement.asyncFn);\n }\n\n /** Returns whether the queue is paused */\n isPaused() {\n return this.paused;\n }\n\n}\n","/**\n * Similar to [Promise.race](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise/race?retiredLocale=de) \n * but allows to specify how many promises to wait for.\n *\n * @example\n * const prom1 = Promise.resolve(1);\n * const prom2 = new Promise(resolve => setTimeout(resolve, 100, 2));\n * const prom3 = Promise.resolve(3);\n * \n * const firstTwo = await races(2, prom1, prom2, prom3);\n * // => [1, 3]\n * \n * @template TRes The type of the result of the promises.\n * @param waitFor The number of promises to wait for.\n * @param promises The promises to wait for.\n * @returns A promise that resolves an array of the results of the first n promises.\n */\n\nexport function races<TRes>(waitFor: number, ...promises: Promise<TRes>[]): Promise<TRes[]> {\n return new Promise((resolve, reject) => {\n if (promises.length < waitFor)\n waitFor = promises.length;\n\n const results: TRes[] = [];\n let resolved = 0;\n for (const promise of promises) {\n promise.then((value) => {\n results.push(value);\n resolved++;\n if (resolved >= waitFor) {\n resolve(results);\n }\n }).catch((error) => {\n reject(error);\n });\n }\n });\n}","/**\n * Sleeps for the given amount of time.\n *\n * @example\n * await sleep(1000);\n * // => Waits for 1 second.\n * @param ms Amount of time to sleep in milliseconds.\n * @returns A promise that resolves after the given amount of time.\n */\nexport function sleep(ms: number) {\n return new Promise((resolve) => setTimeout(resolve, ms));\n}","/* eslint-disable no-await-in-loop */\nimport { sleep } from \"@promise/sleep.js\";\n\n/**\n * Retry a function until it succeeds or the maximum number of retries is reached.\n * \n * Default maxRetries: `5`. \n * Default backoff: `2^retries * 100ms` (100, 200, 400, 800, 1600, 3200, ...)\n *\n * @example\n * await retry(() => fetch('https://example.com'));\n * \n * // ---- Advanced example ----\n * const fetchSite = async () => {\n * const response = await fetch('https://example.com');\n * if(!response.ok)\n * throw new Error('Failed to fetch');\n * }\n * \n * const logger = (error: unknown, retry?: number) => console.log(\"Retrying\", retry, error);\n * \n * await retry(fetchSite, { maxRetries: 3, backoff: retries => retries * 1000, onRetry: logger });\n * // => Will retry 3 times with a 1 second delay between each retry.\n * // => Will log the error and retry number.\n * \n * @param func The function to retry.\n * @param options The options for the retry.\n * @param options.maxRetries The maximum number of retries. Defaults to `5`.\n * @param options.backoff The backoff function to use. Defaults to `2^retries * 100`.\n * @param options.onRetry The function to call when a retry is attempted. It will be called with the error and the attempt number.\n * @template TRes The type of the result of the function.\n * @returns A promise that resolves when the function succeeds.\n */\n\nexport async function retry<TRes>(\n func: () => Promise<TRes>, \n options?: { \n maxRetries?: number,\n backoff?: ((retries: number) => number),\n onRetry?: (error?: unknown, attempted?: number) => void\n }\n): Promise<TRes> {\n const backOffFn = options?.backoff ?? (retries => (2 ** retries) * 100);\n const maxRetries = options?.maxRetries ?? 5;\n // eslint-disable-next-line @typescript-eslint/no-empty-function\n const onRetry = options?.onRetry ?? (() => {});\n let retries = 0;\n let lastError: unknown;\n\n while (retries <= maxRetries) {\n try {\n if (retries > 0)\n onRetry(lastError, retries);\n return await func();\n } catch (error) {\n lastError = error;\n retries++;\n if (retries > maxRetries) {\n throw error;\n }\n await sleep(backOffFn(retries));\n }\n /* c8 ignore next 2 */\n }\n throw new Error(\"Retry terminated without success, this should never happen\");\n}","/**\n * Returns a new promise that will reject with an error after a specified timeout. \n *\n * @example\n * try {\n * await timeout(fetch('https://example.com'), 1000);\n * } catch (error) {\n * console.log(error.message);\n * // => 'Promise timed out after 1000ms'\n * }\n * @template TRes - The type of the resolved value.\n * @param promise The promise to wrap.\n * @param timeout The timeout in milliseconds.\n * \n * @returns A new promise that will reject with an error after the specified timeout.\n */\nexport function timeout<TRes>(promise: Promise<TRes>, timeout: number): Promise<TRes> {\n return new Promise((resolve, reject) => {\n const timeoutId = setTimeout(() => {\n reject(new Error(`Promise timed out after ${timeout}ms`));\n }, timeout);\n \n promise.then(\n (result) => {\n clearTimeout(timeoutId);\n resolve(result);\n },\n (error) => {\n clearTimeout(timeoutId);\n reject(error);\n }\n );\n });\n}","/**\n * Attempts to execute a promise and returns an array with the result or error.\n * \n * This is useful for handling errors in async functions without try/catch blocks.\n * \n * @example\n * ```typescript\n * const [data, error] = await tryCatch(fetch('https://example.com/api'));\n * if (error)\n * console.error(`Error: ${error.message}`);\n * ```\n * @param promise A Promise to be executed.\n * @returns A Promise that resolves to an array containing the result or error. \n * If the Promise executes successfully, the array contains the result and a null error. \n * If the Promise throws an error, the array contains undefined for the result and the error object.\n *\n * @template TRes The type of the result.\n */\n\nexport async function tryCatch<TRes>(promise: Promise<TRes>): Promise<[TRes, undefined] | [undefined, Error]> {\n try {\n const data = await promise;\n return [data, undefined];\n } catch (error) {\n if (error instanceof Error)\n return [undefined, error];\n\n throw error;\n }\n}","const wordsRegex = /(?:\\d*[a-z]+)|(?:[A-Z][a-z]+)|(?:\\d*[A-Z]+(?=[^a-z]|$))|\\d+/g;\n\n/**\n * Split a string into words. Can deal with camelCase, PascalCase & snake_case.\n * \n * @example\n * splitWords('camelCase')\n * // => ['camel', 'Case']\n * \n * splitWords('PascalCase')\n * // => ['Pascal', 'Case']\n * \n * splitWords('hello_world-123')\n * // => ['hello', 'world', '123']\n * \n * @param str The string to split into words.\n * @param forceFallback Force the use of the positive lookahead fallback. Only used for testing.\n * @returns An array of words.\n */\n\nexport function splitWords(str: string): string[] {\n return str.match(wordsRegex) ?? [];\n}","const accentControlRegex = /[\\u0300-\\u036F]/g;\n\n/**\n * Deburrs a string by converting\n * [Latin-1 Supplement](https://en.wikipedia.org/wiki/Latin-1_Supplement_(Unicode_block)#Character_table)\n * and [Latin Extended-A](https://en.wikipedia.org/wiki/Latin_Extended-A)\n * letters to basic Latin letters and removing\n * [combining diacritical marks](https://en.wikipedia.org/wiki/Combining_Diacritical_Marks).\n *\n * @example\n * deburr('déjà vu')\n * // => 'deja vu'\n * @param str The string to deburr.\n * @returns Returns the deburred string.\n */\n\nexport function deburr(str: string): string {\n return str.normalize(\"NFD\").replace(accentControlRegex, \"\");\n}\n","import { splitWords } from \"@string/splitWords\";\n\nimport { deburr } from \"./deburr.js\";\n\n/**\n * Converts `string` to camelCase.\n *\n * @example\n * camelCase('Foo Bar')\n * // => 'fooBar'\n * camelCase('--foo-bar--')\n * // => 'fooBar'\n * camelCase('__FOO_BAR__')\n * // => 'fooBar'\n * @param str The string to convert.\n * @returns Returns the camel cased string.\n */\n\nexport function camelCase(str: string): string {\n str = deburr(str);\n const words = splitWords(str);\n\n let camelCase = \"\";\n for (const [index, word] of words.entries()) {\n camelCase += index === 0 \n ? word.toLowerCase() \n : word.charAt(0).toUpperCase() + word.slice(1).toLowerCase();\n }\n\n return camelCase;\n}","/**\n * Converts the first character of a string to upper case and the remaining to lower case.\n *\n * @example\n * capitalize('FRED')\n * // => 'Fred'\n * @param str The string to capitalize.\n * @returns Returns the capitalized string.\n */\n\nexport function capitalize(str: string): string {\n return str.charAt(0).toUpperCase() + str.slice(1);\n}\n","const charRegex = /[\"&'<>]/g;\nconst escapeChars = new Map([\n [\"&\", \"&\"],\n [\"<\", \"<\"],\n [\">\", \">\"],\n [\"'\", \"'\"],\n ['\"', \""\"]\n]);\n\n/**\n * Converts the characters `&`, `<`, `>`, `\"` and `'` in a string to their corresponding HTML entities.\n *\n * @example\n * escapeHtml('fred, barney, & pebbles')\n * // => 'fred, barney, & pebbles'\n * @param str The string to escape.\n * @returns Returns the escaped string.\n */\n\nexport function escapeHtml(str: string): string {\n return str.replace(charRegex, char => escapeChars.get(char)!);\n}\n","const escapeCharsRegex = /[$()*+.?[\\\\\\]^{|}]/g;\n\n/**\n * Escapes the `RegExp` special characters `^`, `$`, `\\`, `.`, `*`, `+`,\n * `?`, `(`, `)`, `[`, `]`, `{`, `}`, and `|` in a string.\n *\n * @example\n * escapeRegExp('[moderndash](https://moderndash.io/)')\n * // => '\\[moderndash\\]\\(https://moderndash\\.io/\\)'\n * @param str The string to escape.\n * @returns Returns the escaped string.\n */\n\nexport function escapeRegExp(str: string): string {\n return str.replace(escapeCharsRegex, \"\\\\$&\");\n}\n","import { splitWords } from \"@string/splitWords\";\n\nimport { deburr } from \"./deburr.js\";\n\n/**\n * Converts a string to kebab-case.\n *\n * @example\n * kebabCase('Foo Bar')\n * // => 'foo-bar'\n * kebabCase('fooBar')\n * // => 'foo-bar'\n * kebabCase('__FOO_BAR__')\n * // => 'foo-bar'\n * \n * @param str The string to convert.\n * @returns Returns the kebab cased string.\n */\n\nexport function kebabCase(str: string): string {\n str = deburr(str);\n const words = splitWords(str);\n let kebabCase = \"\";\n for (const word of words) {\n kebabCase += word.toLowerCase() + \"-\";\n }\n return kebabCase.slice(0, -1);\n}\n","import { splitWords } from \"@string/splitWords\";\n\nimport { deburr } from \"./deburr.js\";\n\n\n/**\n * Converts a string to PascalCase.\n *\n * @example\n * pascalCase('Foo Bar')\n * // => 'FooBar'\n * pascalCase('fooBar')\n * // => 'FooBar'\n * pascalCase('__FOO_BAR__')\n * // => 'FooBar'\n * \n * @param str The string to convert.\n * @returns Returns the pascal cased string.\n */\n\nexport function pascalCase(str: string): string {\n str = deburr(str);\n const words = splitWords(str);\n let pascalCase = \"\";\n for (const word of words) {\n pascalCase += word.charAt(0).toUpperCase() + word.slice(1);\n }\n return pascalCase;\n}\n","import { splitWords } from \"@string/splitWords\";\n\nimport { deburr } from \"./deburr.js\";\n\n/**\n * Converts a string to snake_case.\n *\n * @example\n * snakeCase('Foo Bar')\n * // => 'foo_bar'\n * snakeCase('fooBar')\n * // => 'foo_bar'\n * snakeCase('--FOO-BAR--')\n * // => 'foo_bar'\n * snakeCase('foo2bar')\n * // => 'foo_2_bar'\n * \n * @param str The string to convert.\n * @returns Returns the snake cased string.\n */\n\nexport function snakeCase(str: string): string {\n str = deburr(str);\n const words = splitWords(str);\n let snakeCase = \"\";\n for (const word of words) {\n if (snakeCase.length > 0) {\n snakeCase += \"_\";\n }\n snakeCase += word.toLowerCase();\n }\n return snakeCase;\n}\n","import { splitWords } from \"@string/splitWords\";\n\nimport { deburr } from \"./deburr.js\";\n\n/**\n * Converts a string to Title Case.\n *\n * @example\n * titleCase('--foo-bar--')\n * // => 'Foo Bar'\n * titleCase('fooBar')\n * // => 'Foo Bar'\n * titleCase('__FOO_BAR__')\n * // => 'Foo Bar'\n * titleCase('HélloWorld')\n * // => 'Hello World'\n * @param str The string to convert.\n * @returns Returns the title cased string.\n */\n\nexport function titleCase(str: string): string {\n str = deburr(str);\n const words = splitWords(str);\n let titleCase = \"\";\n for (const word of words) {\n titleCase += word.charAt(0).toUpperCase() + word.slice(1).toLowerCase() + \" \";\n }\n return titleCase.trimEnd();\n}\n","/**\n * Trim the string from the left and right by the given characters\n * \n * *Use the native [trim](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/trim) method if you want to trim whitespace.*\n * @example\n * ```ts\n * trim('$$abc$', '$') // => 'abc'\n * trim('!!abc_!', '_!') // => 'abc'\n * ```\n * @param str The string to trim\n * @param chars The characters to trim\n * @returns The trimmed string\n */\n\nexport function trim(str: string, chars: string): string {\n let startIndex = 0;\n while (startIndex < str.length && chars.includes(str[startIndex])) {\n startIndex++;\n }\n \n let endIndex = str.length - 1;\n while (endIndex >= startIndex && chars.includes(str[endIndex])) {\n endIndex--;\n }\n \n return str.slice(startIndex, endIndex + 1);\n}","/**\n * Trims the specified characters from the end of the string.\n * \n * *Use the native [trimEnd](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/trimEnd) method if you want to trim whitespace.*\n * @example\n * ```ts\n * trimEnd('abc$$$', '$') // => 'abc'\n * trimEnd('abc_!!_', '_!') // => 'abc'\n * ```\n * @param str The string to trim\n * @param chars The characters to trim\n * @returns The trimmed string\n */\n\nexport function trimEnd(str: string, chars: string): string {\n let lastIndex = str.length - 1;\n while (lastIndex >= 0 && chars.includes(str[lastIndex])) {\n lastIndex--;\n }\n return str.slice(0, lastIndex + 1);\n\n}","/**\n * Trims specified characters from the start of the string.\n * \n * *Use the native [trimStart](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/trimStart) method if you want to trim whitespace.*\n * @example\n * ```ts\n * trimStart('$$$abc', '$') // => 'abc'\n * trimStart('_!!_abc', '_!') // => 'abc'\n * ```\n * @param str The string to trim\n * @param chars The characters to trim\n * @returns The trimmed string\n */\n\nexport function trimStart(str: string, chars: string): string {\n let startIndex = 0;\n while (startIndex < str.length && chars.includes(str[startIndex])) {\n startIndex++;\n }\n return str.slice(startIndex);\n}","const htmlEntitiesRegex = /&(?:amp|lt|gt|quot|#39);/g;\nconst entityMap = new Map([\n [\"&\", \"&\"],\n [\"<\", \"<\"],\n [\">\", \">\"],\n [\""\", '\"'],\n [\"'\", \"'\"]\n]);\n\n/**\n * Converts the HTML entities `&`, `<`, `>`, `"` and `'`\n * in a string to their corresponding characters.\n *\n * @example\n * unescapeHtml('fred, barney, & pebbles')\n * // => 'fred, barney, & pebbles'\n * @param str The string to unescape.\n * @returns Returns the unescaped string.\n */\n\nexport function unescapeHtml(str: string): string {\n return str.replace(htmlEntitiesRegex, (entity: string) => entityMap.get(entity)!);\n}\n","\n/**\n * Checks if a value is empty.\n * \n * Supports: strings, arrays, objects, maps, sets, typed arrays.\n * @example\n * isEmpty(null)\n * // => true\n *\n * isEmpty({})\n * // => true\n *\n * isEmpty(\"\")\n * // => true\n *\n * isEmpty([1, 2, 3])\n * // => false\n *\n * isEmpty('abc')\n * // => false\n *\n * isEmpty({ 'a': 1 })\n * // => false\n * @param value The value to check.\n * @returns Returns `true` if `value` is empty, else `false`.\n */\n\nexport function isEmpty(value: string | object | null | undefined): boolean {\n if (value === null || value === undefined)\n return true;\n\n if (typeof value === \"string\" || Array.isArray(value))\n return value.length === 0;\n\n if (value instanceof Map || value instanceof Set)\n return value.size === 0;\n\n if (ArrayBuffer.isView(value))\n return value.byteLength === 0;\n\n if (typeof value === \"object\")\n return Object.keys(value).length === 0;\n\n return false;\n}\n","/* eslint-disable complexity */\nimport type { PlainObject } from \"@type/PlainObject.js\";\n\nimport { isPlainObject } from \"./isPlainObject.js\";\n\ntype TypedArray = Int8Array | Uint8Array | Uint8ClampedArray | Int16Array | Uint16Array | Int32Array | Uint32Array | Float32Array | Float64Array;\n\n/**\n * Performs a deep comparison between two values to determine if they are\n * equivalent.\n * \n * Supports: primitives, arrays, objects, dates, regexes, maps, sets, buffers, typed arrays\n * \n * @example\n * var object = { a: { b: 2 } };\n * var other = { a: { b: 2 } };\n *\n * isEqual(object, other);\n * // => true\n *\n * object === other;\n * // => false\n * @param a The value to compare.\n * @param b The other value to compare.\n * @returns Returns `true` if the values are equivalent, else `false`.\n */\n\nexport function isEqual(a: unknown, b: unknown): boolean {\n if (Object.is(a, b)) return true;\n \n if (typeof a !== typeof b) return false;\n\n if (Array.isArray(a) && Array.isArray(b))\n return isSameArray(a, b);\n\n if (a instanceof Date && b instanceof Date)\n return a.getTime() === b.getTime();\n\n if (a instanceof RegExp && b instanceof RegExp)\n return a.toString() === b.toString();\n\n if (isPlainObject(a) && isPlainObject(b))\n return isSameObject(a, b);\n\n if (a instanceof ArrayBuffer && b instanceof ArrayBuffer)\n return dataViewsAreEqual(new DataView(a), new DataView(b));\n\n if (a instanceof DataView && b instanceof DataView)\n return dataViewsAreEqual(a, b);\n\n if (isTypedArray(a) && isTypedArray(b)) {\n if (a.byteLength !== b.byteLength) return false;\n return isSameArray(a, b);\n }\n\n return false;\n}\n\nfunction isSameObject(a: PlainObject, b: PlainObject) {\n // check if the objects have the same keys\n const keys1 = Object.keys(a);\n const keys2 = Object.keys(b);\n if (!isEqual(keys1, keys2)) return false;\n\n // check if the values of each key in the objects are equal\n for (const key of keys1) {\n if (!isEqual(a[key], b[key])) return false;\n }\n\n // the objects are deeply equal\n return true;\n}\n\nfunction isSameArray(a: unknown[] | TypedArray, b: unknown[] | TypedArray) {\n if (a.length !== b.length) return false;\n return a.every((element, index) => isEqual(element, b[index]));\n}\n\nfunction dataViewsAreEqual(a: DataView, b: DataView) {\n if (a.byteLength !== b.byteLength) return false;\n for (let offset = 0; offset < a.byteLength; offset++) {\n if (a.getUint8(offset) !== b.getUint8(offset)) return false;\n }\n return true;\n}\n\nfunction isTypedArray(value: unknown): value is TypedArray {\n return ArrayBuffer.isView(value) && !(value instanceof DataView);\n}","/**\n * Checks if given string is a valid URL\n *\n * @example\n * isUrl('https://google.com')\n * // => true\n * isUrl('google.com')\n * // => false\n * @param str The string to check.\n * @returns Returns `true` if given string is a valid URL, else `false`.\n */\n\nexport function isUrl(str: string): boolean {\n try {\n new URL(str);\n return true;\n } catch {\n return false;\n }\n}"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;A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B,MAAI,aAAa,eAAe,aAAa;AACzC,WAAO,kBAAkB,IAAI,SAAS,CAAC,GAAG,IAAI,SAAS,CAAC,CAAC;AAE7D,MAAI,aAAa,YAAY,aAAa;AACtC,WAAO,kBAAkB,GAAG,CAAC;AAEjC,MAAI,aAAa,CAAC,KAAK,aAAa,CAAC,GAAG;AACpC,QAAI,EAAE,eAAe,EAAE;AAAY,aAAO;AAC1C,WAAO,YAAY,GAAG,CAAC;AAAA,EAC3B;AAEA,SAAO;AACX;AAEA,SAAS,aAAa,GAAgB,GAAgB;AAElD,QAAM,QAAQ,OAAO,KAAK,CAAC;AAC3B,QAAM,QAAQ,OAAO,KAAK,CAAC;AAC3B,MAAI,CAAC,QAAQ,OAAO,KAAK;AAAG,WAAO;AAGnC,aAAW,OAAO,OAAO;AACrB,QAAI,CAAC,QAAQ,EAAE,GAAG,GAAG,EAAE,GAAG,CAAC;AAAG,aAAO;AAAA,EACzC;AAGA,SAAO;AACX;AAEA,SAAS,YAAY,GAA2B,GAA2B;AACvE,MAAI,EAAE,WAAW,EAAE;AAAQ,WAAO;AAClC,SAAO,EAAE,MAAM,CAAC,SAAS,UAAU,QAAQ,SAAS,EAAE,KAAK,CAAC,CAAC;AACjE;AAEA,SAAS,kBAAkB,GAAa,GAAa;AACjD,MAAI,EAAE,eAAe,EAAE;AAAY,WAAO;AAC1C,WAAS,SAAS,GAAG,SAAS,EAAE,YAAY,UAAU;AAClD,QAAI,EAAE,SAAS,MAAM,MAAM,EAAE,SAAS,MAAM;AAAG,aAAO;AAAA,EAC1D;AACA,SAAO;AACX;AAEA,SAAS,aAAa,OAAqC;AACvD,SAAO,YAAY,OAAO,KAAK,KAAK,EAAE,iBAAiB;AAC3D;;;AC5EO,SAAS,MAAM,KAAsB;AACxC,MAAI;AACA,QAAI,IAAI,GAAG;AACX,WAAO;AAAA,EACX,QAAE;AACE,WAAO;AAAA,EACX;AACJ;","names":["difference","intersection","range","range","randomFloat","count","count","retries","timeout","camelCase","kebabCase","pascalCase","snakeCase","titleCase"]}
|
|
1
|
+
{"version":3,"sources":["../src/index.ts","../src/array/chunk.ts","../src/array/count.ts","../src/helpers/fastArrayFlat.ts","../src/array/difference.ts","../src/array/dropRightWhile.ts","../src/array/dropWhile.ts","../src/array/group.ts","../src/array/unique.ts","../src/array/intersection.ts","../src/array/move.ts","../src/array/range.ts","../src/array/shuffle.ts","../src/array/sort.ts","../src/array/takeRightWhile.ts","../src/array/takeWhile.ts","../src/crypto/hash.ts","../src/crypto/randomInt.ts","../src/crypto/randomElem.ts","../src/crypto/randomFloat.ts","../src/crypto/randomString.ts","../src/decorator/toDecorator.ts","../src/function/debounce.ts","../src/decorator/decDebounce.ts","../src/function/maxCalls.ts","../src/decorator/decMaxCalls.ts","../src/function/memoize.ts","../src/decorator/decMemoize.ts","../src/function/minCalls.ts","../src/decorator/decMinCalls.ts","../src/function/throttle.ts","../src/decorator/decThrottle.ts","../src/function/times.ts","../src/number/sum.ts","../src/number/average.ts","../src/number/median.ts","../src/number/round.ts","../src/validate/isPlainObject.ts","../src/object/flatKeys.ts","../src/object/merge.ts","../src/object/pick.ts","../src/object/omit.ts","../src/object/set.ts","../src/promise/queue.ts","../src/promise/races.ts","../src/promise/sleep.ts","../src/promise/retry.ts","../src/promise/timeout.ts","../src/promise/tryCatch.ts","../src/string/splitWords.ts","../src/string/deburr.ts","../src/string/camelCase.ts","../src/string/capitalize.ts","../src/string/escapeHtml.ts","../src/string/escapeRegExp.ts","../src/string/kebabCase.ts","../src/string/pascalCase.ts","../src/string/replaceLast.ts","../src/string/snakeCase.ts","../src/string/titleCase.ts","../src/string/trim.ts","../src/string/trimEnd.ts","../src/string/trimStart.ts","../src/string/unescapeHtml.ts","../src/validate/isEmpty.ts","../src/validate/isEqual.ts","../src/validate/isUrl.ts"],"sourcesContent":["export * from \"./array\";\nexport * from \"./crypto\";\nexport * from \"./decorator\";\nexport * from \"./function\";\nexport * from \"./number\";\nexport * from \"./object\";\nexport * from \"./promise\";\nexport * from \"./string\";\nexport * from \"./type\";\nexport * from \"./validate\";\n","/**\n * Creates an array of elements split into groups the length of size. If array can't be split evenly, the final chunk will be the remaining elements.\n *\n * @example\n * chunk(['a', 'b', 'c', 'd'], 2)\n * // => [['a', 'b'], ['c', 'd']]\n *\n * chunk(['a', 'b', 'c', 'd'], 3)\n * // => [['a', 'b', 'c'], ['d']]\n * @param chunkSize The length of each chunk\n * @param array The array to chunk\n * @template TElem The type of the array elements\n * @returns Returns the new array of chunks\n */\n\nexport function chunk<TElem>(array: readonly TElem[], chunkSize: number): TElem[][] {\n const intSize = Math.trunc(chunkSize);\n\n if (array.length === 0 || intSize < 1)\n return [];\n \n let index = 0;\n let resultIndex = 0;\n const result = new Array(Math.ceil(array.length / intSize)) as TElem[][];\n\n while (index < array.length) {\n result[resultIndex++] = array.slice(index, (index += intSize));\n }\n\n return result;\n}","/**\n * Creates an object with counts of occurrences of items in the array.\n *\n * @example\n * const users = [\n * { 'user': 'barney', 'active': true, age: 36 },\n * { 'user': 'betty', 'active': false, age: 36 },\n * { 'user': 'fred', 'active': true, age: 40 }\n * ]\n *\n * count(users, value => value.active ? 'active' : 'inactive');\n * // => { 'active': 2, 'inactive': 1 }\n *\n * count(users, value => value.age);\n * // => { 36: 2, 40: 1 }\n *\n * @param criteria The criteria to count by\n * @param array The array or record to iterate over\n * @template TElem The type of the array elements\n * @returns Returns the composed aggregate object\n */\n\nexport function count<TElem, TKey extends PropertyKey>(array: readonly TElem[], criteria: (value: TElem) => TKey): Record<TKey, number> {\n const result = {} as Record<TKey, number>;\n for (const value of array) {\n const key = criteria(value);\n\n // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition\n result[key] = (result[key] ?? 0) + 1;\n }\n return result;\n}","// native array.flat is much slower than this - node 19\nexport function fastArrayFlat<TElem>(arrays: (readonly TElem[])[]): readonly TElem[] {\n let result = arrays.shift() ?? [];\n\n for (const array of arrays) {\n result = [...result, ...array];\n }\n\n return result;\n}","import type { CompareFunction } from \"@helpers/ArrayTypeUtils.js\";\nimport type { ArrayMinLength } from \"@type/ArrayMinLength.js\";\n\nimport { fastArrayFlat } from \"@helpers/fastArrayFlat.js\";\n\n/**\n * Create a new array with values from the first array that are not present in the other arrays.\n * \n * Optionally, use a compare function to determine the comparison of elements (default is `===`).\n * \n * @example\n * difference([2, 1], [2, 3], [6])\n * // => [1]\n *\n * // ---- Custom compare function ----\n * const compareByFloor = (a, b) => Math.floor(a) === Math.floor(b);\n * difference([1.2, 3.1], [1.3, 2.4], compareByFloor)\n * // => [3.1]\n *\n * // ---- Only compare by id ----\n * const arr1 = [{ id: 1, name: 'Yeet' }, { id: 3, name: 'John' }];\n * const arr2 = [{ id: 3, name: 'Carl' }, { id: 4, name: 'Max' }];\n *\n * difference(arr1, arr2, (a, b) => a.id === b.id)\n * // => [{ id: 1, name: 'Yeet' }]\n * @param arraysOrCompareFn Two or more arrays with an optional compare function at the end\n * @template TElem The type of the array elements\n * @template TArrays The type of the arrays provided\n * @returns Returns the new array of filtered values\n */\n\nexport function difference<TElem>(...arraysOrCompareFn: ArrayMinLength<TElem[], 2>): TElem[];\nexport function difference<TArrays extends ArrayMinLength<unknown[], 2>>(...arraysOrCompareFn: [...TArrays, CompareFunction<TArrays>]): TArrays[0];\nexport function difference<TArrays extends ArrayMinLength<unknown[], 2>, TElem>(...arraysOrCompareFn: ArrayMinLength<TElem[], 2> | [...TArrays, CompareFunction<TArrays>]): TArrays[0] {\n const compareFnProvided = typeof arraysOrCompareFn.at(-1) === \"function\";\n const compareFunction = compareFnProvided && arraysOrCompareFn.pop() as CompareFunction<TArrays>;\n\n const arrays = arraysOrCompareFn as TArrays;\n const firstArray = arrays.shift()!;\n const combinedRestArray = fastArrayFlat(arrays);\n\n if (!compareFunction) {\n const restSet = new Set(combinedRestArray);\n return firstArray.filter(element => !restSet.has(element));\n }\n\n const difference: TArrays[0] = [];\n for (const element of firstArray) {\n if (combinedRestArray.every(item => !compareFunction(element, item))) {\n difference.push(element);\n }\n }\n\n return difference;\n}","/**\n * Creates a slice of `array` excluding elements dropped from the end. \n * Elements are dropped until `predicate` returns falsy.\n *\n * @example\n * const users = [\n * { 'user': 'barney', 'active': false },\n * { 'user': 'fred', 'active': true },\n * { 'user': 'pebbles', 'active': true }\n * ]\n *\n * dropRightWhile(users, user => user.active)\n * // => objects for ['barney']\n * @param predicate The function invoked per iteration\n * @param array The array to query\n * @template TElem The type of the array elements\n * @returns Returns the slice of `array`\n */\n\nexport function dropRightWhile<TElem>(array: readonly TElem[], predicate: (value: TElem) => boolean) {\n let i = array.length;\n while (i > 0 && predicate(array[i - 1])) {\n i--;\n }\n return array.slice(0, i);\n}\n","/**\n * Creates a slice of `array` excluding elements dropped from the beginning. \n * Elements are dropped until `predicate` returns falsy.\n *\n * @example\n * const users = [\n * { 'user': 'barney', 'active': true },\n * { 'user': 'fred', 'active': true },\n * { 'user': 'pebbles', 'active': false }\n * ]\n *\n * dropWhile(users, user => user.active)\n * // => objects for ['pebbles']\n * @param predicate The function invoked per iteration\n * @param array The array to query\n * @template TElem The type of the array elements\n * @returns Returns the slice of `array`\n */\n\nexport function dropWhile<TElem>(array: readonly TElem[], predicate: (value: TElem) => boolean): TElem[] {\n const index = array.findIndex(x => !predicate(x));\n return array.slice(index === -1 ? array.length : index);\n}\n","/**\n * Creates an object with grouped items in the array.\n *\n * @example\n * group([6.1, 4.2, 6.3], Math.floor)\n * // => { 4: [4.2], 6: [6.1, 6.3] }\n *\n * group([6.1, 4.2, 6.3], value => value > 5 ? '>5' : '<=5')\n * // => { '<=5': [4.2], '>5': [6.1, 6.3] }\n * \n * @param collection The array or object to iterate over\n * @param getGroupKey A function that returns the group id for each item\n * @template TElem The type of the array elements\n * @returns An object with grouped items\n */\n\nexport function group<TElem, TKey extends PropertyKey>(array: readonly TElem[], getGroupKey: (elem: TElem) => TKey): Record<TKey, TElem[]> {\n const result = {} as Record<TKey, TElem[]>;\n for (const elem of array) {\n const key = getGroupKey(elem);\n // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition\n (result[key] ??= []).push(elem);\n }\n return result;\n}","/**\n * Creates unique array retaining first occurrence of elements.\n *\n * A compare function is optional (default is `===`).\n * \n * @example\n * unique([2, 1, 2])\n * // => [2, 1]\n * \n * // compare by object values\n * const users = [\n * { id: 1, name: 'john' },\n * { id: 2, name: 'john' },\n * { id: 2, name: 'john' },\n * ]\n * \n * unique(users, isEqual)\n * // => [{ id: 1, name: 'john' }, { id: 2, name: 'john' }]\n * \n * // compare by id\n * unique(users, (a, b) => a.name === b.name)\n * // => [{ id: 1, name: 'john' }]\n *\n * @param array Array to inspect\n * @param iteratee Iteratee invoked per element\n * @template TElem Type of the array elements\n * @returns A new unique array\n */\n\nexport function unique<TElem>(array: readonly TElem[], compareFn?: (a: TElem, b: TElem) => boolean): TElem[] {\n // Arrays optimized with native Set\n if (!compareFn)\n return [...new Set(array)];\n\n const uniqueArray: TElem[] = [];\n for (const value of array) {\n let isUnique = true;\n \n for (const uniqueValue of uniqueArray) {\n if (compareFn(value, uniqueValue)) {\n isUnique = false;\n break;\n }\n }\n \n if (isUnique)\n uniqueArray.push(value);\n }\n \n return uniqueArray;\n}\n","import type { CompareFunction } from \"@helpers/ArrayTypeUtils.js\";\nimport type { ArrayMinLength } from \"@type/ArrayMinLength.js\";\n\nimport { fastArrayFlat } from \"@helpers/fastArrayFlat.js\";\n\nimport { unique } from \"./unique.js\";\n\n/**\n * Create an array with unique values that are present in all arrays. \n * The order of the values is based on the first array. \n * \n * Optionally, use a compare function for element comparison (default is `===`).\n * \n * @example\n * intersection([2, 1], [2, 3], [6, 2])\n * // => [2]\n *\n * // ---- Custom compare function ----\n * const compareFn = (a, b) => Math.floor(a) === Math.floor(b);\n * \n * intersection([1.2, 1.1], [1.3, 2.4], compareFn)\n * // => [1.2]\n *\n * // ---- Only compare by id ----\n * const arr1 = [{ id: 1, name: 'Yeet' }, { id: 3, name: 'John' }];\n * const arr2 = [{ id: 3, name: 'Carl' }, { id: 4, name: 'Max' }];\n *\n * intersection(arr1, arr2, (a, b) => a.id === b.id)\n * // => [{ id: 3, name: 'John' }]\n * \n * @param arraysOrCompareFn Two or more arrays with an optional compare function at the end\n * @template TElem Type of the array elements\n * @template TArrays Type of the arrays provided\n * @returns New array of intersecting values\n */\n\nexport function intersection<TElem>(...arraysOrCompareFn: ArrayMinLength<TElem[], 2>): TElem[];\nexport function intersection<TArrays extends ArrayMinLength<unknown[], 2>>(...arraysOrCompareFn: [...TArrays, CompareFunction<TArrays>]): TArrays[0];\nexport function intersection<TArrays extends ArrayMinLength<unknown[], 2>, TElem>(...arraysOrCompareFn: ArrayMinLength<TElem[], 2> | [...TArrays, CompareFunction<TArrays>]): TArrays[0] {\n const compareFnProvided = typeof arraysOrCompareFn.at(-1) === \"function\";\n const compareFunction = compareFnProvided && arraysOrCompareFn.pop() as CompareFunction<TArrays>;\n\n const arrays = arraysOrCompareFn as TArrays;\n const firstArray = unique(arrays.shift()!);\n const combinedRestArray = fastArrayFlat(arrays);\n\n if (!compareFunction) {\n const restSet = new Set(combinedRestArray);\n return firstArray.filter(element => restSet.has(element));\n }\n \n const intersection: TArrays[0] = [];\n\n for (const element of firstArray) {\n if (combinedRestArray.some(item => compareFunction(element, item))) {\n intersection.push(element);\n }\n }\n\n return intersection;\n}\n","/**\n * Moves an element within an array.\n * \n * @example\n * ```typescript\n * move([1, 2, 3, 4, 5], 0, 2);\n * // => [2, 3, 1, 4, 5]\n * ```\n * \n * @param array The input array\n * @param fromIndex Index of the element to move\n * @param toIndex Target index for the element\n * @throws If index is out of bounds\n * @returns The modified array with the moved element\n * @template TArr Type of the array elements\n */\n\nexport function move<TArr>(array: TArr[], fromIndex: number, toIndex: number): TArr[] {\n if (fromIndex < 0 || fromIndex >= array.length)\n throw new Error(`Invalid 'fromIndex': ${fromIndex}. Must be between 0 and ${array.length - 1}.`);\n\n if (toIndex < 0 || toIndex >= array.length)\n throw new Error(`Invalid 'toIndex': ${toIndex}. Must be between 0 and ${array.length - 1}.`);\n\n if (fromIndex === toIndex)\n return array;\n\n const item = array[fromIndex];\n\n if (fromIndex < toIndex)\n for (let index = fromIndex; index < toIndex; index++)\n array[index] = array[index + 1];\n else\n for (let index = fromIndex; index > toIndex; index--)\n array[index] = array[index - 1];\n\n array[toIndex] = item;\n\n return array;\n}","/**\n * Generates iterable sequence including numbers from start to end, with step increments.\n *\n * @example\n * for (const num of range(1, 5)) {\n * console.log(num);\n * }\n * // => 1 2 3 4 5\n * \n * // Generate an array of even numbers between 0 and 10:\n * const arr = [...range(0, 10, 2)];\n * // => [0, 2, 4, 6, 8, 10]\n * \n * @param start Start number of sequence\n * @param end End number of sequence\n * @param step Step between numbers, default: 1\n * @throws If range is negative or step is 0\n * @returns Generator of numbers within the range\n */\nexport function* range(start: number, end: number, step = 1): Generator<number> {\n if (start > end)\n throw new Error(\"The start of the range must be less than or equal to the end.\");\n\n if (step <= 0)\n throw new Error(\"The step must be greater than 0.\");\n \n for (let i = start; i <= end; i += step) {\n yield i;\n }\n}","/**\n * Creates a new array of shuffled values, using the Fisher-Yates-Durstenfeld Shuffle algorithm.\n *\n * @example\n * shuffle([1, 2, 3, 4])\n * // => [4, 1, 3, 2]\n * @param array Array to shuffle\n * @template TElem The type of the array elements\n * @returns A new shuffled array\n */\n\nexport function shuffle<TElem>(array: readonly TElem[]): TElem[] {\n const shuffledArray = [...array];\n \n for (let index = shuffledArray.length - 1; index > 0; index--) {\n const randomIndex = Math.floor(Math.random() * (index + 1));\n [shuffledArray[index], shuffledArray[randomIndex]] = [shuffledArray[randomIndex], shuffledArray[index]];\n }\n \n return shuffledArray;\n}","\n/**\n * Creates new array sorted in ascending/descending order with single or multiple criteria.\n * \n * @example\n * sort([1, 2, 3, 4], { order: 'desc' })\n * // => [4, 3, 2, 1]\n * \n * // --- Sorting by multiple properties ---\n * const array = [{ a: 2, b: 1 }, { a: 1, b: 2 }, { a: 1, b: 1 }];\n * \n * sort(array,\n * { order: 'asc', by: item => item.a },\n * { order: 'desc', by: item => item.b }\n * )\n * // => [{ a: 1, b: 2 }, { a: 1, b: 1 }, { a: 2, b: 1 }]\n * \n * @param array Array to sort\n * @param criteria Criteria to sort by\n * @param criteria.order Order to sort in, either 'asc' or 'desc'\n * @param criteria.by Iteratee function to sort based on a specific property\n * @template TElem Type of the array elements\n * @returns New sorted array\n*/\nexport function sort<TElem>(array: readonly TElem[], ...criteria: { order?: \"asc\" | \"desc\", by?: (item: TElem) => number | bigint | Date | string }[]): TElem[] {\n return [...array].sort((a, b) => {\n for (const { order, by } of criteria) {\n const aValue = by ? by(a) : a;\n const bValue = by ? by(b) : b;\n if (aValue < bValue) {\n return order === \"desc\" ? 1 : -1; \n }\n if (aValue > bValue) {\n return order === \"desc\" ? -1 : 1;\n }\n }\n return 0;\n });\n}","/**\n * Creates a slice of `array` with elements taken from the end. \n * Elements are taken until `predicate` returns falsy.\n * \n * @example\n * const users = [\n * { 'user': 'barney', 'active': false },\n * { 'user': 'fred', 'active': true },\n * { 'user': 'pebbles', 'active': true }\n * ]\n *\n * takeRightWhile(users, user => user.active)\n * // => objects for ['fred', 'pebbles']\n * @param predicate The function invoked per iteration.\n * @param array The array to query.\n * @template TElem The type of the array elements.\n * @returns Returns the slice of `array`.\n */\n\nexport function takeRightWhile<TElem>(array: readonly TElem[], predicate: (elem: TElem) => boolean): TElem[] {\n const result: TElem[] = [];\n\n for (let i = array.length - 1; i >= 0; i--) {\n if (predicate(array[i])) {\n result.unshift(array[i]);\n } else {\n break;\n }\n }\n\n return result;\n}\n","/**\n * Creates a slice of `array` with elements taken from the beginning. \n * Elements are taken until `predicate` returns falsy.\n *\n * @example\n * const users = [\n * { 'user': 'barney', 'active': true },\n * { 'user': 'fred', 'active': true },\n * { 'user': 'pebbles', 'active': false }\n * ]\n *\n * takeWhile(users, user => user.active)\n * // => objects for ['barney', 'fred']\n * @param predicate The function invoked per iteration.\n * @param array The array to query.\n * @template TElem The type of the array elements.\n * @returns Returns the slice of `array`.\n */\n\nexport function takeWhile<TElem>(array: readonly TElem[], predicate: (elem: TElem) => boolean): TElem[] {\n const result: TElem[] = [];\n\n for (const element of array) {\n if (predicate(element)) {\n result.push(element);\n } else {\n break;\n }\n }\n\n return result;\n}\n","import type { Jsonifiable } from \"@type/Jsonifiable.js\";\n\ntype SupportedAlgorithms = \"SHA-256\" | \"SHA-384\" | \"SHA-512\";\n\nlet textEncoder: TextEncoder | undefined;\n\n/**\n * Generates a hash from the given data using the specified algorithm.\n *\n * It uses the Web Crypto API to generate the hash.\n * \n * *Note: If you need a secure hash use a specialized library like [crypto-js](https://www.npmjs.com/package/crypto-js) instead.*\n * \n * @example\n * // Hash a string using the default algorithm (SHA-256)\n * await hash('hello world'); \n * // => \"b94d27b9934d3e08a52e52d7da7dabfac484efe37a53...\"\n *\n * // Hash an object using the SHA-512 algorithm\n * await hash({ foo: 'bar', baz: 123 }, 'SHA-512');\n * // => \"d8f3c752c6820e580977099368083f4266b569660558...\"\n * \n * @param data The data to hash, either as a string or a JSON-serializable object.\n * @param algorithm The hashing algorithm to use. Defaults to 'SHA-256'.\n * @returns A Promise that resolves to the hexadecimal representation of the hash.\n *\n * @throws {DOMException} If the specified algorithm is not supported by the Web Crypto API.\n */\n\nexport async function hash(data: Jsonifiable, algorithm: SupportedAlgorithms = \"SHA-256\"): Promise<string> {\n textEncoder ??= new TextEncoder();\n\n const dataBuffer = typeof data === \"string\"\n ? textEncoder.encode(data) \n : textEncoder.encode(JSON.stringify(data));\n \n const hashBuffer = await crypto.subtle.digest(algorithm, dataBuffer);\n const hashArray = [...new Uint8Array(hashBuffer)];\n const hexValues = hashArray.map(b => b.toString(16).padStart(2, \"0\"));\n return hexValues.join(\"\");\n}\n","\n/**\n * Generates a random integer between two given numbers, including those numbers.\n * \n * It uses `crypto.getRandomValues` to generate the random number.\n * @example\n * randomInt(1, 10) \n * // => 5\n * \n * @param min The smallest integer that can be generated.\n * @param max The largest integer that can be generated.\n * \n * @returns A random integer between `min` and `max`, including `min` and `max`.\n */\n\nexport function randomInt(min: number, max: number): number {\n // Taken from https://stackoverflow.com/a/41452318\n if (!Number.isInteger(min) || !Number.isInteger(max))\n throw new TypeError(\"min and max must be integers\");\n\n if (min >= max) \n throw new Error(\"max must be greater than min\");\n\n const range = max - min + 1;\n const randomBytes = Math.ceil(Math.log2(range) / 8);\n const maxRandNumber = Math.pow(256, randomBytes);\n const randomBuffer = new Uint8Array(randomBytes);\n\n let randomValue: number;\n do {\n crypto.getRandomValues(randomBuffer);\n randomValue = 0;\n for (let index = 0; index < randomBytes; index++) {\n // eslint-disable-next-line no-bitwise\n randomValue = (randomValue << 8) + randomBuffer[index];\n }\n // rerun if randomValue is bigger than range\n } while (randomValue >= maxRandNumber - (maxRandNumber % range));\n\n return min + (randomValue % range);\n}\n","import { randomInt } from \"./randomInt.js\";\n\n/**\n * Gets a random element an array. A single element is returned by default. \n * Specify the `multi` parameter to get an array of multiple random elements.\n *\n * If the array is empty, `undefined` is returned. \n * If `multi` is defined it returns an empty array.\n * \n * It uses `crypto.getRandomValues` to get the random element.\n * @example\n * randomElem([1, 2, 3, 4])\n * // => 2\n *\n * randomElem([1, 2, 3, 4], 2)\n * // => [3, 1]\n * @param array The array to sample.\n * @returns Returns the random element.\n */\n\nexport function randomElem<TArr>(array: TArr[]): TArr | undefined;\nexport function randomElem<TArr>(array: TArr[], multi: number): TArr[];\nexport function randomElem<TArr>(array: TArr[], multi?: number): TArr | undefined | TArr[] {\n if (multi === undefined) {\n if (array.length === 0) return undefined;\n return getSingleElement(array);\n }\n\n if (multi && array.length === 0) return [];\n\n // Multiple samples\n const result = new Array<TArr>(multi);\n for (let i = 0; i < multi; i++) {\n result[i] = getSingleElement(array);\n }\n return result;\n}\n\nfunction getSingleElement<TArr>(array: TArr[]): TArr {\n const randomIndex = randomInt(0, array.length - 1);\n return array[randomIndex];\n}","/* eslint-disable no-bitwise */\nconst shiftLeft20Bits = 2 ** 20;\nconst shiftRight52Bits = 2 ** -52;\n\n/**\n * Generates a random float between two given numbers, including those numbers.\n * \n * It uses `crypto.getRandomValues` to generate the random number.\n * @example\n * randomFloat(1, 10) \n * // => 1.123456789\n * \n * @param min The smallest float that can be generated.\n * @param max The largest float that can be generated.\n * \n * @returns A random float between `min` and `max`, including `min` and `max`.\n */\n\nexport function randomFloat(min: number, max: number): number {\n if (min >= max) {\n throw new Error(\"max must be greater than min\");\n }\n const range = max - min;\n const randomBuffer = new Uint32Array(2);\n crypto.getRandomValues(randomBuffer);\n\n // keep all 32 bits of the the first, top 20 of the second for 52 random bits\n const mantissa = (randomBuffer[0] * shiftLeft20Bits) + (randomBuffer[1] >>> 12);\n\n // shift all 52 bits to the right of the decimal point\n const randomFloat = mantissa * shiftRight52Bits;\n return min + (randomFloat * range);\n}","import { randomInt } from \"./randomInt.js\";\n\nconst DEFAULT_CHARSET = \"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789\";\n\n/**\n * Generates a random string of the specified length.\n * The default charset is alphanumeric characters.\n * \n * It uses `crypto.getRandomValues` to generate the random string.\n * \n * @example\n * randomString(8);\n * // => \"JWw1p6rD\"\n *\n * randomString(16, 'abc');\n * // => \"cbaacbabcabccabc\"\n * @param length The length of the string to generate.\n * @param charSet The set of characters to use when generating the string. Defaults to alphanumeric characters.\n * @returns A random string of the specified length.\n */\n\nexport function randomString(length: number, charSet = DEFAULT_CHARSET): string {\n if (charSet.length <= 0) return \"\";\n\n let result = \"\";\n for (let index = 0; index < length; index++) {\n const randomIndex = randomInt(0, charSet.length - 1);\n result += charSet[randomIndex];\n }\n\n return result;\n}","import type { GenericFunction } from \"@type/GenericFunction.js\";\n\ntype Tail<T extends unknown[]> = T extends [infer _Head, ...infer Tail] ? Tail : never;\n\n/**\n * Transforms a function that takes a function as first argument into a decorator function.\n * \n * @example\n * ```typescript\n * function log(func: Function, message: string) {\n * return function (...args: unknown[]) {\n * console.log(message);\n * return func(...args);\n * };\n * }\n * \n * const logger = toDecorator(log);\n * \n * class TestClass {\n * @logger(\"Hello world!\")\n * testMethod() {\n * return 1; \n * }\n * }\n * \n * const instance = new TestClass();\n * instance.testMethod(); \n * // => Log \"Hello World\" and return 1\n * ```\n * @param func The function to transform.\n * @returns A decorator function that can be used to decorate a method.\n */\n\nexport function toDecorator<TFunc extends GenericFunction<TFunc>>(func: TFunc) {\n return function (...args: Tail<Parameters<TFunc>>) {\n return function (_target: unknown, _key: string, descriptor: PropertyDescriptor) {\n const creatorArgs = [descriptor.value, ...args] as Parameters<TFunc>;\n descriptor.value = func(...creatorArgs);\n };\n };\n}","import type { GenericFunction } from \"@type/GenericFunction.js\";\n\n/**\n * Creates a debounced version of a function. Only calling it after a specified amount of time has passed without any new calls.\n * \n * **Methods:** \n * - `cancel` will cancel the next invocation of the debounced function. \n * - `flush` will immediately invoke the debounced function and cancel any pending invocations. \n * \n * This function can be used as a decorator with {@link decDebounce}.\n * \n * @example\n * const sayHello = (name: string) => console.log(`Hello, ${name}!`);\n * const debouncedSayHello = debounce(sayHello, 200);\n * \n * debouncedSayHello(\"John\");\n * debouncedSayHello(\"Jane\");\n * // => Only the second invocation of `debouncedSayHello` is executed, after a delay of 200ms.\n * @param func The function to debounce.\n * @param wait The number of milliseconds to wait before invoking `func`.\n * @returns A debounced version of `func` with `cancel` and `flush` methods.\n */\n\nexport function debounce<TFunc extends GenericFunction<TFunc>>(func: TFunc, wait: number): TFunc & {\n cancel: () => void;\n flush: () => void;\n} {\n let timeoutId: NodeJS.Timeout | undefined;\n const debounced = function (this: unknown, ...args: Parameters<TFunc>) {\n clearTimeout(timeoutId);\n timeoutId = setTimeout(() => func.apply(this, args), wait);\n };\n\n /** Cancels the next invocation of the debounced function. */\n debounced.cancel = function () {\n clearTimeout(timeoutId);\n timeoutId = undefined;\n };\n\n /** Immediately invokes the debounced function and cancels any pending invocations. */\n debounced.flush = function (this: unknown, ...args: Parameters<TFunc>) {\n if (timeoutId) {\n clearTimeout(timeoutId);\n timeoutId = undefined;\n }\n func.apply(this, args);\n };\n\n return debounced as TFunc & { cancel: () => void; flush: () => void };\n}","import { toDecorator } from \"@decorator/toDecorator.js\";\nimport { debounce } from \"@function/debounce.js\";\n\n/**\n * Debounces the decorated function. Only calling it after a specified amount of time has passed without any new calls.\n * \n * Look at {@link debounce} for the non-decorator version.\n * \n * *Requires the [experimentalDecorators](https://www.typescriptlang.org/tsconfig#experimentalDecorators) flag to be set.*\n * \n * @example\n * ```typescript\n * class TestClass {\n * @decDebounce(100)\n * testMethod(str: string) {\n * console.log(\"Debounced:\", str);\n * }\n * }\n * \n * const instance = new TestClass();\n * instance.testMethod(\"Hello\");\n * instance.testMethod(\"World\");\n * // => Only the second invocation of `debouncedSayHello` is executed, after a delay of 1000ms.\n * ```\n * @param wait Milliseconds to wait before invoking the decorated function after the last invocation.\n */\n\nexport function decDebounce(wait: number) {\n return toDecorator(debounce)(wait);\n}\n","import type { GenericFunction } from \"@type/GenericFunction.js\";\n\n/**\n * Creates a function that invokes the given function as long as it's called `<= n` times.\n * \n * Subsequent calls to the created function return the result of the last `func` invocation.\n *\n * This function can be used as a decorator with {@link decMaxCalls}.\n * @example\n * let count = 0;\n * const addCount = () => ++count;\n *\n * // Allow addCount to be invoked twice.\n * const limitAddCount = maxCalls(addCount, 2)\n *\n * limitAddCount() // => 1\n * limitAddCount() // => 2\n * limitAddCount() // => 2\n * // => `limitAddCount` is invoked twice and the result is cached.\n * @param n The number of calls before the cached result is returned.\n * @param func The function to restrict.\n * @returns Returns the new restricted function.\n */\n\nexport function maxCalls<TFunc extends GenericFunction<TFunc>>(func: TFunc, n: number): TFunc {\n let count = 0;\n let result: ReturnType<TFunc>;\n return function (this: unknown, ...args: Parameters<TFunc>): ReturnType<TFunc> {\n if (count < n) {\n count += 1;\n result = func.apply(this, args);\n }\n return result;\n } as TFunc;\n}\n","import { toDecorator } from \"@decorator/toDecorator.js\";\nimport { maxCalls } from \"@function/maxCalls.js\";\n\n/**\n * Only invokes the decorated function as long as it's called `<= n` times. \n * Subsequent calls to the decorated function return the result of the last invocation.\n * \n * Look at {@link maxCalls} for the non-decorator version.\n * \n * *Requires the [experimentalDecorators](https://www.typescriptlang.org/tsconfig#experimentalDecorators) flag to be set.*\n * \n * @example\n * ```typescript\n * class TestClass {\n * private count = 0;\n * @decMaxCalls(2)\n * testMethod() {\n * return ++this.count;\n * }\n * }\n * const instance = new TestClass();\n * instance.testMethod(); // => 1 \n * instance.testMethod(); // => 2\n * instance.testMethod(); // => 2\n * ```\n * @param n The number of calls before the cached result is returned.\n */\n\nexport function decMaxCalls(n: number) {\n return toDecorator(maxCalls)(n);\n}","import type { GenericFunction } from \"@type/GenericFunction.js\";\n\nconst defaultResolver = (...args: unknown[]) => JSON.stringify(args);\n\n/**\n * Creates a function that memoizes the result of a given function.\n * \n * The cache key is determined by the `resolver` or by the arguments from the function call.\n *\n * **Options:**\n * - `resolver` A function that determines the cache key based on the arguments provided.\n * - `ttl` the time to live for the cache entries in milliseconds.\n * \n * **Properties:**\n * - `cache` The cache is an instance of `Map` and can be used to clear or inspect the cache. \n * It can be replaced by a custom cache that matches the `Map` interface.\n * \n * \n * This function can be used as a decorator with {@link decMemoize}.\n * \n * @example\n * ```typescript\n * function fibonacci(n: number) {\n * if (n <= 1) return n;\n * return fibonacci(n - 1) + fibonacci(n - 2);\n * }\n *\n * const memoizedFib = memoize(fibonacci, { ttl: 1000 })\n * \n * memoizedFib(40) // => 102334155\n * memoizedFib(40) // => 102334155 (cache hit)\n * setTimeout(() => memoizedFib(40), 1000) // => 102334155 (cache miss)\n * \n * // Cached values are exposed as the `cache` property.\n * memoizedFib.cache.get(\"40\") // => [value, timestamp]\n * memoizedFib.cache.set(\"40\", [1234, Date.now()])\n * memoizedFib.cache.clear()\n * \n * // This is the default way to create cache keys.\n * const defaultResolver = (...args: unknown[]) => JSON.stringify(args)\n * ```\n * @param func The function to have its output memoized.\n * @param options The options object with optional `resolver` and `ttl` parameters.\n * @param options.resolver - A function that determines the cache key for storing the result based on the arguments provided.\n * @param options.ttl - The time to live for the cache in milliseconds.\n * @template TFunc The type of the function to memoize.\n * @template Cache The type of the cache storage.\n * @returns Returns the new memoized function.\n */\n\nexport function memoize<TFunc extends GenericFunction<TFunc>, Cache extends Map<string, [ReturnType<TFunc>, number]>>(\n func: TFunc, options: { resolver?: (...args: Parameters<TFunc>) => string, ttl?: number; } = {}\n): TFunc & { cache: Cache } {\n const resolver = options.resolver ?? defaultResolver;\n const ttl = options.ttl;\n const cache = new Map() as Cache;\n\n const memoizedFunc = function (this: unknown, ...args: Parameters<TFunc>): ReturnType<TFunc> {\n const key = resolver(...args);\n if (cache.has(key)) {\n const [cacheResult, cacheTime] = cache.get(key)!;\n if (ttl === undefined || (Date.now() - cacheTime < ttl)) {\n return cacheResult;\n }\n }\n const result = func.apply(this, args);\n cache.set(key, [result, Date.now()]);\n return result;\n };\n\n memoizedFunc.cache = cache;\n return memoizedFunc as TFunc & { cache: Cache };\n} ","import { toDecorator } from \"@decorator/toDecorator.js\";\nimport { memoize } from \"@function/memoize.js\";\n\n/**\n * Memoizes the decorated function. \n * The cache key is either determined by the provided resolver or by the arguments used in the memoized function.\n * \n * **Options:**\n * - `resolver` A function that determines the cache key for storing the result based on the arguments provided.\n * - `ttl` sets the time to live for the cache in milliseconds. After `ttl` milliseconds, the next call to the memoized function will result in a cache miss.\n * \n * Look at {@link memoize} for the non-decorator version.\n * \n * *Requires the [experimentalDecorators](https://www.typescriptlang.org/tsconfig#experimentalDecorators) flag to be set.*\n * \n * @example\n * ```typescript\n * class TestClass {\n * @decMemoize({ ttl: 1000 })\n * testMethod(a: number, b: number) {\n * return a + b;\n * }\n * }\n * const instance = new TestClass();\n * instance.testMethod(1, 2); // => 3\n * instance.testMethod(1, 2); // => 3 (cached)\n * \n * // After 1 second:\n * instance.testMethod(1, 2); // => 3 (cache miss)\n * ```\n * @param options The options object.\n * @param options.resolver - A function that determines the cache key for storing the result based on the arguments provided.\n * @param options.ttl - The time to live for the cache in milliseconds.\n */\n\nexport function decMemoize(options: Parameters<typeof memoize>[1] = {}) {\n return toDecorator(memoize)(options);\n}","import type { GenericFunction } from \"@type/GenericFunction.js\";\n\n/**\n * Creates a function that invokes the given function once it's called more than `n` times. \n * Returns undefined until the minimum call count is reached.\n * \n * This function can be used as a decorator with {@link decMinCalls}.\n * @example\n * const caution = () => console.log(\"Caution!\");\n * const limitedCaution = minCalls(caution, 2);\n *\n * limitedCaution()\n * limitedCaution()\n * limitedCaution()\n * // => `caution` is invoked on the third call.\n * @param n The number of calls before the given function is invoked.\n * @param func The function to restrict.\n * @returns Returns the new restricted function.\n */\n\nexport function minCalls<TFunc extends GenericFunction<TFunc>>(func: TFunc, n: number) {\n let count = 1;\n return function (this: unknown, ...args: Parameters<TFunc>): ReturnType<TFunc> | undefined {\n if (count > n) {\n return func.apply(this, args);\n }\n count += 1;\n };\n}","import { toDecorator } from \"@decorator/toDecorator.js\";\nimport { minCalls } from \"@function/minCalls.js\";\n\n/** \n * Only invokes the decorated function after it's called more than `n` times.\n * \n * Look at {@link minCalls} for the non-decorator version.\n * \n * *Requires the [experimentalDecorators](https://www.typescriptlang.org/tsconfig#experimentalDecorators) flag to be set.*\n * @example\n * ```typescript\n * class TestClass {\n * @decMinCalls(2)\n * testMethod() {\n * return 1;\n * }\n * }\n * const instance = new TestClass();\n * instance.testMethod(); // => undefined\n * instance.testMethod(); // => undefined\n * instance.testMethod(); // => 1\n * ```\n * @param n The number of calls before the decorated function is invoked.\n */\n\nexport function decMinCalls(n: number) {\n return toDecorator(minCalls)(n);\n}","import type { GenericFunction } from \"@type/GenericFunction.js\";\n\n/**\n * Generates a function that invokes the given function at most once per every `wait` milliseconds.\n * \n * This function can be used as a decorator with {@link decThrottle}.\n * @example\n * const throttled = throttle(() => console.log(\"Throttled!\"), 1000);\n * \n * throttled();\n * throttled();\n * // => \"Throttled!\" is logged once per second.\n * @param func The function to throttle.\n * @param wait The number of milliseconds to throttle invocations to.\n * @returns Returns the new throttled function.\n */\n\nexport function throttle<TFunc extends GenericFunction<TFunc>>(func: TFunc, wait: number): TFunc {\n let inThrottle = false;\n return function (this: unknown, ...args: Parameters<TFunc>) {\n if (!inThrottle) {\n func.apply(this, args);\n inThrottle = true;\n setTimeout(() => (inThrottle = false), wait);\n }\n } as TFunc;\n}\n \n","import { toDecorator } from \"@decorator/toDecorator.js\";\nimport { throttle } from \"@function/throttle.js\";\n\n/**\n * The decorated function is invoked at most once per every `wait` milliseconds.\n * \n * Look at {@link throttle} for the non-decorator version.\n * \n * *Requires the [experimentalDecorators](https://www.typescriptlang.org/tsconfig#experimentalDecorators) flag to be set.*\n * \n * @example\n * ```typescript\n * class TestClass {\n * @decThrottle(1000)\n * testMethod() {\n * console.log(\"Throttled!\");\n * }\n * }\n * \n * const instance = new TestClass();\n * instance.testMethod(); // => \"Throttled!\" is logged once per second.\n * instance.testMethod(); // nothing happens\n * ```\n * @param wait The number of milliseconds to wait between invocations.\n */\n\nexport function decThrottle(wait: number) {\n return toDecorator(throttle)(wait);\n}","/**\n * Invokes a function `n` times, returning an array of the results of\n * each invocation.\n * \n * @example\n * times(index => console.log(\"Run\", index), 3)\n * // => \"Run 0\" | \"Run 1\" | \"Run 2\"\n * times(Math.random, 3)\n * // => [0.123, 0.456, 0.789]\n * times(() => 0, 4)\n * // => [0, 0, 0, 0]\n * @param n The number of times to invoke `func`.\n * @param func The function invoked per iteration.\n * @returns Returns an array of results.\n */\n\nexport function times<TInput>(func: (index: number) => TInput, n: number): TInput[] {\n const result: TInput[] = [];\n for (let i = 0; i < n; i++) {\n result.push(func(i));\n }\n return result;\n}","\nimport type { Tuples, Call } from \"hotscript\";\n\n/**\n * Calculates the sum of an array of numbers.\n * \n * Returns `NaN` if the input array is empty.\n * @example\n * sum([1, 2, 3, 4, 5]) // => 15\n * \n * @param numbers The input array of numbers\n * @returns The sum of the input array \n */\n\nexport function sum(numbers: number[]): number;\nexport function sum<TNum extends readonly number[]>(numbers: TNum): Call<Tuples.Sum, TNum>;\nexport function sum<TNum extends readonly number[]>(numbers: TNum): Call<Tuples.Sum, TNum> | number {\n if (numbers.length === 0)\n return NaN;\n return numbers.reduce((total, current) => total + current, 0);\n}","import { sum } from \"@number/sum.js\";\n\n/**\n * Calculates the average of an array of numbers\n * \n * Returns `NaN` if the input array is empty.\n * @example\n * average([1, 2, 3, 4, 5]) // => 3\n * \n * @param numbers The input array of numbers\n * @returns The average of the input array, or NaN if the input array is empty\n */\n\nexport function average(numbers: readonly number[]): number {\n if (numbers.length === 0)\n return NaN;\n return sum(numbers) / numbers.length;\n}","/**\n * Calculates the median of an array of numbers\n * \n * Returns `NaN` if the input array is empty.\n * @example\n * median([1, 2, 3, 4, 5]) // => 3\n * median([1, 2, 3, 4, 5, 6]) // => 3.5\n * \n * @param numbers The input array of numbers\n * @returns The median of the input array\n */\n\nexport function median(numbers: readonly number[]): number {\n if (numbers.length === 0)\n return NaN;\n const sortedArray = [...numbers].sort((a, b) => a - b);\n const mid = Math.floor(sortedArray.length / 2);\n return sortedArray.length % 2 === 0 ? ((sortedArray[mid - 1] + sortedArray[mid]) / 2) : sortedArray[mid];\n}","/**\n * Rounds a number to the given precision.\n *\n * @example\n * round(1.23456, 2); // => 1.23\n * round(1.235, 1); // => 1.2\n * round(1234.56); // => 1234.56\n * \n * @param number The number to be rounded.\n * @param precision The number of decimal places to round to. Defaults to 2.\n * @returns The rounded number.\n */\n\nexport function round(number: number, precision = 2): number {\n const factor = Math.pow(10, precision);\n return Math.round((number + Number.EPSILON) * factor) / factor;\n}","import type { PlainObject } from \"@type/PlainObject.js\";\n\n/**\n * Checks if the value is a plain object.\n * \n * @example\n * isPlainObject({}) // => true\n * isPlainObject({ a: 1 }) // => true\n * isPlainObject(null) // => false\n * isPlainObject('1') // => false\n * isPlainObject([]) // => false\n * isPlainObject(new Function()) // => false\n * isPlainObject(new Date()) // => false\n * @param value The value to check\n * @returns Boolean indicating if the value is a plain object\n */\n\nexport function isPlainObject(value: unknown): value is PlainObject {\n return value?.constructor === Object;\n}","import type { PlainObject } from \"@type/PlainObject.js\";\nimport type { Call, Objects } from \"hotscript\";\n\nimport { isPlainObject } from \"@validate/isPlainObject.js\";\n\ntype StringIfNever<Type> = [Type] extends [never] ? string : Type;\ntype Paths<TObj> = StringIfNever<Call<Objects.AllPaths, TObj>>;\n\n/**\n * Flattens an object into a single level object.\n * \n * @example\n * const obj = { a: { b: 2, c: [{ d: 3 }, { d: 4 }] } };\n * flatKeys(obj);\n * // => { 'a.b': 2, 'a.c[0].d': 3, 'a.c[1].d': 4 }\n * \n * @param obj The object to flatten.\n * @template TObj The type of the object to flatten.\n * @returns A new object with flattened keys.\n */\n\nexport function flatKeys<TObj extends PlainObject>(obj: TObj): Record<Paths<TObj>, unknown> {\n const flatObject: Record<string, unknown> = {};\n \n for (const [key, value] of Object.entries(obj)) {\n addToResult(key, value, flatObject);\n }\n \n return flatObject;\n}\n\nfunction addToResult(prefix: string, value: unknown, flatObject: Record<string, unknown>) {\n if (isPlainObject(value)) {\n const flatObj = flatKeys(value);\n for (const [flatKey, flatValue] of Object.entries(flatObj)) {\n flatObject[`${prefix}.${flatKey}`] = flatValue;\n }\n } else if (Array.isArray(value)) {\n for (const [index, element] of value.entries()) {\n addToResult(`${prefix}[${index}]`, element, flatObject);\n }\n\n } else {\n flatObject[prefix] = value;\n }\n}","import type { ArrayMinLength } from \"@type/ArrayMinLength.js\";\nimport type { PlainObject } from \"@type/PlainObject.js\";\n\nimport { isPlainObject } from \"@validate/isPlainObject.js\";\n\n/**\n * This function combines two or more objects into a single new object. Arrays and other types are overwritten.\n * \n * @example\n * // ---- Nested objects are merged ----\n * merge({ a: 1 }, { b: 2 }, { c: 3, d: { e: 4 } }) \n * // => { a: 1, b: 2, c: 3, d: { e: 4 } }\n *\n * // ---- Other types are overwritten ----\n * merge({ a: [1, 2] }, { a: [3, 4] })\n * // => { a: [3, 4] }\n * \n * merge({ a: 1 }, { a: \"Yes\" })\n * // => { a: \"Yes\" }\n * @param target The target object\n * @param sources The source objects\n * @template TTarget The type of the target object\n * @template TSources The type of the source objects\n * @returns A new merged object\n */\n\nexport function merge<TTarget extends PlainObject, TSources extends ArrayMinLength<PlainObject, 1>>(target: TTarget, ...sources: TSources): MergeDeepObjects<[TTarget, ...TSources]> {\n const targetCopy = { ...target };\n for (const source of sources) {\n for (const [key, value] of Object.entries(source)) {\n (targetCopy as PlainObject)[key] = isPlainObject(value) && isPlainObject(targetCopy[key]) \n ? merge(targetCopy[key] as PlainObject, value) \n : value;\n }\n }\n return targetCopy as MergeDeepObjects<[TTarget, ...TSources]>; \n}\n\ntype OptionalPropertyNames<T> =\n { [K in keyof T]-?: (PlainObject extends { [P in K]: T[K] } ? K : never) }[keyof T];\n\ntype SpreadProperties<L, R, K extends keyof L & keyof R> =\n { [P in K]: L[P] | Exclude<R[P], undefined> };\n\ntype Id<T> = T extends infer U ? { [K in keyof U]: U[K] } : never;\n\ntype SpreadTwo<L, R> = Id<\n& Pick<L, Exclude<keyof L, keyof R>>\n& Pick<R, Exclude<keyof R, OptionalPropertyNames<R>>>\n& Pick<R, Exclude<OptionalPropertyNames<R>, keyof L>>\n& SpreadProperties<L, R, OptionalPropertyNames<R> & keyof L>\n>;\n\ntype MergeDeepObjects<A extends readonly [...unknown[]]> = A extends [infer L, ...infer R] ?\n SpreadTwo<L, MergeDeepObjects<R>> : unknown;\n","import type { PlainObject } from \"@type/PlainObject.js\";\n\n/**\n * Creates an object composed of the picked `object` properties.\n *\n * @example\n * const object = { 'a': 1, 'b': '2', 'c': 3 }\n *\n * pick(object, ['a', 'c'])\n * // => { 'a': 1, 'c': 3 }\n * @param object The source object.\n * @param keysToPick The property paths to pick.\n * @template TObj The type of the object.\n * @returns Returns the new object.\n */\n\nexport function pick<TObj extends PlainObject, Key extends keyof TObj>(object: TObj, keysToPick: Key[]): Pick<TObj, Key> {\n const result = {} as Pick<TObj, Key>;\n for (const key of keysToPick) {\n result[key] = object[key];\n }\n return result;\n}\n","import type { PlainObject } from \"@type/PlainObject.js\";\n\nimport { pick } from \"./pick.js\";\n\n/**\n * Omit specified keys from an object\n *\n * @example\n * const obj = {a: 1, b: 2, c: 3};\n * omit(obj, ['a', 'b']);\n * // => {c: 3}\n *\n * @param object The object to filter\n * @param keysToOmit The keys to exclude from the returned object\n * @template TObj The type of the object\n * @returns - An object without the specified keys\n */\n\nexport function omit<TObj extends PlainObject, Key extends keyof TObj>(object: TObj, keysToOmit: Key[]): Omit<TObj, Key> {\n const keys = Object.keys(object);\n const filteredKeys = keys.filter(key => !keysToOmit.includes(key as Key)) as Exclude<keyof TObj, Key>[];\n\n return pick(object, filteredKeys);\n}","import type { PlainObject } from \"@type/PlainObject.js\";\nimport type { Call, Objects } from \"hotscript\";\n\nimport { isPlainObject } from \"@validate/isPlainObject.js\";\n\nconst validPathRegex = /^[^.[\\]]+(?:\\.[^.[\\]]+)*(?:\\[\\d+])*(?:\\.[^.[\\]]+(?:\\[\\d+])*)*$/;\nconst pathSplitRegex = /\\.|(?=\\[)/g;\nconst matchBracketsRegex = /[[\\]]/g;\n\n// eslint-disable-next-line @typescript-eslint/ban-types\ntype Paths<TObj> = Call<Objects.AllPaths, TObj> | string & {};\ntype UpdateObj<TObj extends PlainObject, TPath extends string, TVal> = Call<Objects.Update<TPath, TVal>, TObj>;\n\n/**\n * Sets the value at path of object. If a portion of path doesn’t exist, it’s created.\n * \n * @example\n * const obj = { a: { b: 2 } };\n * set(obj, 'a.c', 1);\n * // => { a: { b: 2, c: 1 } }\n * \n * // `[number]` can be used to access array elements\n * set(obj, 'a.c[0]', 'hello');\n * // => { a: { b: 2, c: ['hello'] } }\n * \n * // numbers with dots are treated as keys\n * set(obj, 'a.c.0.d', 'world');\n * // => { a: { b: 2, c: { 0: { d: 'world' } } }\n * \n * // supports numbers in keys\n * set(obj, 'a.e0.a', 1);\n * // => { a: { e0: { a: 1 } } }\n * \n * @param obj The object to modify.\n * @param path The path of the property to set.\n * @param value The value to set.\n * @template TObj The type of the object.\n * @template TPath The type of the object path.\n * @template TVal The type of the value to set.\n * @returns The modified object.\n */\n\nexport function set<TObj extends PlainObject, TPath extends Paths<TObj>, TVal>(obj: TObj, path: TPath, value: TVal): UpdateObj<TObj, TPath, TVal> {\n if (!validPathRegex.test(path))\n throw new Error(\"Invalid path, look at the examples for the correct format.\");\n\n const pathParts = (path as string).split(pathSplitRegex);\n let currentObj: PlainObject = obj;\n for (let index = 0; index < pathParts.length; index++) {\n const key = pathParts[index].replace(matchBracketsRegex, \"\");\n\n if (index === pathParts.length - 1) {\n currentObj[key] = value;\n break;\n }\n\n const nextElemIn = pathParts[index + 1].startsWith(\"[\") ? \"array\" : \"object\";\n if (currentObj[key] === undefined) {\n currentObj[key] = nextElemIn === \"array\" ? [] : {};\n } else if (nextElemIn === \"array\" && !Array.isArray(currentObj[key])) {\n currentObj[key] = [];\n } else if (nextElemIn === \"object\" && !isPlainObject(currentObj[key])) {\n currentObj[key] = {};\n }\n currentObj = currentObj[key] as PlainObject;\n }\n\n return obj as UpdateObj<TObj, TPath, TVal>;\n}","/**\n * A class for managing a queue of async functions that runs a set number concurrently. \n * If for example you have 10 async functions and you want to run 3 at a time, you can use this class.\n * \n * If the queue is paused, the queue will not run any more async functions until it is resumed.\n * \n * **Methods:**\n * - `add` - adds a async function or array of functions to the queue. Returns a promise that resolves when the added function(s) finish.\n * - `clear` - clears the queue.\n * - `pause` - pauses the queue.\n * - `resume` - resumes the queue. \n * - `getQueue` - returns the current queue.\n * - `isPaused` - returns whether the queue is paused.\n * \n * @example\n * // Create a queue that can run 3 tasks concurrently\n * const queue = new Queue(3);\n * \n * queue.add(() => fetch('https://example.com'));\n * \n * queue.add(async () => {\n * const response = await fetch('https://example.com');\n * return response.json();\n * });\n * \n * // Add an array of tasks to the queue and wait for them to resolve\n * await queue.add([\n * () => fetch('https://apple.com'),\n * () => fetch('https://microsoft.com')\n * ]);\n * // => [Response, Response]\n */\n\nexport class Queue {\n private running = 0;\n private maxConcurrent: number;\n private paused = false;\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n private queue: { asyncFn: () => Promise<any>, resolve: (value: any) => void, reject: (reason?: any) => void }[] = [];\n\n /**\n * @constructor\n * @param maxConcurrent The maximum number of async functions to run concurrently.\n */\n constructor(maxConcurrent: number) {\n this.maxConcurrent = maxConcurrent;\n }\n\n /**\n * Add async functions or an array of async functions to the queue.\n * \n * @param asyncFn The async function(s) to add to the queue.\n * @returns A promise that resolves when the added function(s) finishes.\n */\n add<TProm, TAsyncFn extends () => Promise<TProm>>(asyncFn: TAsyncFn): Promise<TProm>;\n add<TProm, TAsyncFn extends () => Promise<TProm>>(asyncFn: TAsyncFn[]): Promise<TProm[]>;\n add<TProm, TAsyncFn extends () => Promise<TProm>>(asyncFn: TAsyncFn | TAsyncFn[]): Promise<TProm> | Promise<TProm[]> {\n if (Array.isArray(asyncFn)) {\n const promises = asyncFn.map((fn) => this.buildWaitingPromise(fn));\n return Promise.all(promises);\n } else {\n return this.buildWaitingPromise(asyncFn);\n } \n }\n\n private buildWaitingPromise<TProm>(asyncFn: () => Promise<TProm>): Promise<TProm> {\n return new Promise((resolve, reject) => {\n this.queue.push({ asyncFn, resolve, reject });\n this.run();\n });\n } \n\n private run() {\n while (this.queue.length > 0 && this.running < this.maxConcurrent && !this.paused) {\n this.running++;\n const queueElement = this.queue.shift()!;\n void queueElement.asyncFn()\n .then((result) => {\n queueElement.resolve(result);\n }).catch((error) => {\n queueElement.reject(error);\n }).finally(() => {\n this.running--;\n this.run();\n });\n }\n }\n\n /** Removes all the tasks from the queue */\n clear() {\n for (const queueElement of this.queue) {\n queueElement.reject(new Error(\"Queue cleared\"));\n }\n this.queue = [];\n }\n\n /** Pauses the execution of the queue */\n pause() {\n this.paused = true;\n }\n\n /** Resumes the execution of the tasks in the queue */\n resume() {\n this.paused = false;\n this.run();\n }\n\n /** Return the tasks added to the queue */\n getQueue() {\n return this.queue.map((queueElement) => queueElement.asyncFn);\n }\n\n /** Returns whether the queue is paused */\n isPaused() {\n return this.paused;\n }\n\n}\n","/**\n * Similar to [Promise.race](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise/race?retiredLocale=de) \n * but allows to specify how many promises to wait for.\n *\n * @example\n * const prom1 = Promise.resolve(1);\n * const prom2 = new Promise(resolve => setTimeout(resolve, 100, 2));\n * const prom3 = Promise.resolve(3);\n * \n * const firstTwo = await races(2, prom1, prom2, prom3);\n * // => [1, 3]\n * \n * @template TRes The type of the result of the promises.\n * @param waitFor The number of promises to wait for.\n * @param promises The promises to wait for.\n * @returns A promise that resolves an array of the results of the first n promises.\n */\n\nexport function races<TRes>(waitFor: number, ...promises: Promise<TRes>[]): Promise<TRes[]> {\n return new Promise((resolve, reject) => {\n if (promises.length < waitFor)\n waitFor = promises.length;\n\n const results: TRes[] = [];\n let resolved = 0;\n for (const promise of promises) {\n promise.then((value) => {\n results.push(value);\n resolved++;\n if (resolved >= waitFor) {\n resolve(results);\n }\n }).catch((error) => {\n reject(error);\n });\n }\n });\n}","/**\n * Sleeps for the given amount of time.\n *\n * @example\n * await sleep(1000);\n * // => Waits for 1 second.\n * @param ms Amount of time to sleep in milliseconds.\n * @returns A promise that resolves after the given amount of time.\n */\nexport function sleep(ms: number) {\n return new Promise((resolve) => setTimeout(resolve, ms));\n}","/* eslint-disable no-await-in-loop */\nimport { sleep } from \"@promise/sleep.js\";\n\n/**\n * Retry a function until it succeeds or the maximum number of retries is reached.\n * \n * Default maxRetries: `5`. \n * Default backoff: `2^retries * 100ms` (100, 200, 400, 800, 1600, 3200, ...)\n *\n * @example\n * await retry(() => fetch('https://example.com'));\n * \n * // ---- Advanced example ----\n * const fetchSite = async () => {\n * const response = await fetch('https://example.com');\n * if(!response.ok)\n * throw new Error('Failed to fetch');\n * }\n * \n * const logger = (error: unknown, retry?: number) => console.log(\"Retrying\", retry, error);\n * \n * await retry(fetchSite, { maxRetries: 3, backoff: retries => retries * 1000, onRetry: logger });\n * // => Will retry 3 times with a 1 second delay between each retry.\n * // => Will log the error and retry number.\n * \n * @param func The function to retry.\n * @param options The options for the retry.\n * @param options.maxRetries The maximum number of retries. Defaults to `5`.\n * @param options.backoff The backoff function to use. Defaults to `2^retries * 100`.\n * @param options.onRetry The function to call when a retry is attempted. It will be called with the error and the attempt number.\n * @template TRes The type of the result of the function.\n * @returns A promise that resolves when the function succeeds.\n */\n\nexport async function retry<TRes>(\n func: () => Promise<TRes>, \n options?: { \n maxRetries?: number,\n backoff?: ((retries: number) => number),\n onRetry?: (error?: unknown, attempted?: number) => void\n }\n): Promise<TRes> {\n const backOffFn = options?.backoff ?? (retries => (2 ** retries) * 100);\n const maxRetries = options?.maxRetries ?? 5;\n // eslint-disable-next-line @typescript-eslint/no-empty-function\n const onRetry = options?.onRetry ?? (() => {});\n let retries = 0;\n let lastError: unknown;\n\n while (retries <= maxRetries) {\n try {\n if (retries > 0)\n onRetry(lastError, retries);\n return await func();\n } catch (error) {\n lastError = error;\n retries++;\n if (retries > maxRetries) {\n throw error;\n }\n await sleep(backOffFn(retries));\n }\n /* c8 ignore next 2 */\n }\n throw new Error(\"Retry terminated without success, this should never happen\");\n}","/**\n * Returns a new promise that will reject with an error after a specified timeout. \n *\n * @example\n * try {\n * await timeout(fetch('https://example.com'), 1000);\n * } catch (error) {\n * console.log(error.message);\n * // => 'Promise timed out after 1000ms'\n * }\n * @template TRes - The type of the resolved value.\n * @param promise The promise to wrap.\n * @param timeout The timeout in milliseconds.\n * \n * @returns A new promise that will reject with an error after the specified timeout.\n */\nexport function timeout<TRes>(promise: Promise<TRes>, timeout: number): Promise<TRes> {\n return new Promise((resolve, reject) => {\n const timeoutId = setTimeout(() => {\n reject(new Error(`Promise timed out after ${timeout}ms`));\n }, timeout);\n \n promise.then(\n (result) => {\n clearTimeout(timeoutId);\n resolve(result);\n },\n (error) => {\n clearTimeout(timeoutId);\n reject(error);\n }\n );\n });\n}","/**\n * Attempts to execute a promise and returns an array with the result or error.\n * \n * This is useful for handling errors in async functions without try/catch blocks.\n * \n * @example\n * ```typescript\n * const [data, error] = await tryCatch(fetch('https://example.com/api'));\n * if (error)\n * console.error(`Error: ${error.message}`);\n * ```\n * @param promise A Promise to be executed.\n * @returns A Promise that resolves to an array containing the result or error. \n * If the Promise executes successfully, the array contains the result and a null error. \n * If the Promise throws an error, the array contains undefined for the result and the error object.\n *\n * @template TRes The type of the result.\n */\n\nexport async function tryCatch<TRes>(promise: Promise<TRes>): Promise<[TRes, undefined] | [undefined, Error]> {\n try {\n const data = await promise;\n return [data, undefined];\n } catch (error) {\n if (error instanceof Error)\n return [undefined, error];\n\n throw error;\n }\n}","const wordsRegex = /(?:\\d*[a-z]+)|(?:[A-Z][a-z]+)|(?:\\d*[A-Z]+(?=[^a-z]|$))|\\d+/g;\n\n/**\n * Split a string into words. Can deal with camelCase, PascalCase & snake_case.\n * \n * @example\n * splitWords('camelCase')\n * // => ['camel', 'Case']\n * \n * splitWords('PascalCase')\n * // => ['Pascal', 'Case']\n * \n * splitWords('hello_world-123')\n * // => ['hello', 'world', '123']\n * \n * @param str The string to split into words.\n * @param forceFallback Force the use of the positive lookahead fallback. Only used for testing.\n * @returns An array of words.\n */\n\nexport function splitWords(str: string): string[] {\n return str.match(wordsRegex) ?? [];\n}","const accentControlRegex = /[\\u0300-\\u036F]/g;\n\n/**\n * Deburrs a string by converting\n * [Latin-1 Supplement](https://en.wikipedia.org/wiki/Latin-1_Supplement_(Unicode_block)#Character_table)\n * and [Latin Extended-A](https://en.wikipedia.org/wiki/Latin_Extended-A)\n * letters to basic Latin letters and removing\n * [combining diacritical marks](https://en.wikipedia.org/wiki/Combining_Diacritical_Marks).\n *\n * @example\n * deburr('déjà vu')\n * // => 'deja vu'\n * @param str The string to deburr.\n * @returns Returns the deburred string.\n */\n\nexport function deburr(str: string): string {\n return str.normalize(\"NFD\").replace(accentControlRegex, \"\");\n}\n","import { splitWords } from \"@string/splitWords\";\n\nimport { deburr } from \"./deburr.js\";\n\n/**\n * Converts `string` to camelCase.\n *\n * @example\n * camelCase('Foo Bar')\n * // => 'fooBar'\n * camelCase('--foo-bar--')\n * // => 'fooBar'\n * camelCase('__FOO_BAR__')\n * // => 'fooBar'\n * @param str The string to convert.\n * @returns Returns the camel cased string.\n */\n\nexport function camelCase(str: string): string {\n str = deburr(str);\n const words = splitWords(str);\n\n let camelCase = \"\";\n for (const [index, word] of words.entries()) {\n camelCase += index === 0 \n ? word.toLowerCase() \n : word.charAt(0).toUpperCase() + word.slice(1).toLowerCase();\n }\n\n return camelCase;\n}","/**\n * Converts the first character of a string to upper case and the remaining to lower case.\n *\n * @example\n * capitalize('FRED')\n * // => 'Fred'\n * @param str The string to capitalize.\n * @returns Returns the capitalized string.\n */\n\nexport function capitalize(str: string): string {\n return str.charAt(0).toUpperCase() + str.slice(1);\n}\n","const charRegex = /[\"&'<>]/g;\nconst escapeChars = new Map([\n [\"&\", \"&\"],\n [\"<\", \"<\"],\n [\">\", \">\"],\n [\"'\", \"'\"],\n ['\"', \""\"]\n]);\n\n/**\n * Converts the characters `&`, `<`, `>`, `\"` and `'` in a string to their corresponding HTML entities.\n *\n * @example\n * escapeHtml('fred, barney, & pebbles')\n * // => 'fred, barney, & pebbles'\n * @param str The string to escape.\n * @returns Returns the escaped string.\n */\n\nexport function escapeHtml(str: string): string {\n return str.replace(charRegex, char => escapeChars.get(char)!);\n}\n","const escapeCharsRegex = /[$()*+.?[\\\\\\]^{|}]/g;\n\n/**\n * Escapes the `RegExp` special characters `^`, `$`, `\\`, `.`, `*`, `+`,\n * `?`, `(`, `)`, `[`, `]`, `{`, `}`, and `|` in a string.\n *\n * @example\n * escapeRegExp('[moderndash](https://moderndash.io/)')\n * // => '\\[moderndash\\]\\(https://moderndash\\.io/\\)'\n * @param str The string to escape.\n * @returns Returns the escaped string.\n */\n\nexport function escapeRegExp(str: string): string {\n return str.replace(escapeCharsRegex, \"\\\\$&\");\n}\n","import { splitWords } from \"@string/splitWords\";\n\nimport { deburr } from \"./deburr.js\";\n\n/**\n * Converts a string to kebab-case.\n *\n * @example\n * kebabCase('Foo Bar')\n * // => 'foo-bar'\n * kebabCase('fooBar')\n * // => 'foo-bar'\n * kebabCase('__FOO_BAR__')\n * // => 'foo-bar'\n * \n * @param str The string to convert.\n * @returns Returns the kebab cased string.\n */\n\nexport function kebabCase(str: string): string {\n str = deburr(str);\n const words = splitWords(str);\n let kebabCase = \"\";\n for (const word of words) {\n kebabCase += word.toLowerCase() + \"-\";\n }\n return kebabCase.slice(0, -1);\n}\n","import { splitWords } from \"@string/splitWords\";\n\nimport { deburr } from \"./deburr.js\";\n\n\n/**\n * Converts a string to PascalCase.\n *\n * @example\n * pascalCase('Foo Bar')\n * // => 'FooBar'\n * pascalCase('fooBar')\n * // => 'FooBar'\n * pascalCase('__FOO_BAR__')\n * // => 'FooBar'\n * \n * @param str The string to convert.\n * @returns Returns the pascal cased string.\n */\n\nexport function pascalCase(str: string): string {\n str = deburr(str);\n const words = splitWords(str);\n let pascalCase = \"\";\n for (const word of words) {\n pascalCase += word.charAt(0).toUpperCase() + word.slice(1);\n }\n return pascalCase;\n}\n","/**\n * Replaces the last occurrence of a string.\n * \n * @example\n * ```typescript\n * replaceLast(\"Foo Bar Bar\", \"Bar\", \"Boo\"); \n * // => \"Foo Bar Boo\"\n * ```\n * \n * @param str The string to replace in.\n * @param searchFor The string to search for.\n * @param replaceWith The string to replace with.\n * @returns The replaced string.\n */\n\nexport function replaceLast(str: string, searchFor: string, replaceWith: string): string {\n const index = str.lastIndexOf(searchFor);\n\n if (index === -1)\n return str;\n\n return str.slice(0, index) + replaceWith + str.slice(index + searchFor.length);\n}","import { splitWords } from \"@string/splitWords\";\n\nimport { deburr } from \"./deburr.js\";\n\n/**\n * Converts a string to snake_case.\n *\n * @example\n * snakeCase('Foo Bar')\n * // => 'foo_bar'\n * snakeCase('fooBar')\n * // => 'foo_bar'\n * snakeCase('--FOO-BAR--')\n * // => 'foo_bar'\n * snakeCase('foo2bar')\n * // => 'foo_2_bar'\n * \n * @param str The string to convert.\n * @returns Returns the snake cased string.\n */\n\nexport function snakeCase(str: string): string {\n str = deburr(str);\n const words = splitWords(str);\n let snakeCase = \"\";\n for (const word of words) {\n if (snakeCase.length > 0) {\n snakeCase += \"_\";\n }\n snakeCase += word.toLowerCase();\n }\n return snakeCase;\n}\n","import { splitWords } from \"@string/splitWords\";\n\nimport { deburr } from \"./deburr.js\";\n\n/**\n * Converts a string to Title Case.\n *\n * @example\n * titleCase('--foo-bar--')\n * // => 'Foo Bar'\n * titleCase('fooBar')\n * // => 'Foo Bar'\n * titleCase('__FOO_BAR__')\n * // => 'Foo Bar'\n * titleCase('HélloWorld')\n * // => 'Hello World'\n * @param str The string to convert.\n * @returns Returns the title cased string.\n */\n\nexport function titleCase(str: string): string {\n str = deburr(str);\n const words = splitWords(str);\n let titleCase = \"\";\n for (const word of words) {\n titleCase += word.charAt(0).toUpperCase() + word.slice(1).toLowerCase() + \" \";\n }\n return titleCase.trimEnd();\n}\n","/**\n * Trim the string from the left and right by the given characters\n * \n * *Use the native [trim](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/trim) method if you want to trim whitespace.*\n * @example\n * ```ts\n * trim('$$abc$', '$') // => 'abc'\n * trim('!!abc_!', '_!') // => 'abc'\n * ```\n * @param str The string to trim\n * @param chars The characters to trim\n * @returns The trimmed string\n */\n\nexport function trim(str: string, chars: string): string {\n let startIndex = 0;\n while (startIndex < str.length && chars.includes(str[startIndex])) {\n startIndex++;\n }\n \n let endIndex = str.length - 1;\n while (endIndex >= startIndex && chars.includes(str[endIndex])) {\n endIndex--;\n }\n \n return str.slice(startIndex, endIndex + 1);\n}","/**\n * Trims the specified characters from the end of the string.\n * \n * *Use the native [trimEnd](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/trimEnd) method if you want to trim whitespace.*\n * @example\n * ```ts\n * trimEnd('abc$$$', '$') // => 'abc'\n * trimEnd('abc_!!_', '_!') // => 'abc'\n * ```\n * @param str The string to trim\n * @param chars The characters to trim\n * @returns The trimmed string\n */\n\nexport function trimEnd(str: string, chars: string): string {\n let lastIndex = str.length - 1;\n while (lastIndex >= 0 && chars.includes(str[lastIndex])) {\n lastIndex--;\n }\n return str.slice(0, lastIndex + 1);\n\n}","/**\n * Trims specified characters from the start of the string.\n * \n * *Use the native [trimStart](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/trimStart) method if you want to trim whitespace.*\n * @example\n * ```ts\n * trimStart('$$$abc', '$') // => 'abc'\n * trimStart('_!!_abc', '_!') // => 'abc'\n * ```\n * @param str The string to trim\n * @param chars The characters to trim\n * @returns The trimmed string\n */\n\nexport function trimStart(str: string, chars: string): string {\n let startIndex = 0;\n while (startIndex < str.length && chars.includes(str[startIndex])) {\n startIndex++;\n }\n return str.slice(startIndex);\n}","const htmlEntitiesRegex = /&(?:amp|lt|gt|quot|#39);/g;\nconst entityMap = new Map([\n [\"&\", \"&\"],\n [\"<\", \"<\"],\n [\">\", \">\"],\n [\""\", '\"'],\n [\"'\", \"'\"]\n]);\n\n/**\n * Converts the HTML entities `&`, `<`, `>`, `"` and `'`\n * in a string to their corresponding characters.\n *\n * @example\n * unescapeHtml('fred, barney, & pebbles')\n * // => 'fred, barney, & pebbles'\n * @param str The string to unescape.\n * @returns Returns the unescaped string.\n */\n\nexport function unescapeHtml(str: string): string {\n return str.replace(htmlEntitiesRegex, (entity: string) => entityMap.get(entity)!);\n}\n","\n/**\n * Checks if a value is empty.\n * \n * Supports: strings, arrays, objects, maps, sets, typed arrays.\n * @example\n * isEmpty(null)\n * // => true\n *\n * isEmpty({})\n * // => true\n *\n * isEmpty(\"\")\n * // => true\n *\n * isEmpty([1, 2, 3])\n * // => false\n *\n * isEmpty('abc')\n * // => false\n *\n * isEmpty({ 'a': 1 })\n * // => false\n * @param value The value to check.\n * @returns Returns `true` if `value` is empty, else `false`.\n */\n\nexport function isEmpty(value: string | object | null | undefined): boolean {\n if (value === null || value === undefined)\n return true;\n\n if (typeof value === \"string\" || Array.isArray(value))\n return value.length === 0;\n\n if (value instanceof Map || value instanceof Set)\n return value.size === 0;\n\n if (ArrayBuffer.isView(value))\n return value.byteLength === 0;\n\n if (typeof value === \"object\")\n return Object.keys(value).length === 0;\n\n return false;\n}\n","/* eslint-disable complexity */\nimport type { PlainObject } from \"@type/PlainObject.js\";\n\nimport { isPlainObject } from \"./isPlainObject.js\";\n\ntype TypedArray = Int8Array | Uint8Array | Uint8ClampedArray | Int16Array | Uint16Array | Int32Array | Uint32Array | Float32Array | Float64Array;\n\n/**\n * Performs a deep comparison between two values to determine if they are\n * equivalent.\n * \n * Supports: primitives, arrays, objects, dates, regexes, maps, sets, buffers, typed arrays\n * \n * @example\n * var object = { a: { b: 2 } };\n * var other = { a: { b: 2 } };\n *\n * isEqual(object, other);\n * // => true\n *\n * object === other;\n * // => false\n * @param a The value to compare.\n * @param b The other value to compare.\n * @returns Returns `true` if the values are equivalent, else `false`.\n */\n\nexport function isEqual(a: unknown, b: unknown): boolean {\n if (Object.is(a, b)) return true;\n \n if (typeof a !== typeof b) return false;\n\n if (Array.isArray(a) && Array.isArray(b))\n return isSameArray(a, b);\n\n if (a instanceof Date && b instanceof Date)\n return a.getTime() === b.getTime();\n\n if (a instanceof RegExp && b instanceof RegExp)\n return a.toString() === b.toString();\n\n if (isPlainObject(a) && isPlainObject(b))\n return isSameObject(a, b);\n\n if (a instanceof ArrayBuffer && b instanceof ArrayBuffer)\n return dataViewsAreEqual(new DataView(a), new DataView(b));\n\n if (a instanceof DataView && b instanceof DataView)\n return dataViewsAreEqual(a, b);\n\n if (isTypedArray(a) && isTypedArray(b)) {\n if (a.byteLength !== b.byteLength) return false;\n return isSameArray(a, b);\n }\n\n return false;\n}\n\nfunction isSameObject(a: PlainObject, b: PlainObject) {\n // check if the objects have the same keys\n const keys1 = Object.keys(a);\n const keys2 = Object.keys(b);\n if (!isEqual(keys1, keys2)) return false;\n\n // check if the values of each key in the objects are equal\n for (const key of keys1) {\n if (!isEqual(a[key], b[key])) return false;\n }\n\n // the objects are deeply equal\n return true;\n}\n\nfunction isSameArray(a: unknown[] | TypedArray, b: unknown[] | TypedArray) {\n if (a.length !== b.length) return false;\n return a.every((element, index) => isEqual(element, b[index]));\n}\n\nfunction dataViewsAreEqual(a: DataView, b: DataView) {\n if (a.byteLength !== b.byteLength) return false;\n for (let offset = 0; offset < a.byteLength; offset++) {\n if (a.getUint8(offset) !== b.getUint8(offset)) return false;\n }\n return true;\n}\n\nfunction isTypedArray(value: unknown): value is TypedArray {\n return ArrayBuffer.isView(value) && !(value instanceof DataView);\n}","/**\n * Checks if given string is a valid URL\n *\n * @example\n * isUrl('https://google.com')\n * // => true\n * isUrl('google.com')\n * // => false\n * @param str The string to check.\n * @returns Returns `true` if given string is a valid URL, else `false`.\n */\n\nexport function isUrl(str: string): boolean {\n try {\n new URL(str);\n return true;\n } catch {\n return false;\n }\n}"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACeO,SAAS,MAAa,OAAyB,WAA8B;AAChF,QAAM,UAAU,KAAK,MAAM,SAAS;AAEpC,MAAI,MAAM,WAAW,KAAK,UAAU;AAChC,WAAO,CAAC;AAEZ,MAAI,QAAQ;AACZ,MAAI,cAAc;AAClB,QAAM,SAAS,IAAI,MAAM,KAAK,KAAK,MAAM,SAAS,OAAO,CAAC;AAE1D,SAAO,QAAQ,MAAM,QAAQ;AACzB,WAAO,aAAa,IAAI,MAAM,MAAM,OAAQ,SAAS,O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IAAI,GAAG;AACX,WAAO;AAAA,EACX,QAAE;AACE,WAAO;AAAA,EACX;AACJ;","names":["difference","intersection","range","range","randomFloat","count","count","retries","timeout","camelCase","kebabCase","pascalCase","snakeCase","titleCase"]}
|