moderndash 0.12.8 → 0.13.1

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/README.md CHANGED
@@ -5,7 +5,7 @@
5
5
  Optimized for modern browsers & developer experience.
6
6
  </p>
7
7
 
8
- <div align=center>
8
+ <div align=center class="space-y">
9
9
  ✅ ESM
10
10
  ✅ Tree-shakable
11
11
  ✅ Typescript Strict Mode (no any)<br>
@@ -16,7 +16,7 @@
16
16
  </div>
17
17
  <p></p>
18
18
 
19
- <div align=center>
19
+ <div align=center class="center">
20
20
  <a href="https://bundlephobia.com/package/moderndash@0.11.1">
21
21
  <img alt="npm bundle size" src="https://img.shields.io/bundlephobia/minzip/moderndash@latest?color=Green">
22
22
  </a>
@@ -29,7 +29,7 @@
29
29
  </a>
30
30
  </div>
31
31
 
32
- <h3 align=center>
32
+ <h3 align=center class="hide-on-website">
33
33
  <a href="https://moderndash.io" target="_blank">
34
34
  📓 Documentation
35
35
  </a>
@@ -38,15 +38,15 @@
38
38
  ---
39
39
 
40
40
  ## 📓 Introduction
41
- ModernDash is a modern and lightweight alternative to utility libraries like Lodash. It provides important functions while encouraging use of native JS where possible.
41
+ ModernDash is a modern and lightweight alternative to utility libraries like Lodash. It provides important functions while encouraging the use of native JS wherever possible.
42
42
 
43
- ModernDash ignores trivial functions and focuses of the functions you actually need.
43
+ ModernDash ignores trivial functions and instead focuses on the functions that you actually need.
44
44
  ```typescript
45
45
  // We don't need
46
46
  Lodash.isArray(arr)
47
47
  Lodash.compact(arr)
48
48
 
49
- // When we these native replacements
49
+ // When we have these native replacements
50
50
  Array.isArray(arr)
51
51
  arr.filter(Boolean)
52
52
  ```
@@ -57,5 +57,5 @@ npm install moderndash
57
57
  ```
58
58
 
59
59
  ## Why is X lodash function not included?
60
- Please check [You-Dont-Need-Lodash](https://github.com/you-dont-need/You-Dont-Need-Lodash-Underscore) for native replacements.
61
- If you still think a function is missing open an issue.
60
+ Please refer to [You-Dont-Need-Lodash](https://github.com/you-dont-need/You-Dont-Need-Lodash-Underscore) for native replacements.
61
+ If you still believe a function is missing, please open an issue.
package/dist/index.cjs CHANGED
@@ -462,12 +462,13 @@ function randomInt(min, max) {
462
462
 
463
463
  // src/object/merge.ts
464
464
  function merge(target, ...sources) {
465
+ const targetCopy = { ...target };
465
466
  for (const source of sources) {
466
467
  for (const [key, value] of Object.entries(source)) {
467
- target[key] = isPlainObject(value) && isPlainObject(target[key]) ? merge(target[key], value) : value;
468
+ targetCopy[key] = isPlainObject(value) && isPlainObject(targetCopy[key]) ? merge(targetCopy[key], value) : value;
468
469
  }
469
470
  }
470
- return target;
471
+ return targetCopy;
471
472
  }
472
473
 
473
474
  // src/object/pick.ts
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.ts","../src/array/chunk.ts","../src/array/count.ts","../src/validate/isPlainObject.ts","../src/validate/isEqual.ts","../src/array/difference.ts","../src/array/dropRightWhile.ts","../src/array/dropWhile.ts","../src/array/group.ts","../src/array/intersection.ts","../src/array/sample.ts","../src/array/shuffle.ts","../src/array/sort.ts","../src/array/takeRightWhile.ts","../src/array/takeWhile.ts","../src/array/unique.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/randomFloat.ts","../src/number/randomInt.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/string/deburr.ts","../src/helpers/stringModifiers.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/stripSpecial.ts","../src/string/titleCase.ts","../src/string/unescapeHtml.ts","../src/validate/isEmpty.ts","../src/validate/isUrl.ts"],"sourcesContent":["export * from './array';\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: TElem[], chunkSize: number): TElem[][] {\n const sizeInteger = Math.trunc(chunkSize);\n if (array.length === 0 || sizeInteger < 1) {\n return [];\n }\n\n const chunkedArray = [];\n let i = 0;\n\n while (i < array.length) {\n chunkedArray.push(array.slice(i, i + sizeInteger));\n i += sizeInteger;\n }\n\n return chunkedArray;\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);\n * // => { 'true': 2, 'false': 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: TElem[], criteria: (value: TElem) => TKey | boolean): Record<TKey, number> {\n const result = {} as Record<TKey, number>;\n for (const value of array) {\n let key = criteria(value);\n if (typeof key === 'boolean')\n key = key.toString() as TKey;\n // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition\n if (result[key] === undefined)\n result[key] = 1;\n else\n result[key] += 1;\n }\n return result;\n}\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 './isPlainObject.js';\n\n/**\n * Performs a deep comparison between two values to determine if they are\n * equivalent.\n *\n * **Note:** This method supports comparing arrays, array buffers, booleans,\n * date objects, error objects, maps, numbers, `Object` objects, regexes,\n * sets, strings, symbols, and typed arrays. `Object` objects are compared\n * by their own, not inherited, enumerable properties. Functions and DOM\n * nodes are compared by strict equality, i.e. `===`.\n *\n * @example\n * var object = { 'a': 1 };\n * var other = { 'a': 1 };\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 (Array.isArray(a) && Array.isArray(b)) {\n return isSameArray(a, b);\n }\n\n if (a instanceof Date && b instanceof Date) {\n return a.getTime() === b.getTime();\n }\n\n if (a instanceof RegExp && b instanceof RegExp) {\n return a.toString() === b.toString();\n }\n\n if (isPlainObject(a) && isPlainObject(b)) {\n return isSameObject(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[], b: unknown[]) {\n if (a.length !== b.length) return false;\n\n // check if the values of each element in the arrays are equal\n for (const [i, element] of a.entries()) {\n if (!isEqual(element, b[i])) return false;\n }\n\n return true;\n}\n","import type { MinimumTwoArrays } from '@type/MinimumTwoArrays.js';\n\nimport { isEqual } from '@validate/isEqual';\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: {@link isEqual}).\n * @example\n * difference([2, 1], [2, 3])\n * // => [1]\n *\n * // ---- Custom compare function ----\n * difference((a, b) => Math.floor(a) === Math.floor(b), [1.2, 3.1], [1.3, 2.4])\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((a, b) => a.id === b.id, arr1, arr2)\n * // => [{ id: 1, name: 'Yeet' }]\n * @param arrays First array is inspected, others are excluded.\n * @template TElem The type of the array elements.\n * @returns Returns the new array of filtered values.\n */\n\nexport function difference<TElem>(...arrays: MinimumTwoArrays<TElem>): TElem[];\nexport function difference<TElem>(arrayOrCompFn: (a: TElem, b: TElem) => boolean, ...arrays: MinimumTwoArrays<TElem>): TElem[];\nexport function difference<TElem>(arrayOrCompFn: TElem[] | ((a: TElem, b: TElem) => boolean), ...arrays: MinimumTwoArrays<TElem>): TElem[] {\n const withCompareFn = typeof arrayOrCompFn === 'function';\n const compareFN = withCompareFn ? arrayOrCompFn as (a: TElem, b: TElem) => boolean : isEqual;\n\n const [firstArray, ...restArrays] = withCompareFn ? arrays : [arrayOrCompFn, ...arrays];\n const difference: TElem[] = [];\n\n firstArray.forEach(element => {\n if (!restArrays.some(array => array.some(item => compareFN(item, element)))) {\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 falsey.\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, ({ active }) => 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: 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 falsey.\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, ({ active }) => 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: 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)\n * // => { 'false': [4.2], 'true': [6.1, 6.3] }\n * \n * @param collection The array or object to iterate over.\n * @param criteria The criteria to group by.\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: TElem[], criteria: (value: TElem) => TKey | boolean): Record<TKey, TElem[]> {\n const result = {} as Record<TKey, TElem[]>;\n for (const value of array) {\n let key = criteria(value);\n if (typeof key === 'boolean')\n key = key.toString() as TKey;\n // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition\n result[key] = result[key] ?? [];\n result[key].push(value);\n }\n return result;\n}\n","import type { MinimumTwoArrays } from '@type/MinimumTwoArrays.js';\n\nimport { isEqual } from '@validate/isEqual';\n\n/**\n * Create an array with unique values from all input arrays, with order based on the first array. \n * \n * Optionally, use a compare function for element comparison (default: {@link isEqual}).\n * @example\n * intersection([2, 1], [2, 3])\n * // => [2]\n *\n * // ---- Custom compare function ----\n * const compareFn = (a, b) => Math.floor(a) === Math.floor(b);\n * \n * intersection(compareFn, [1.2, 1.1], [1.3, 2.4])\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((a, b) => a.id === b.id, arr1, arr2)\n * // => [{ id: 3, name: 'John' }]\n * @param arrays - The arrays to inspect.\n * @returns Returns the new array of intersecting values.\n */\n\nexport function intersection<TArr>(...arrays: MinimumTwoArrays<TArr>): TArr[];\nexport function intersection<TArr>(arrayOrCompFn: (a: TArr, b: TArr) => boolean, ...arrays: MinimumTwoArrays<TArr>): TArr[];\nexport function intersection<TArr>(arrayOrCompFn: TArr[] | ((a: TArr, b: TArr) => boolean), ...arrays: MinimumTwoArrays<TArr>): TArr[] {\n const withCompareFn = typeof arrayOrCompFn === 'function';\n const compareFN = withCompareFn ? arrayOrCompFn as (a: TArr, b: TArr) => boolean : isEqual;\n\n const [firstArray, ...restArrays] = withCompareFn ? arrays : [arrayOrCompFn, ...arrays];\n const intersection: TArr[] = [];\n\n firstArray.forEach(element => {\n if (restArrays.every(array => array.some(item => compareFN(item, element)))) {\n intersection.push(element);\n }\n });\n\n return intersection;\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 * @example\n * sample([1, 2, 3, 4])\n * // => 2\n *\n * sample([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 sample<TArr>(array: TArr[]): TArr | undefined;\nexport function sample<TArr>(array: TArr[], multi: number): TArr[];\nexport function sample<TArr>(array: TArr[], multi?: number): TArr | undefined | TArr[] {\n if (multi === undefined) {\n if (array.length === 0) return undefined;\n return getSingleSample(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] = getSingleSample(array);\n }\n return result;\n}\n\nfunction getSingleSample<TArr>(array: TArr[]): TArr {\n const randomIndex = Math.floor(Math.random() * array.length);\n return array[randomIndex];\n}","/**\n * Creates a new array of shuffled values, using a version of the\n * [Fisher-Yates shuffle](https://en.wikipedia.org/wiki/Fisher-Yates_shuffle).\n *\n * @example\n * shuffle([1, 2, 3, 4])\n * // => [4, 1, 3, 2]\n * @param array - The array or object to shuffle.\n * @returns Returns the new shuffled array.\n */\n\nexport function shuffle<TArr>(array: TArr[]): TArr[] {\n const shuffledArray = [...array];\n let currentIndex = shuffledArray.length;\n let temporaryValue: TArr;\n let randomIndex: number;\n\n // While there remain elements to shuffle...\n while (0 !== currentIndex) {\n // Pick a remaining element...\n randomIndex = Math.floor(Math.random() * currentIndex);\n currentIndex -= 1;\n\n // And swap it with the current element.\n temporaryValue = shuffledArray[currentIndex];\n shuffledArray[currentIndex] = shuffledArray[randomIndex];\n shuffledArray[randomIndex] = temporaryValue;\n }\n\n return shuffledArray;\n}\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 * @returns Returns the sorted array.\n*/\nexport function sort<TInput>(array: TInput[], ...orders: { order?: 'asc' | 'desc', by?: (item: TInput) => number | bigint | Date | string }[]): TInput[] {\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 falsey.\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(({ active }) => active, users)\n * // => objects for ['fred', 'pebbles']\n * @param predicate - The function invoked per iteration.\n * @param array - The array to query.\n * @returns Returns the slice of `array`.\n */\n\nexport function takeRightWhile<TArr>(predicate: (elem: TArr) => boolean, array: TArr[]): TArr[] {\n const result: TArr[] = [];\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 falsey.\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, ({ active }) => active)\n * // => objects for ['barney', 'fred']\n * @param predicate The function invoked per iteration.\n * @param array The array to query.\n * @returns Returns the slice of `array`.\n */\n\nexport function takeWhile<TArr>(array: TArr[], predicate: (elem: TArr) => boolean): TArr[] {\n const result: TArr[] = [];\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 { isEqual } from '@validate/isEqual';\n\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 * An compare function is optinal to specify how the array is compared (default: {@link isEqual}).\n * \n * @example\n * unique([2, 1, 2])\n * // => [2, 1]\n *\n * const users = [\n * { id: 1, name: 'a' },\n * { id: 1, name: 'c' }\n * ]\n *\n * unique(users, (a, b) => a.id === b.id)\n * // => [{ id: 1, name: 'a' }]\n *\n *\n * @param array - The array to inspect.\n * @param iteratee - The iteratee invoked per element.\n * @returns Returns the new duplicate free array.\n */\n\nexport function unique<TInput>(array: TInput[], compareFn = (a: TInput, b: TInput) => isEqual(a, b)): TInput[] {\n return array.filter((value, index, self) => {\n return self.findIndex(otherValue => compareFn(value, otherValue)) === index;\n });\n}\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, 1000);\n * \n * debouncedSayHello(\"John\");\n * debouncedSayHello(\"Jane\");\n * // => Only the second invocation of `debouncedSayHello` is executed, after a delay of 1000ms.\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 * Debouces 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 TypeScript >=5.0 or `experimentalDecorators` flag enabled.*\n * \n * @example\n * ```typescript\n * class TestClass {\n * @decDebounce(1000)\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 TypeScript >=5.0 or `experimentalDecorators` flag enabled.*\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 caches the result of `func`.\n * \n * The cache key is either determined by the provided `resolver` or by the arguments used in the cached function.\n *\n * The `cache` property is exposed on the cached function. It is an instance of `Map` and can be used to clear or inspect the cache. \n * The cache property can be replaced by a custom cache as long as it implements the `Map` interface.\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 * 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 *\n * memoizedFib(40) // => 102334155 (cache hit)\n *\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 TypeScript >=5.0 or `experimentalDecorators` flag enabled.*\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 TypeScript >=5.0 or `experimentalDecorators` flag enabled.*\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\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 TypeScript >=5.0 or `experimentalDecorators` flag enabled.*\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: 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: 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: 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 * 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) // => 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('min must be less than or equal to max');\n const range = max - min;\n const randomBuffer = new Uint32Array(1);\n crypto.getRandomValues(randomBuffer);\n const random = randomBuffer[0] / 0xFFFFFFFF;\n return min + (random * range);\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) // => 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 if (min > max)\n throw new Error('min must be less than or equal to max');\n const range = max - min + 1;\n const randomBuffer = new Uint32Array(1);\n crypto.getRandomValues(randomBuffer);\n return min + (randomBuffer[0] % range);\n}\n \n","import type { PlainObject } from '@type/PlainObject.js';\n\nimport { isPlainObject } from '@validate/isPlainObject.js';\n\n/**\n * Deep merge two or more objects.\n * \n * @example\n * // ---- Nested objects are merged ----\n * merge({ a: 1 }, { b: 2 }, { c: 3 }) \n * // => { a: 1, b: 2, c: 3 }\n * \n * merge({ a: { b: 1 } }, { a: { c: 2 } })\n * // => { a: { b: 1, c: 2 } }\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 * @returns The merged object\n */\n\nexport function merge(target: PlainObject, ...sources: PlainObject[]): PlainObject {\n for (const source of sources) {\n for (const [key, value] of Object.entries(source)) {\n target[key] = isPlainObject(value) && isPlainObject(target[key]) \n ? merge(target[key] as PlainObject, value) \n : value;\n }\n }\n return target;\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 * @returns Returns the new object.\n */\n\nexport function pick<TInput extends PlainObject, Key extends keyof TInput>(object: TInput, keysToPick: Key[]): Pick<TInput, Key> {\n const result = {} as Pick<TInput, 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 * @returns - An object without the specified keys\n *\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\n/**\n * Sets the value at path of object. If a portion of path doesn’t exist, it’s created.\n * \n * @alpha\n * @example\n * const obj = { a: { b: 2 } };\n * set(obj, 'a.c', 1);\n * // => { a: { b: 2, c: 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 * @returns The modified object.\n */\n\nexport function set(obj: PlainObject, path: string, value: unknown): PlainObject {\n const pathParts = path.split(/[.[\\]]/g).filter(x => Boolean(x.trim()));\n\n let currentObj: Record<string | number, unknown> = obj;\n for (let index = 0; index < pathParts.length; index++) {\n const key = pathParts[index];\n\n if (index === pathParts.length - 1) {\n currentObj[key] = value;\n break;\n }\n \n const nextIsNumber = !Number.isNaN(Number.parseInt(pathParts[index + 1]));\n if (currentObj[key] === undefined)\n currentObj[key] = nextIsNumber ? [] : {};\n\n currentObj = currentObj[key] as Record<string | number, unknown>;\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 aync functions or an array of async functions to the queue.\n * \n * @param asyncFn - The aync 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 promise1 = Promise.resolve(1);\n * const promise2 = Promise.resolve(2);\n * const promise3 = Promise.resolve(3);\n * \n * const firstThree = await races(3, promise1, promise2, promise3);\n * // => [1, 2, 3]\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 (url: string) => {\n * const response = await fetch(url);\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('https://example.com'), { maxRetries: 3, backoff: retries => retries * 1000, onRetry: logger });\n * // => Will retry 3 times with a 1 second delay between each retry. 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.\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, retry?: 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 }\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 * 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 // eslint-disable-next-line no-control-regex\n return str.replace(/[^\\u0000-\\u007E]/g, (chr: string) =>\n chr.normalize('NFD').replace(/[\\u0300-\\u036F]/g, ''));\n}\n","import { deburr } from '@string/deburr';\n\nexport function splitWords(str: string): string[] {\n str = deburr(str);\n\n // Split non-alphanumeric characters with spaces and deal with camel/PascalCase\n const regex = new RegExp(\n '[^\\\\dA-Za-z]' + // match any character that is not a letter or a digit\n '|' + // or\n '(?<=[a-z])' + // lookbehind for a lowercase letter\n '(?=[A-Z])' + // lookahead for an uppercase letter\n '|' + // or\n '(?<=[A-Z])' + // lookbehind for an uppercase letter\n '(?=[A-Z][a-z])' // lookahead for an uppercase letter followed by a lowercase letter\n );\n\n return str.split(regex).filter(Boolean);\n}\n","import { splitWords } from '@helpers/stringModifiers';\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 const words = splitWords(str);\n\n // Capitalize the first letter of each word\n const camelCase = words.map((word, index) => {\n if (index === 0) {\n return word.toLowerCase();\n }\n return word.charAt(0).toUpperCase() + word.slice(1).toLowerCase();\n });\n\n return camelCase.join('');\n}\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","/**\n * Converts the characters `&`, `<`, `>`, `\"` and `'` in a string to their corresponding HTML entities.\n *\n * @example\n * escapeHtml('fred, barney, & pebbles')\n * // => 'fred, barney, &amp; pebbles'\n * @param str - The string to escape.\n * @returns Returns the escaped string.\n */\n\nexport function escapeHtml(str: string): string {\n const escapeChars: Record<string, string> = {\n '&': '&amp;',\n '<': '&lt;',\n '>': '&gt;',\n '\\'': '&#39;',\n '\"': '&quot;'\n };\n return str.replace(/[\"&'<>]/g, char => escapeChars[char] || char);\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(/[$()*+.?[\\\\\\]^{|}]/g, '\\\\$&');\n}\n","import { splitWords } from '@helpers/stringModifiers';\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 * kebabCase('Héllo World')\n * // => 'hello-world'\n * \n * @param str - The string to convert.\n * @returns Returns the kebab cased string.\n */\n\nexport function kebabCase(str: string): string {\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 '@helpers/stringModifiers';\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 * pascalCase('Héllo World')\n * // => 'HelloWorld'\n * \n * @param str - The string to convert.\n * @returns Returns the pascal cased string.\n */\n\nexport function pascalCase(str: string): string {\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 '@helpers/stringModifiers';\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 * snakeCase('Héllo World')\n * // => 'hello_world'\n * @param str - The string to convert.\n * @returns Returns the snake cased string.\n */\n\nexport function snakeCase(str: string): string {\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 { deburr } from '@string/deburr';\n\n/**\n * Removes all special characters from a string.\n *\n * @example\n * stripSpecial('Héllo! World #$%&*!')\n * // => 'Hello World'\n * @param str - The string to remove special characters from.\n * @returns Returns the string with special characters removed.\n*/\n\nexport function stripSpecial(str: string): string {\n str = deburr(str);\n return str.replace(/[^\\s\\w]/gi, '');\n}\n","import { splitWords } from '@helpers/stringModifiers';\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 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 * Converts the HTML entities `&amp;`, `&lt;`, `&gt;`, `&quot;` and `&#39;`\n * in a string to their corresponding characters.\n *\n * @example\n * unescapeHtml('fred, barney, &amp; 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 const entityMap: Record<string, string> = {\n '&amp;': '&',\n '&lt;': '<',\n '&gt;': '>',\n '&quot;': '\"',\n '&#39;': '\\''\n };\n return str.replace(/&(?:amp|lt|gt|quot|#(0+)?39);/g, (entity: string) => entityMap[entity] || entity);\n}\n","/**\n * Checks if `value` is an empty object, collection, map, or set.\n *\n * Objects are considered empty if they have no own enumerable string keyed\n * properties.\n *\n * Array-like values such as `arguments` objects, arrays, buffers, strings, or\n * Similarly, maps and sets are considered empty if they have a `size` of `0`.\n *\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 given vlaue 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\n if (typeof value === 'string' || Array.isArray(value)) {\n return value.length === 0;\n }\n\n if (value instanceof Map || value instanceof Set) {\n return value.size === 0;\n }\n\n if (typeof value === 'object') {\n return Object.keys(value).length === 0;\n }\n\n return false;\n}\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;;;ACeO,SAAS,MAAa,OAAgB,WAA8B;AACvE,QAAM,cAAc,KAAK,MAAM,SAAS;AACxC,MAAI,MAAM,WAAW,KAAK,cAAc,GAAG;AACvC,WAAO,CAAC;AAAA,EACZ;AAEA,QAAM,eAAe,CAAC;AACtB,MAAI,IAAI;AAER,SAAO,IAAI,MAAM,QAAQ;AACrB,iBAAa,KAAK,MAAM,MAAM,GAAG,IAAI,WAAW,CAAC;AACjD,SAAK;AAAA,EACT;AAEA,SAAO;AACX;;;ACRO,SAAS,MAAuC,OAAgB,UAAkE;AACrI,QAAM,SAAS,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AAChB,SAAO,IAAI,QAAQ,aAAa,EAAE;AACtC;;;ACGO,SAAS,UAAU,KAAqB;AAC3C,QAAM,QAAQ,WAAW,GAAG;AAC5B,MAAIC,aAAY;AAChB,aAAW,QAAQ,OAAO;AACtB,IAAAA,cAAa,KAAK,OAAO,CAAC,EAAE,YAAY,IAAI,KAAK,MAAM,CAAC,EAAE,YAAY,IAAI;AAAA,EAC9E;AACA,SAAOA,WAAU,QAAQ;AAC7B;;;ACdO,SAAS,aAAa,KAAqB;AAC9C,QAAM,YAAoC;AAAA,IACtC,SAAS;AAAA,IACT,QAAQ;AAAA,IACR,QAAQ;AAAA,IACR,UAAU;AAAA,IACV,SAAS;AAAA,EACb;AACA,SAAO,IAAI,QAAQ,kCAAkC,CAAC,WAAmB,UAAU,MAAM,KAAK,MAAM;AACxG;;;ACWO,SAAS,QAAQ,OAAoD;AACxE,MAAI,UAAU,QAAQ,UAAU,QAAW;AACvC,WAAO;AAAA,EACX;AAEA,MAAI,OAAO,UAAU,YAAY,MAAM,QAAQ,KAAK,GAAG;AACnD,WAAO,MAAM,WAAW;AAAA,EAC5B;AAEA,MAAI,iBAAiB,OAAO,iBAAiB,KAAK;AAC9C,WAAO,MAAM,SAAS;AAAA,EAC1B;AAEA,MAAI,OAAO,UAAU,UAAU;AAC3B,WAAO,OAAO,KAAK,KAAK,EAAE,WAAW;AAAA,EACzC;AAEA,SAAO;AACX;;;ACrCO,SAAS,MAAM,KAAsB;AACxC,MAAI;AACA,QAAI,IAAI,GAAG;AACX,WAAO;AAAA,EACX,QAAE;AACE,WAAO;AAAA,EACX;AACJ;","names":["difference","intersection","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/validate/isPlainObject.ts","../src/validate/isEqual.ts","../src/array/difference.ts","../src/array/dropRightWhile.ts","../src/array/dropWhile.ts","../src/array/group.ts","../src/array/intersection.ts","../src/array/sample.ts","../src/array/shuffle.ts","../src/array/sort.ts","../src/array/takeRightWhile.ts","../src/array/takeWhile.ts","../src/array/unique.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/randomFloat.ts","../src/number/randomInt.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/string/deburr.ts","../src/helpers/stringModifiers.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/stripSpecial.ts","../src/string/titleCase.ts","../src/string/unescapeHtml.ts","../src/validate/isEmpty.ts","../src/validate/isUrl.ts"],"sourcesContent":["export * from './array';\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: TElem[], chunkSize: number): TElem[][] {\n const sizeInteger = Math.trunc(chunkSize);\n if (array.length === 0 || sizeInteger < 1) {\n return [];\n }\n\n const chunkedArray = [];\n let i = 0;\n\n while (i < array.length) {\n chunkedArray.push(array.slice(i, i + sizeInteger));\n i += sizeInteger;\n }\n\n return chunkedArray;\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);\n * // => { 'true': 2, 'false': 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: TElem[], criteria: (value: TElem) => TKey | boolean): Record<TKey, number> {\n const result = {} as Record<TKey, number>;\n for (const value of array) {\n let key = criteria(value);\n if (typeof key === 'boolean')\n key = key.toString() as TKey;\n // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition\n if (result[key] === undefined)\n result[key] = 1;\n else\n result[key] += 1;\n }\n return result;\n}\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 './isPlainObject.js';\n\n/**\n * Performs a deep comparison between two values to determine if they are\n * equivalent.\n *\n * **Note:** This method supports comparing arrays, array buffers, booleans,\n * date objects, error objects, maps, numbers, `Object` objects, regexes,\n * sets, strings, symbols, and typed arrays. `Object` objects are compared\n * by their own, not inherited, enumerable properties. Functions and DOM\n * nodes are compared by strict equality, i.e. `===`.\n *\n * @example\n * var object = { 'a': 1 };\n * var other = { 'a': 1 };\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 (Array.isArray(a) && Array.isArray(b)) {\n return isSameArray(a, b);\n }\n\n if (a instanceof Date && b instanceof Date) {\n return a.getTime() === b.getTime();\n }\n\n if (a instanceof RegExp && b instanceof RegExp) {\n return a.toString() === b.toString();\n }\n\n if (isPlainObject(a) && isPlainObject(b)) {\n return isSameObject(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[], b: unknown[]) {\n if (a.length !== b.length) return false;\n\n // check if the values of each element in the arrays are equal\n for (const [i, element] of a.entries()) {\n if (!isEqual(element, b[i])) return false;\n }\n\n return true;\n}\n","import type { ArrayMinLength } from '@type/ArrayMinLength.js';\n\nimport { isEqual } from '@validate/isEqual';\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: {@link isEqual}).\n * @example\n * difference([2, 1], [2, 3])\n * // => [1]\n *\n * // ---- Custom compare function ----\n * difference((a, b) => Math.floor(a) === Math.floor(b), [1.2, 3.1], [1.3, 2.4])\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((a, b) => a.id === b.id, arr1, arr2)\n * // => [{ id: 1, name: 'Yeet' }]\n * @param arrays First array is inspected, others are excluded.\n * @template TElem The type of the array elements.\n * @returns Returns the new array of filtered values.\n */\n\nexport function difference<TElem>(...arrays: ArrayMinLength<TElem[], 2>): TElem[];\nexport function difference<TElem>(arrayOrCompFn: (a: TElem, b: TElem) => boolean, ...arrays: ArrayMinLength<TElem[], 2>): TElem[];\nexport function difference<TElem>(arrayOrCompFn: TElem[] | ((a: TElem, b: TElem) => boolean), ...arrays: ArrayMinLength<TElem[], 2>): TElem[] {\n const withCompareFn = typeof arrayOrCompFn === 'function';\n const compareFN = withCompareFn ? arrayOrCompFn as (a: TElem, b: TElem) => boolean : isEqual;\n\n const [firstArray, ...restArrays] = withCompareFn ? arrays : [arrayOrCompFn, ...arrays];\n const difference: TElem[] = [];\n\n firstArray.forEach(element => {\n if (!restArrays.some(array => array.some(item => compareFN(item, element)))) {\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 falsey.\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, ({ active }) => 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: 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 falsey.\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, ({ active }) => 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: 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)\n * // => { 'false': [4.2], 'true': [6.1, 6.3] }\n * \n * @param collection The array or object to iterate over.\n * @param criteria The criteria to group by.\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: TElem[], criteria: (value: TElem) => TKey | boolean): Record<TKey, TElem[]> {\n const result = {} as Record<TKey, TElem[]>;\n for (const value of array) {\n let key = criteria(value);\n if (typeof key === 'boolean')\n key = key.toString() as TKey;\n // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition\n result[key] = result[key] ?? [];\n result[key].push(value);\n }\n return result;\n}\n","import type { ArrayMinLength } from '@type/ArrayMinLength.js';\n\nimport { isEqual } from '@validate/isEqual';\n\n/**\n * Create an array with unique values from all input arrays, with order based on the first array. \n * \n * Optionally, use a compare function for element comparison (default: {@link isEqual}).\n * @example\n * intersection([2, 1], [2, 3])\n * // => [2]\n *\n * // ---- Custom compare function ----\n * const compareFn = (a, b) => Math.floor(a) === Math.floor(b);\n * \n * intersection(compareFn, [1.2, 1.1], [1.3, 2.4])\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((a, b) => a.id === b.id, arr1, arr2)\n * // => [{ id: 3, name: 'John' }]\n * @param arrays - The arrays to inspect.\n * @returns Returns the new array of intersecting values.\n */\n\nexport function intersection<TArr>(...arrays: ArrayMinLength<TArr[], 2>): TArr[];\nexport function intersection<TArr>(arrayOrCompFn: (a: TArr, b: TArr) => boolean, ...arrays: ArrayMinLength<TArr[], 2>): TArr[];\nexport function intersection<TArr>(arrayOrCompFn: TArr[] | ((a: TArr, b: TArr) => boolean), ...arrays: ArrayMinLength<TArr[], 2>): TArr[] {\n const withCompareFn = typeof arrayOrCompFn === 'function';\n const compareFN = withCompareFn ? arrayOrCompFn as (a: TArr, b: TArr) => boolean : isEqual;\n\n const [firstArray, ...restArrays] = withCompareFn ? arrays : [arrayOrCompFn, ...arrays];\n const intersection: TArr[] = [];\n\n firstArray.forEach(element => {\n if (restArrays.every(array => array.some(item => compareFN(item, element)))) {\n intersection.push(element);\n }\n });\n\n return intersection;\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 * @example\n * sample([1, 2, 3, 4])\n * // => 2\n *\n * sample([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 sample<TArr>(array: TArr[]): TArr | undefined;\nexport function sample<TArr>(array: TArr[], multi: number): TArr[];\nexport function sample<TArr>(array: TArr[], multi?: number): TArr | undefined | TArr[] {\n if (multi === undefined) {\n if (array.length === 0) return undefined;\n return getSingleSample(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] = getSingleSample(array);\n }\n return result;\n}\n\nfunction getSingleSample<TArr>(array: TArr[]): TArr {\n const randomIndex = Math.floor(Math.random() * array.length);\n return array[randomIndex];\n}","/**\n * Creates a new array of shuffled values, using a version of the\n * [Fisher-Yates shuffle](https://en.wikipedia.org/wiki/Fisher-Yates_shuffle).\n *\n * @example\n * shuffle([1, 2, 3, 4])\n * // => [4, 1, 3, 2]\n * @param array - The array or object to shuffle.\n * @returns Returns the new shuffled array.\n */\n\nexport function shuffle<TArr>(array: TArr[]): TArr[] {\n const shuffledArray = [...array];\n let currentIndex = shuffledArray.length;\n let temporaryValue: TArr;\n let randomIndex: number;\n\n // While there remain elements to shuffle...\n while (0 !== currentIndex) {\n // Pick a remaining element...\n randomIndex = Math.floor(Math.random() * currentIndex);\n currentIndex -= 1;\n\n // And swap it with the current element.\n temporaryValue = shuffledArray[currentIndex];\n shuffledArray[currentIndex] = shuffledArray[randomIndex];\n shuffledArray[randomIndex] = temporaryValue;\n }\n\n return shuffledArray;\n}\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 * @returns Returns the sorted array.\n*/\nexport function sort<TInput>(array: TInput[], ...orders: { order?: 'asc' | 'desc', by?: (item: TInput) => number | bigint | Date | string }[]): TInput[] {\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 falsey.\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(({ active }) => active, users)\n * // => objects for ['fred', 'pebbles']\n * @param predicate - The function invoked per iteration.\n * @param array - The array to query.\n * @returns Returns the slice of `array`.\n */\n\nexport function takeRightWhile<TArr>(predicate: (elem: TArr) => boolean, array: TArr[]): TArr[] {\n const result: TArr[] = [];\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 falsey.\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, ({ active }) => active)\n * // => objects for ['barney', 'fred']\n * @param predicate The function invoked per iteration.\n * @param array The array to query.\n * @returns Returns the slice of `array`.\n */\n\nexport function takeWhile<TArr>(array: TArr[], predicate: (elem: TArr) => boolean): TArr[] {\n const result: TArr[] = [];\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 { isEqual } from '@validate/isEqual';\n\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 * An compare function is optinal to specify how the array is compared (default: {@link isEqual}).\n * \n * @example\n * unique([2, 1, 2])\n * // => [2, 1]\n *\n * const users = [\n * { id: 1, name: 'a' },\n * { id: 1, name: 'c' }\n * ]\n *\n * unique(users, (a, b) => a.id === b.id)\n * // => [{ id: 1, name: 'a' }]\n *\n *\n * @param array - The array to inspect.\n * @param iteratee - The iteratee invoked per element.\n * @returns Returns the new duplicate free array.\n */\n\nexport function unique<TInput>(array: TInput[], compareFn = (a: TInput, b: TInput) => isEqual(a, b)): TInput[] {\n return array.filter((value, index, self) => {\n return self.findIndex(otherValue => compareFn(value, otherValue)) === index;\n });\n}\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 * Debouces 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 TypeScript >=5.0 or `experimentalDecorators` flag enabled.*\n * \n * @example\n * ```typescript\n * class TestClass {\n * @decDebounce(1000)\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 TypeScript >=5.0 or `experimentalDecorators` flag enabled.*\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 caches the result of `func`.\n * \n * The cache key is either determined by the provided `resolver` or by the arguments used in the cached function.\n *\n * The `cache` property is exposed on the cached function. It is an instance of `Map` and can be used to clear or inspect the cache. \n * The cache property can be replaced by a custom cache as long as it implements the `Map` interface.\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 * 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 TypeScript >=5.0 or `experimentalDecorators` flag enabled.*\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 TypeScript >=5.0 or `experimentalDecorators` flag enabled.*\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\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 TypeScript >=5.0 or `experimentalDecorators` flag enabled.*\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: 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: 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: 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 * 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) // => 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('min must be less than or equal to max');\n const range = max - min;\n const randomBuffer = new Uint32Array(1);\n crypto.getRandomValues(randomBuffer);\n const random = randomBuffer[0] / 0xFFFFFFFF;\n return min + (random * range);\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) // => 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 if (min > max)\n throw new Error('min must be less than or equal to max');\n const range = max - min + 1;\n const randomBuffer = new Uint32Array(1);\n crypto.getRandomValues(randomBuffer);\n return min + (randomBuffer[0] % range);\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 * @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 * @returns Returns the new object.\n */\n\nexport function pick<TInput extends PlainObject, Key extends keyof TInput>(object: TInput, keysToPick: Key[]): Pick<TInput, Key> {\n const result = {} as Pick<TInput, 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 * @returns - An object without the specified keys\n *\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\n/**\n * Sets the value at path of object. If a portion of path doesn’t exist, it’s created.\n * \n * @alpha\n * @example\n * const obj = { a: { b: 2 } };\n * set(obj, 'a.c', 1);\n * // => { a: { b: 2, c: 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 * @returns The modified object.\n */\n\nexport function set<TObj extends PlainObject>(obj: TObj, path: string, value: unknown): TObj {\n const pathParts = path.split(/[.[\\]]/g).filter(x => Boolean(x.trim()));\n\n let currentObj: Record<string | number, unknown> = obj;\n for (let index = 0; index < pathParts.length; index++) {\n const key = pathParts[index];\n\n if (index === pathParts.length - 1) {\n currentObj[key] = value;\n break;\n }\n \n const nextIsNumber = !Number.isNaN(Number.parseInt(pathParts[index + 1]));\n if (currentObj[key] === undefined)\n currentObj[key] = nextIsNumber ? [] : {};\n\n currentObj = currentObj[key] as Record<string | number, unknown>;\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 aync functions or an array of async functions to the queue.\n * \n * @param asyncFn - The aync 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 promise1 = Promise.resolve(1);\n * const promise2 = Promise.resolve(2);\n * const promise3 = Promise.resolve(3);\n * \n * const firstThree = await races(3, promise1, promise2, promise3);\n * // => [1, 2, 3]\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 (url: string) => {\n * const response = await fetch(url);\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('https://example.com'), { maxRetries: 3, backoff: retries => retries * 1000, onRetry: logger });\n * // => Will retry 3 times with a 1 second delay between each retry. 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.\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, retry?: 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 }\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 * 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 // eslint-disable-next-line no-control-regex\n return str.replace(/[^\\u0000-\\u007E]/g, (chr: string) =>\n chr.normalize('NFD').replace(/[\\u0300-\\u036F]/g, ''));\n}\n","import { deburr } from '@string/deburr';\n\nexport function splitWords(str: string): string[] {\n str = deburr(str);\n\n // Split non-alphanumeric characters with spaces and deal with camel/PascalCase\n const regex = new RegExp(\n '[^\\\\dA-Za-z]' + // match any character that is not a letter or a digit\n '|' + // or\n '(?<=[a-z])' + // lookbehind for a lowercase letter\n '(?=[A-Z])' + // lookahead for an uppercase letter\n '|' + // or\n '(?<=[A-Z])' + // lookbehind for an uppercase letter\n '(?=[A-Z][a-z])' // lookahead for an uppercase letter followed by a lowercase letter\n );\n\n return str.split(regex).filter(Boolean);\n}\n","import { splitWords } from '@helpers/stringModifiers';\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 const words = splitWords(str);\n\n // Capitalize the first letter of each word\n const camelCase = words.map((word, index) => {\n if (index === 0) {\n return word.toLowerCase();\n }\n return word.charAt(0).toUpperCase() + word.slice(1).toLowerCase();\n });\n\n return camelCase.join('');\n}\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","/**\n * Converts the characters `&`, `<`, `>`, `\"` and `'` in a string to their corresponding HTML entities.\n *\n * @example\n * escapeHtml('fred, barney, & pebbles')\n * // => 'fred, barney, &amp; pebbles'\n * @param str - The string to escape.\n * @returns Returns the escaped string.\n */\n\nexport function escapeHtml(str: string): string {\n const escapeChars: Record<string, string> = {\n '&': '&amp;',\n '<': '&lt;',\n '>': '&gt;',\n '\\'': '&#39;',\n '\"': '&quot;'\n };\n return str.replace(/[\"&'<>]/g, char => escapeChars[char] || char);\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(/[$()*+.?[\\\\\\]^{|}]/g, '\\\\$&');\n}\n","import { splitWords } from '@helpers/stringModifiers';\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 * kebabCase('Héllo World')\n * // => 'hello-world'\n * \n * @param str - The string to convert.\n * @returns Returns the kebab cased string.\n */\n\nexport function kebabCase(str: string): string {\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 '@helpers/stringModifiers';\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 * pascalCase('Héllo World')\n * // => 'HelloWorld'\n * \n * @param str - The string to convert.\n * @returns Returns the pascal cased string.\n */\n\nexport function pascalCase(str: string): string {\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 '@helpers/stringModifiers';\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 * snakeCase('Héllo World')\n * // => 'hello_world'\n * @param str - The string to convert.\n * @returns Returns the snake cased string.\n */\n\nexport function snakeCase(str: string): string {\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 { deburr } from '@string/deburr';\n\n/**\n * Removes all special characters from a string.\n *\n * @example\n * stripSpecial('Héllo! World #$%&*!')\n * // => 'Hello World'\n * @param str - The string to remove special characters from.\n * @returns Returns the string with special characters removed.\n*/\n\nexport function stripSpecial(str: string): string {\n str = deburr(str);\n return str.replace(/[^\\s\\w]/gi, '');\n}\n","import { splitWords } from '@helpers/stringModifiers';\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 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 * Converts the HTML entities `&amp;`, `&lt;`, `&gt;`, `&quot;` and `&#39;`\n * in a string to their corresponding characters.\n *\n * @example\n * unescapeHtml('fred, barney, &amp; 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 const entityMap: Record<string, string> = {\n '&amp;': '&',\n '&lt;': '<',\n '&gt;': '>',\n '&quot;': '\"',\n '&#39;': '\\''\n };\n return str.replace(/&(?:amp|lt|gt|quot|#(0+)?39);/g, (entity: string) => entityMap[entity] || entity);\n}\n","/**\n * Checks if `value` is an empty object, collection, map, or set.\n *\n * Objects are considered empty if they have no own enumerable string keyed\n * properties.\n *\n * Array-like values such as `arguments` objects, arrays, buffers, strings, or\n * Similarly, maps and sets are considered empty if they have a `size` of `0`.\n *\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 given vlaue 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\n if (typeof value === 'string' || Array.isArray(value)) {\n return value.length === 0;\n }\n\n if (value instanceof Map || value instanceof Set) {\n return value.size === 0;\n }\n\n if (typeof value === 'object') {\n return Object.keys(value).length === 0;\n }\n\n return false;\n}\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;;;ACeO,SAAS,MAAa,OAAgB,WAA8B;AACvE,QAAM,cAAc,KAAK,MAAM,SAAS;AACxC,MAAI,MAAM,WAAW,KAAK,cAAc,GAAG;AACvC,WAAO,CAAC;AAAA,EACZ;AAEA,QAAM,eAAe,CAAC;AACtB,MAAI,IAAI;AAER,SAAO,IAAI,MAAM,QAAQ;AACrB,iBAAa,KAAK,MAAM,MAAM,GAAG,IAAI,WAAW,CAAC;AACjD,SAAK;AAAA,EACT;AAEA,SAAO;AACX;;;ACRO,SAAS,MAAuC,OAAgB,UAAkE;AACrI,QAAM,SAAS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O,SAAS,aAAa,KAAqB;AAC9C,QAAM,OAAO,GAAG;AAChB,SAAO,IAAI,QAAQ,aAAa,EAAE;AACtC;;;ACGO,SAAS,UAAU,KAAqB;AAC3C,QAAM,QAAQ,WAAW,GAAG;AAC5B,MAAIC,aAAY;AAChB,aAAW,QAAQ,OAAO;AACtB,IAAAA,cAAa,KAAK,OAAO,CAAC,EAAE,YAAY,IAAI,KAAK,MAAM,CAAC,EAAE,YAAY,IAAI;AAAA,EAC9E;AACA,SAAOA,WAAU,QAAQ;AAC7B;;;ACdO,SAAS,aAAa,KAAqB;AAC9C,QAAM,YAAoC;AAAA,IACtC,SAAS;AAAA,IACT,QAAQ;AAAA,IACR,QAAQ;AAAA,IACR,UAAU;AAAA,IACV,SAAS;AAAA,EACb;AACA,SAAO,IAAI,QAAQ,kCAAkC,CAAC,WAAmB,UAAU,MAAM,KAAK,MAAM;AACxG;;;ACWO,SAAS,QAAQ,OAAoD;AACxE,MAAI,UAAU,QAAQ,UAAU,QAAW;AACvC,WAAO;AAAA,EACX;AAEA,MAAI,OAAO,UAAU,YAAY,MAAM,QAAQ,KAAK,GAAG;AACnD,WAAO,MAAM,WAAW;AAAA,EAC5B;AAEA,MAAI,iBAAiB,OAAO,iBAAiB,KAAK;AAC9C,WAAO,MAAM,SAAS;AAAA,EAC1B;AAEA,MAAI,OAAO,UAAU,UAAU;AAC3B,WAAO,OAAO,KAAK,KAAK,EAAE,WAAW;AAAA,EACzC;AAEA,SAAO;AACX;;;ACrCO,SAAS,MAAM,KAAsB;AACxC,MAAI;AACA,QAAI,IAAI,GAAG;AACX,WAAO;AAAA,EACX,QAAE;AACE,WAAO;AAAA,EACX;AACJ;","names":["difference","intersection","count","count","retries","timeout","camelCase","kebabCase","pascalCase","snakeCase","titleCase"]}
package/dist/index.d.ts CHANGED
@@ -38,20 +38,17 @@ declare function chunk<TElem>(array: TElem[], chunkSize: number): TElem[][];
38
38
  declare function count<TElem, TKey extends PropertyKey>(array: TElem[], criteria: (value: TElem) => TKey | boolean): Record<TKey, number>;
39
39
 
40
40
  /**
41
- * A tuple of two or more arrays. Useful for rest parameters.
41
+ * This type builds an array with a minimum length.
42
42
  *
43
43
  * @example
44
- * type MinTwo = MinimumTwoArrays<number>;
44
+ * let arr: ArrayMinLength<number, 3> = [1, 2, 3];
45
+ * arr = [1, 2, 3, 4]; // Error
45
46
  *
46
- * const arr1: MinTwo = [[1, 2, 3], [4, 5, 6]];
47
- * const arr2: MinTwo = [[1, 2, 3], [4, 5, 6], [7, 8, 9]];
48
- *
49
- * const arr3: MinTwo = [[1, 2, 3]]
50
- * // => Type 'number[][]' is not assignable to type '[number[], number[], ...number[][]]'.
51
- *
52
- * @template TInput - The type of the array elements.
47
+ * @template TElem The type of the array elements.
48
+ * @template TMinLength The minimum length of the array.
53
49
  */
54
- type MinimumTwoArrays<TInput> = [TInput[], TInput[], ...TInput[][]];
50
+ type ArrayMinLength<TElem, TMinLenght extends number> = BuildArrayMinLength<TElem, TMinLenght, []>;
51
+ type BuildArrayMinLength<TElem, TMinLength extends number, Current extends TElem[]> = Current['length'] extends TMinLength ? [...Current, ...TElem[]] : BuildArrayMinLength<TElem, TMinLength, [...Current, TElem]>;
55
52
 
56
53
  /**
57
54
  * Create a new array with values from the first array that are not present in the other arrays.
@@ -75,8 +72,8 @@ type MinimumTwoArrays<TInput> = [TInput[], TInput[], ...TInput[][]];
75
72
  * @template TElem The type of the array elements.
76
73
  * @returns Returns the new array of filtered values.
77
74
  */
78
- declare function difference<TElem>(...arrays: MinimumTwoArrays<TElem>): TElem[];
79
- declare function difference<TElem>(arrayOrCompFn: (a: TElem, b: TElem) => boolean, ...arrays: MinimumTwoArrays<TElem>): TElem[];
75
+ declare function difference<TElem>(...arrays: ArrayMinLength<TElem[], 2>): TElem[];
76
+ declare function difference<TElem>(arrayOrCompFn: (a: TElem, b: TElem) => boolean, ...arrays: ArrayMinLength<TElem[], 2>): TElem[];
80
77
 
81
78
  /**
82
79
  * Creates a slice of `array` excluding elements dropped from the end.
@@ -158,8 +155,8 @@ declare function group<TElem, TKey extends PropertyKey>(array: TElem[], criteria
158
155
  * @param arrays - The arrays to inspect.
159
156
  * @returns Returns the new array of intersecting values.
160
157
  */
161
- declare function intersection<TArr>(...arrays: MinimumTwoArrays<TArr>): TArr[];
162
- declare function intersection<TArr>(arrayOrCompFn: (a: TArr, b: TArr) => boolean, ...arrays: MinimumTwoArrays<TArr>): TArr[];
158
+ declare function intersection<TArr>(...arrays: ArrayMinLength<TArr[], 2>): TArr[];
159
+ declare function intersection<TArr>(arrayOrCompFn: (a: TArr, b: TArr) => boolean, ...arrays: ArrayMinLength<TArr[], 2>): TArr[];
163
160
 
164
161
  /**
165
162
  * Gets a random element an array. A single element is returned by default.
@@ -357,14 +354,12 @@ type GenericFunction<TFunc extends (...args: any) => any> = (...args: Parameters
357
354
  * const memoizedFib = memoize(fibonacci, { ttl: 1000 })
358
355
  *
359
356
  * memoizedFib(40) // => 102334155
360
- *
361
357
  * memoizedFib(40) // => 102334155 (cache hit)
362
- *
363
358
  * setTimeout(() => memoizedFib(40), 1000) // => 102334155 (cache miss)
364
359
  *
365
360
  * // Cached values are exposed as the `cache` property.
366
- * memoizedFib.cache.get(40) // => [value, timestamp]
367
- * memoizedFib.cache.set(40, [1234, Date.now()])
361
+ * memoizedFib.cache.get("40") // => [value, timestamp]
362
+ * memoizedFib.cache.set("40", [1234, Date.now()])
368
363
  * memoizedFib.cache.clear()
369
364
  *
370
365
  * // This is the default way to create cache keys.
@@ -507,11 +502,11 @@ declare function toDecorator<TFunc extends GenericFunction<TFunc>>(func: TFunc):
507
502
  *
508
503
  * @example
509
504
  * const sayHello = (name: string) => console.log(`Hello, ${name}!`);
510
- * const debouncedSayHello = debounce(sayHello, 1000);
505
+ * const debouncedSayHello = debounce(sayHello, 200);
511
506
  *
512
507
  * debouncedSayHello("John");
513
508
  * debouncedSayHello("Jane");
514
- * // => Only the second invocation of `debouncedSayHello` is executed, after a delay of 1000ms.
509
+ * // => Only the second invocation of `debouncedSayHello` is executed, after a delay of 200ms.
515
510
  * @param func - The function to debounce.
516
511
  * @param wait - The number of milliseconds to wait before invoking `func`.
517
512
  * @returns A debounced version of `func` with `cancel` and `flush` methods.
@@ -676,15 +671,12 @@ declare function sum(numbers: number[]): number;
676
671
  type PlainObject = Record<PropertyKey, unknown>;
677
672
 
678
673
  /**
679
- * Deep merge two or more objects.
674
+ * This function combines two or more objects into a single new object. Arrays and other types are overwritten.
680
675
  *
681
676
  * @example
682
677
  * // ---- Nested objects are merged ----
683
- * merge({ a: 1 }, { b: 2 }, { c: 3 })
684
- * // => { a: 1, b: 2, c: 3 }
685
- *
686
- * merge({ a: { b: 1 } }, { a: { c: 2 } })
687
- * // => { a: { b: 1, c: 2 } }
678
+ * merge({ a: 1 }, { b: 2 }, { c: 3, d: { e: 4 } })
679
+ * // => { a: 1, b: 2, c: 3, d: { e: 4 } }
688
680
  *
689
681
  * // ---- Other types are overwritten ----
690
682
  * merge({ a: [1, 2] }, { a: [3, 4] })
@@ -694,9 +686,22 @@ type PlainObject = Record<PropertyKey, unknown>;
694
686
  * // => { a: "Yes" }
695
687
  * @param target - The target object
696
688
  * @param sources - The source objects
697
- * @returns The merged object
689
+ * @returns A new merged object
698
690
  */
699
- declare function merge(target: PlainObject, ...sources: PlainObject[]): PlainObject;
691
+ declare function merge<TTarget extends PlainObject, TSources extends ArrayMinLength<PlainObject, 1>>(target: TTarget, ...sources: TSources): MergeDeepObjects<[TTarget, ...TSources]>;
692
+ type OptionalPropertyNames<T> = {
693
+ [K in keyof T]-?: (PlainObject extends {
694
+ [P in K]: T[K];
695
+ } ? K : never);
696
+ }[keyof T];
697
+ type SpreadProperties<L, R, K extends keyof L & keyof R> = {
698
+ [P in K]: L[P] | Exclude<R[P], undefined>;
699
+ };
700
+ type Id<T> = T extends infer U ? {
701
+ [K in keyof U]: U[K];
702
+ } : never;
703
+ type SpreadTwo<L, R> = Id<Pick<L, Exclude<keyof L, keyof R>> & Pick<R, Exclude<keyof R, OptionalPropertyNames<R>>> & Pick<R, Exclude<OptionalPropertyNames<R>, keyof L>> & SpreadProperties<L, R, OptionalPropertyNames<R> & keyof L>>;
704
+ type MergeDeepObjects<A extends readonly [...unknown[]]> = A extends [infer L, ...infer R] ? SpreadTwo<L, MergeDeepObjects<R>> : unknown;
700
705
 
701
706
  /**
702
707
  * Omit specified keys from an object
@@ -741,7 +746,7 @@ declare function pick<TInput extends PlainObject, Key extends keyof TInput>(obje
741
746
  * @param value - The value to set.
742
747
  * @returns The modified object.
743
748
  */
744
- declare function set(obj: PlainObject, path: string, value: unknown): PlainObject;
749
+ declare function set<TObj extends PlainObject>(obj: TObj, path: string, value: unknown): TObj;
745
750
 
746
751
  /**
747
752
  * A class for managing a queue of async functions that runs a set number concurrently.
@@ -1134,4 +1139,4 @@ declare function isPlainObject(value: unknown): value is PlainObject;
1134
1139
  */
1135
1140
  declare function isUrl(str: string): boolean;
1136
1141
 
1137
- export { GenericFunction, MinimumTwoArrays, PlainObject, Queue, average, camelCase, capitalize, chunk, count, debounce, deburr, decDebounce, decMaxCalls, decMemoize, decMinCalls, decThrottle, difference, dropRightWhile, dropWhile, escapeHtml, escapeRegExp, group, intersection, isEmpty, isEqual, isPlainObject, isUrl, kebabCase, maxCalls, median, memoize, merge, minCalls, omit, pascalCase, pick, races, randomFloat, randomInt, retry, sample, set, shuffle, sleep, snakeCase, sort, stripSpecial, sum, takeRightWhile, takeWhile, throttle, timeout, times, titleCase, toDecorator, unescapeHtml, unique };
1142
+ export { ArrayMinLength, GenericFunction, PlainObject, Queue, average, camelCase, capitalize, chunk, count, debounce, deburr, decDebounce, decMaxCalls, decMemoize, decMinCalls, decThrottle, difference, dropRightWhile, dropWhile, escapeHtml, escapeRegExp, group, intersection, isEmpty, isEqual, isPlainObject, isUrl, kebabCase, maxCalls, median, memoize, merge, minCalls, omit, pascalCase, pick, races, randomFloat, randomInt, retry, sample, set, shuffle, sleep, snakeCase, sort, stripSpecial, sum, takeRightWhile, takeWhile, throttle, timeout, times, titleCase, toDecorator, unescapeHtml, unique };
package/dist/index.js CHANGED
@@ -383,12 +383,13 @@ function randomInt(min, max) {
383
383
 
384
384
  // src/object/merge.ts
385
385
  function merge(target, ...sources) {
386
+ const targetCopy = { ...target };
386
387
  for (const source of sources) {
387
388
  for (const [key, value] of Object.entries(source)) {
388
- target[key] = isPlainObject(value) && isPlainObject(target[key]) ? merge(target[key], value) : value;
389
+ targetCopy[key] = isPlainObject(value) && isPlainObject(targetCopy[key]) ? merge(targetCopy[key], value) : value;
389
390
  }
390
391
  }
391
- return target;
392
+ return targetCopy;
392
393
  }
393
394
 
394
395
  // src/object/pick.ts
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/array/chunk.ts","../src/array/count.ts","../src/validate/isPlainObject.ts","../src/validate/isEqual.ts","../src/array/difference.ts","../src/array/dropRightWhile.ts","../src/array/dropWhile.ts","../src/array/group.ts","../src/array/intersection.ts","../src/array/sample.ts","../src/array/shuffle.ts","../src/array/sort.ts","../src/array/takeRightWhile.ts","../src/array/takeWhile.ts","../src/array/unique.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/randomFloat.ts","../src/number/randomInt.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/string/deburr.ts","../src/helpers/stringModifiers.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/stripSpecial.ts","../src/string/titleCase.ts","../src/string/unescapeHtml.ts","../src/validate/isEmpty.ts","../src/validate/isUrl.ts"],"sourcesContent":["/**\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: TElem[], chunkSize: number): TElem[][] {\n const sizeInteger = Math.trunc(chunkSize);\n if (array.length === 0 || sizeInteger < 1) {\n return [];\n }\n\n const chunkedArray = [];\n let i = 0;\n\n while (i < array.length) {\n chunkedArray.push(array.slice(i, i + sizeInteger));\n i += sizeInteger;\n }\n\n return chunkedArray;\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);\n * // => { 'true': 2, 'false': 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: TElem[], criteria: (value: TElem) => TKey | boolean): Record<TKey, number> {\n const result = {} as Record<TKey, number>;\n for (const value of array) {\n let key = criteria(value);\n if (typeof key === 'boolean')\n key = key.toString() as TKey;\n // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition\n if (result[key] === undefined)\n result[key] = 1;\n else\n result[key] += 1;\n }\n return result;\n}\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 './isPlainObject.js';\n\n/**\n * Performs a deep comparison between two values to determine if they are\n * equivalent.\n *\n * **Note:** This method supports comparing arrays, array buffers, booleans,\n * date objects, error objects, maps, numbers, `Object` objects, regexes,\n * sets, strings, symbols, and typed arrays. `Object` objects are compared\n * by their own, not inherited, enumerable properties. Functions and DOM\n * nodes are compared by strict equality, i.e. `===`.\n *\n * @example\n * var object = { 'a': 1 };\n * var other = { 'a': 1 };\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 (Array.isArray(a) && Array.isArray(b)) {\n return isSameArray(a, b);\n }\n\n if (a instanceof Date && b instanceof Date) {\n return a.getTime() === b.getTime();\n }\n\n if (a instanceof RegExp && b instanceof RegExp) {\n return a.toString() === b.toString();\n }\n\n if (isPlainObject(a) && isPlainObject(b)) {\n return isSameObject(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[], b: unknown[]) {\n if (a.length !== b.length) return false;\n\n // check if the values of each element in the arrays are equal\n for (const [i, element] of a.entries()) {\n if (!isEqual(element, b[i])) return false;\n }\n\n return true;\n}\n","import type { MinimumTwoArrays } from '@type/MinimumTwoArrays.js';\n\nimport { isEqual } from '@validate/isEqual';\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: {@link isEqual}).\n * @example\n * difference([2, 1], [2, 3])\n * // => [1]\n *\n * // ---- Custom compare function ----\n * difference((a, b) => Math.floor(a) === Math.floor(b), [1.2, 3.1], [1.3, 2.4])\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((a, b) => a.id === b.id, arr1, arr2)\n * // => [{ id: 1, name: 'Yeet' }]\n * @param arrays First array is inspected, others are excluded.\n * @template TElem The type of the array elements.\n * @returns Returns the new array of filtered values.\n */\n\nexport function difference<TElem>(...arrays: MinimumTwoArrays<TElem>): TElem[];\nexport function difference<TElem>(arrayOrCompFn: (a: TElem, b: TElem) => boolean, ...arrays: MinimumTwoArrays<TElem>): TElem[];\nexport function difference<TElem>(arrayOrCompFn: TElem[] | ((a: TElem, b: TElem) => boolean), ...arrays: MinimumTwoArrays<TElem>): TElem[] {\n const withCompareFn = typeof arrayOrCompFn === 'function';\n const compareFN = withCompareFn ? arrayOrCompFn as (a: TElem, b: TElem) => boolean : isEqual;\n\n const [firstArray, ...restArrays] = withCompareFn ? arrays : [arrayOrCompFn, ...arrays];\n const difference: TElem[] = [];\n\n firstArray.forEach(element => {\n if (!restArrays.some(array => array.some(item => compareFN(item, element)))) {\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 falsey.\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, ({ active }) => 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: 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 falsey.\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, ({ active }) => 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: 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)\n * // => { 'false': [4.2], 'true': [6.1, 6.3] }\n * \n * @param collection The array or object to iterate over.\n * @param criteria The criteria to group by.\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: TElem[], criteria: (value: TElem) => TKey | boolean): Record<TKey, TElem[]> {\n const result = {} as Record<TKey, TElem[]>;\n for (const value of array) {\n let key = criteria(value);\n if (typeof key === 'boolean')\n key = key.toString() as TKey;\n // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition\n result[key] = result[key] ?? [];\n result[key].push(value);\n }\n return result;\n}\n","import type { MinimumTwoArrays } from '@type/MinimumTwoArrays.js';\n\nimport { isEqual } from '@validate/isEqual';\n\n/**\n * Create an array with unique values from all input arrays, with order based on the first array. \n * \n * Optionally, use a compare function for element comparison (default: {@link isEqual}).\n * @example\n * intersection([2, 1], [2, 3])\n * // => [2]\n *\n * // ---- Custom compare function ----\n * const compareFn = (a, b) => Math.floor(a) === Math.floor(b);\n * \n * intersection(compareFn, [1.2, 1.1], [1.3, 2.4])\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((a, b) => a.id === b.id, arr1, arr2)\n * // => [{ id: 3, name: 'John' }]\n * @param arrays - The arrays to inspect.\n * @returns Returns the new array of intersecting values.\n */\n\nexport function intersection<TArr>(...arrays: MinimumTwoArrays<TArr>): TArr[];\nexport function intersection<TArr>(arrayOrCompFn: (a: TArr, b: TArr) => boolean, ...arrays: MinimumTwoArrays<TArr>): TArr[];\nexport function intersection<TArr>(arrayOrCompFn: TArr[] | ((a: TArr, b: TArr) => boolean), ...arrays: MinimumTwoArrays<TArr>): TArr[] {\n const withCompareFn = typeof arrayOrCompFn === 'function';\n const compareFN = withCompareFn ? arrayOrCompFn as (a: TArr, b: TArr) => boolean : isEqual;\n\n const [firstArray, ...restArrays] = withCompareFn ? arrays : [arrayOrCompFn, ...arrays];\n const intersection: TArr[] = [];\n\n firstArray.forEach(element => {\n if (restArrays.every(array => array.some(item => compareFN(item, element)))) {\n intersection.push(element);\n }\n });\n\n return intersection;\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 * @example\n * sample([1, 2, 3, 4])\n * // => 2\n *\n * sample([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 sample<TArr>(array: TArr[]): TArr | undefined;\nexport function sample<TArr>(array: TArr[], multi: number): TArr[];\nexport function sample<TArr>(array: TArr[], multi?: number): TArr | undefined | TArr[] {\n if (multi === undefined) {\n if (array.length === 0) return undefined;\n return getSingleSample(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] = getSingleSample(array);\n }\n return result;\n}\n\nfunction getSingleSample<TArr>(array: TArr[]): TArr {\n const randomIndex = Math.floor(Math.random() * array.length);\n return array[randomIndex];\n}","/**\n * Creates a new array of shuffled values, using a version of the\n * [Fisher-Yates shuffle](https://en.wikipedia.org/wiki/Fisher-Yates_shuffle).\n *\n * @example\n * shuffle([1, 2, 3, 4])\n * // => [4, 1, 3, 2]\n * @param array - The array or object to shuffle.\n * @returns Returns the new shuffled array.\n */\n\nexport function shuffle<TArr>(array: TArr[]): TArr[] {\n const shuffledArray = [...array];\n let currentIndex = shuffledArray.length;\n let temporaryValue: TArr;\n let randomIndex: number;\n\n // While there remain elements to shuffle...\n while (0 !== currentIndex) {\n // Pick a remaining element...\n randomIndex = Math.floor(Math.random() * currentIndex);\n currentIndex -= 1;\n\n // And swap it with the current element.\n temporaryValue = shuffledArray[currentIndex];\n shuffledArray[currentIndex] = shuffledArray[randomIndex];\n shuffledArray[randomIndex] = temporaryValue;\n }\n\n return shuffledArray;\n}\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 * @returns Returns the sorted array.\n*/\nexport function sort<TInput>(array: TInput[], ...orders: { order?: 'asc' | 'desc', by?: (item: TInput) => number | bigint | Date | string }[]): TInput[] {\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 falsey.\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(({ active }) => active, users)\n * // => objects for ['fred', 'pebbles']\n * @param predicate - The function invoked per iteration.\n * @param array - The array to query.\n * @returns Returns the slice of `array`.\n */\n\nexport function takeRightWhile<TArr>(predicate: (elem: TArr) => boolean, array: TArr[]): TArr[] {\n const result: TArr[] = [];\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 falsey.\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, ({ active }) => active)\n * // => objects for ['barney', 'fred']\n * @param predicate The function invoked per iteration.\n * @param array The array to query.\n * @returns Returns the slice of `array`.\n */\n\nexport function takeWhile<TArr>(array: TArr[], predicate: (elem: TArr) => boolean): TArr[] {\n const result: TArr[] = [];\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 { isEqual } from '@validate/isEqual';\n\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 * An compare function is optinal to specify how the array is compared (default: {@link isEqual}).\n * \n * @example\n * unique([2, 1, 2])\n * // => [2, 1]\n *\n * const users = [\n * { id: 1, name: 'a' },\n * { id: 1, name: 'c' }\n * ]\n *\n * unique(users, (a, b) => a.id === b.id)\n * // => [{ id: 1, name: 'a' }]\n *\n *\n * @param array - The array to inspect.\n * @param iteratee - The iteratee invoked per element.\n * @returns Returns the new duplicate free array.\n */\n\nexport function unique<TInput>(array: TInput[], compareFn = (a: TInput, b: TInput) => isEqual(a, b)): TInput[] {\n return array.filter((value, index, self) => {\n return self.findIndex(otherValue => compareFn(value, otherValue)) === index;\n });\n}\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, 1000);\n * \n * debouncedSayHello(\"John\");\n * debouncedSayHello(\"Jane\");\n * // => Only the second invocation of `debouncedSayHello` is executed, after a delay of 1000ms.\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 * Debouces 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 TypeScript >=5.0 or `experimentalDecorators` flag enabled.*\n * \n * @example\n * ```typescript\n * class TestClass {\n * @decDebounce(1000)\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 TypeScript >=5.0 or `experimentalDecorators` flag enabled.*\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 caches the result of `func`.\n * \n * The cache key is either determined by the provided `resolver` or by the arguments used in the cached function.\n *\n * The `cache` property is exposed on the cached function. It is an instance of `Map` and can be used to clear or inspect the cache. \n * The cache property can be replaced by a custom cache as long as it implements the `Map` interface.\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 * 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 *\n * memoizedFib(40) // => 102334155 (cache hit)\n *\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 TypeScript >=5.0 or `experimentalDecorators` flag enabled.*\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 TypeScript >=5.0 or `experimentalDecorators` flag enabled.*\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\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 TypeScript >=5.0 or `experimentalDecorators` flag enabled.*\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: 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: 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: 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 * 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) // => 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('min must be less than or equal to max');\n const range = max - min;\n const randomBuffer = new Uint32Array(1);\n crypto.getRandomValues(randomBuffer);\n const random = randomBuffer[0] / 0xFFFFFFFF;\n return min + (random * range);\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) // => 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 if (min > max)\n throw new Error('min must be less than or equal to max');\n const range = max - min + 1;\n const randomBuffer = new Uint32Array(1);\n crypto.getRandomValues(randomBuffer);\n return min + (randomBuffer[0] % range);\n}\n \n","import type { PlainObject } from '@type/PlainObject.js';\n\nimport { isPlainObject } from '@validate/isPlainObject.js';\n\n/**\n * Deep merge two or more objects.\n * \n * @example\n * // ---- Nested objects are merged ----\n * merge({ a: 1 }, { b: 2 }, { c: 3 }) \n * // => { a: 1, b: 2, c: 3 }\n * \n * merge({ a: { b: 1 } }, { a: { c: 2 } })\n * // => { a: { b: 1, c: 2 } }\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 * @returns The merged object\n */\n\nexport function merge(target: PlainObject, ...sources: PlainObject[]): PlainObject {\n for (const source of sources) {\n for (const [key, value] of Object.entries(source)) {\n target[key] = isPlainObject(value) && isPlainObject(target[key]) \n ? merge(target[key] as PlainObject, value) \n : value;\n }\n }\n return target;\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 * @returns Returns the new object.\n */\n\nexport function pick<TInput extends PlainObject, Key extends keyof TInput>(object: TInput, keysToPick: Key[]): Pick<TInput, Key> {\n const result = {} as Pick<TInput, 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 * @returns - An object without the specified keys\n *\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\n/**\n * Sets the value at path of object. If a portion of path doesn’t exist, it’s created.\n * \n * @alpha\n * @example\n * const obj = { a: { b: 2 } };\n * set(obj, 'a.c', 1);\n * // => { a: { b: 2, c: 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 * @returns The modified object.\n */\n\nexport function set(obj: PlainObject, path: string, value: unknown): PlainObject {\n const pathParts = path.split(/[.[\\]]/g).filter(x => Boolean(x.trim()));\n\n let currentObj: Record<string | number, unknown> = obj;\n for (let index = 0; index < pathParts.length; index++) {\n const key = pathParts[index];\n\n if (index === pathParts.length - 1) {\n currentObj[key] = value;\n break;\n }\n \n const nextIsNumber = !Number.isNaN(Number.parseInt(pathParts[index + 1]));\n if (currentObj[key] === undefined)\n currentObj[key] = nextIsNumber ? [] : {};\n\n currentObj = currentObj[key] as Record<string | number, unknown>;\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 aync functions or an array of async functions to the queue.\n * \n * @param asyncFn - The aync 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 promise1 = Promise.resolve(1);\n * const promise2 = Promise.resolve(2);\n * const promise3 = Promise.resolve(3);\n * \n * const firstThree = await races(3, promise1, promise2, promise3);\n * // => [1, 2, 3]\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 (url: string) => {\n * const response = await fetch(url);\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('https://example.com'), { maxRetries: 3, backoff: retries => retries * 1000, onRetry: logger });\n * // => Will retry 3 times with a 1 second delay between each retry. 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.\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, retry?: 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 }\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 * 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 // eslint-disable-next-line no-control-regex\n return str.replace(/[^\\u0000-\\u007E]/g, (chr: string) =>\n chr.normalize('NFD').replace(/[\\u0300-\\u036F]/g, ''));\n}\n","import { deburr } from '@string/deburr';\n\nexport function splitWords(str: string): string[] {\n str = deburr(str);\n\n // Split non-alphanumeric characters with spaces and deal with camel/PascalCase\n const regex = new RegExp(\n '[^\\\\dA-Za-z]' + // match any character that is not a letter or a digit\n '|' + // or\n '(?<=[a-z])' + // lookbehind for a lowercase letter\n '(?=[A-Z])' + // lookahead for an uppercase letter\n '|' + // or\n '(?<=[A-Z])' + // lookbehind for an uppercase letter\n '(?=[A-Z][a-z])' // lookahead for an uppercase letter followed by a lowercase letter\n );\n\n return str.split(regex).filter(Boolean);\n}\n","import { splitWords } from '@helpers/stringModifiers';\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 const words = splitWords(str);\n\n // Capitalize the first letter of each word\n const camelCase = words.map((word, index) => {\n if (index === 0) {\n return word.toLowerCase();\n }\n return word.charAt(0).toUpperCase() + word.slice(1).toLowerCase();\n });\n\n return camelCase.join('');\n}\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","/**\n * Converts the characters `&`, `<`, `>`, `\"` and `'` in a string to their corresponding HTML entities.\n *\n * @example\n * escapeHtml('fred, barney, & pebbles')\n * // => 'fred, barney, &amp; pebbles'\n * @param str - The string to escape.\n * @returns Returns the escaped string.\n */\n\nexport function escapeHtml(str: string): string {\n const escapeChars: Record<string, string> = {\n '&': '&amp;',\n '<': '&lt;',\n '>': '&gt;',\n '\\'': '&#39;',\n '\"': '&quot;'\n };\n return str.replace(/[\"&'<>]/g, char => escapeChars[char] || char);\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(/[$()*+.?[\\\\\\]^{|}]/g, '\\\\$&');\n}\n","import { splitWords } from '@helpers/stringModifiers';\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 * kebabCase('Héllo World')\n * // => 'hello-world'\n * \n * @param str - The string to convert.\n * @returns Returns the kebab cased string.\n */\n\nexport function kebabCase(str: string): string {\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 '@helpers/stringModifiers';\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 * pascalCase('Héllo World')\n * // => 'HelloWorld'\n * \n * @param str - The string to convert.\n * @returns Returns the pascal cased string.\n */\n\nexport function pascalCase(str: string): string {\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 '@helpers/stringModifiers';\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 * snakeCase('Héllo World')\n * // => 'hello_world'\n * @param str - The string to convert.\n * @returns Returns the snake cased string.\n */\n\nexport function snakeCase(str: string): string {\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 { deburr } from '@string/deburr';\n\n/**\n * Removes all special characters from a string.\n *\n * @example\n * stripSpecial('Héllo! World #$%&*!')\n * // => 'Hello World'\n * @param str - The string to remove special characters from.\n * @returns Returns the string with special characters removed.\n*/\n\nexport function stripSpecial(str: string): string {\n str = deburr(str);\n return str.replace(/[^\\s\\w]/gi, '');\n}\n","import { splitWords } from '@helpers/stringModifiers';\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 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 * Converts the HTML entities `&amp;`, `&lt;`, `&gt;`, `&quot;` and `&#39;`\n * in a string to their corresponding characters.\n *\n * @example\n * unescapeHtml('fred, barney, &amp; 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 const entityMap: Record<string, string> = {\n '&amp;': '&',\n '&lt;': '<',\n '&gt;': '>',\n '&quot;': '\"',\n '&#39;': '\\''\n };\n return str.replace(/&(?:amp|lt|gt|quot|#(0+)?39);/g, (entity: string) => entityMap[entity] || entity);\n}\n","/**\n * Checks if `value` is an empty object, collection, map, or set.\n *\n * Objects are considered empty if they have no own enumerable string keyed\n * properties.\n *\n * Array-like values such as `arguments` objects, arrays, buffers, strings, or\n * Similarly, maps and sets are considered empty if they have a `size` of `0`.\n *\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 given vlaue 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\n if (typeof value === 'string' || Array.isArray(value)) {\n return value.length === 0;\n }\n\n if (value instanceof Map || value instanceof Set) {\n return value.size === 0;\n }\n\n if (typeof value === 'object') {\n return Object.keys(value).length === 0;\n }\n\n return false;\n}\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":";AAeO,SAAS,MAAa,OAAgB,WAA8B;AACvE,QAAM,cAAc,KAAK,MAAM,SAAS;AACxC,MAAI,MAAM,WAAW,KAAK,cAAc,GAAG;AACvC,WAAO,CAAC;AAAA,EACZ;AAEA,QAAM,eAAe,CAAC;AACtB,MAAI,IAAI;AAER,SAAO,IAAI,MAAM,QAAQ;AACrB,iBAAa,KAAK,MAAM,MAAM,GAAG,IAAI,WAAW,CAAC;AACjD,SAAK;AAAA,EACT;AAEA,SAAO;AACX;;;ACRO,SAAS,MAAuC,OAAgB,UAAkE;AACrI,QAAM,SAAS,CAAC;AAChB,aAAW,SAAS,OAAO;AACvB,QAAI,MAAM,SAAS,KAAK;AACxB,QAAI,OAAO,QAAQ;AACf,YAAM,IAAI,SAAS;AAEvB,QAAI,OAAO,GAAG,MAAM;AAChB,aAAO,GAAG,IAAI;AAAA;AAEd,aAAO,GAAG,KAAK;AAAA,EACvB;AACA,SAAO;AACX;;;AClBO,SAAS,cAAc,OAAsC;AAChE,SAAO,OAAO,gBAAgB;AAClC;;;ACSO,SAAS,QAAQ,GAAY,GAAqB;AACrD,MAAI,OAAO,GAAG,GAAG,CAAC;AAAG,WAAO;AAE5B,MAAI,MAAM,QAAQ,CAAC,KAAK,MAAM,QAAQ,CAAC,GAAG;AACtC,WAAO,YAAY,GAAG,CAAC;AAAA,EAC3B;AAEA,MAAI,aAAa,QAAQ,aAAa,MAAM;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;;ACWO,SAAS,QAAQ,OAAoD;AACxE,MAAI,UAAU,QAAQ,UAAU,QAAW;AACvC,WAAO;AAAA,EACX;AAEA,MAAI,OAAO,UAAU,YAAY,MAAM,QAAQ,KAAK,GAAG;AACnD,WAAO,MAAM,WAAW;AAAA,EAC5B;AAEA,MAAI,iBAAiB,OAAO,iBAAiB,KAAK;AAC9C,WAAO,MAAM,SAAS;AAAA,EAC1B;AAEA,MAAI,OAAO,UAAU,UAAU;AAC3B,WAAO,OAAO,KAAK,KAAK,EAAE,WAAW;AAAA,EACzC;AAEA,SAAO;AACX;;;ACrCO,SAAS,MAAM,KAAsB;AACxC,MAAI;AACA,QAAI,IAAI,GAAG;AACX,WAAO;AAAA,EACX,QAAE;AACE,WAAO;AAAA,EACX;AACJ;","names":["difference","intersection","count","count","retries","timeout","camelCase","kebabCase","pascalCase","snakeCase","titleCase"]}
1
+ {"version":3,"sources":["../src/array/chunk.ts","../src/array/count.ts","../src/validate/isPlainObject.ts","../src/validate/isEqual.ts","../src/array/difference.ts","../src/array/dropRightWhile.ts","../src/array/dropWhile.ts","../src/array/group.ts","../src/array/intersection.ts","../src/array/sample.ts","../src/array/shuffle.ts","../src/array/sort.ts","../src/array/takeRightWhile.ts","../src/array/takeWhile.ts","../src/array/unique.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/randomFloat.ts","../src/number/randomInt.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/string/deburr.ts","../src/helpers/stringModifiers.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/stripSpecial.ts","../src/string/titleCase.ts","../src/string/unescapeHtml.ts","../src/validate/isEmpty.ts","../src/validate/isUrl.ts"],"sourcesContent":["/**\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: TElem[], chunkSize: number): TElem[][] {\n const sizeInteger = Math.trunc(chunkSize);\n if (array.length === 0 || sizeInteger < 1) {\n return [];\n }\n\n const chunkedArray = [];\n let i = 0;\n\n while (i < array.length) {\n chunkedArray.push(array.slice(i, i + sizeInteger));\n i += sizeInteger;\n }\n\n return chunkedArray;\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);\n * // => { 'true': 2, 'false': 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: TElem[], criteria: (value: TElem) => TKey | boolean): Record<TKey, number> {\n const result = {} as Record<TKey, number>;\n for (const value of array) {\n let key = criteria(value);\n if (typeof key === 'boolean')\n key = key.toString() as TKey;\n // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition\n if (result[key] === undefined)\n result[key] = 1;\n else\n result[key] += 1;\n }\n return result;\n}\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 './isPlainObject.js';\n\n/**\n * Performs a deep comparison between two values to determine if they are\n * equivalent.\n *\n * **Note:** This method supports comparing arrays, array buffers, booleans,\n * date objects, error objects, maps, numbers, `Object` objects, regexes,\n * sets, strings, symbols, and typed arrays. `Object` objects are compared\n * by their own, not inherited, enumerable properties. Functions and DOM\n * nodes are compared by strict equality, i.e. `===`.\n *\n * @example\n * var object = { 'a': 1 };\n * var other = { 'a': 1 };\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 (Array.isArray(a) && Array.isArray(b)) {\n return isSameArray(a, b);\n }\n\n if (a instanceof Date && b instanceof Date) {\n return a.getTime() === b.getTime();\n }\n\n if (a instanceof RegExp && b instanceof RegExp) {\n return a.toString() === b.toString();\n }\n\n if (isPlainObject(a) && isPlainObject(b)) {\n return isSameObject(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[], b: unknown[]) {\n if (a.length !== b.length) return false;\n\n // check if the values of each element in the arrays are equal\n for (const [i, element] of a.entries()) {\n if (!isEqual(element, b[i])) return false;\n }\n\n return true;\n}\n","import type { ArrayMinLength } from '@type/ArrayMinLength.js';\n\nimport { isEqual } from '@validate/isEqual';\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: {@link isEqual}).\n * @example\n * difference([2, 1], [2, 3])\n * // => [1]\n *\n * // ---- Custom compare function ----\n * difference((a, b) => Math.floor(a) === Math.floor(b), [1.2, 3.1], [1.3, 2.4])\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((a, b) => a.id === b.id, arr1, arr2)\n * // => [{ id: 1, name: 'Yeet' }]\n * @param arrays First array is inspected, others are excluded.\n * @template TElem The type of the array elements.\n * @returns Returns the new array of filtered values.\n */\n\nexport function difference<TElem>(...arrays: ArrayMinLength<TElem[], 2>): TElem[];\nexport function difference<TElem>(arrayOrCompFn: (a: TElem, b: TElem) => boolean, ...arrays: ArrayMinLength<TElem[], 2>): TElem[];\nexport function difference<TElem>(arrayOrCompFn: TElem[] | ((a: TElem, b: TElem) => boolean), ...arrays: ArrayMinLength<TElem[], 2>): TElem[] {\n const withCompareFn = typeof arrayOrCompFn === 'function';\n const compareFN = withCompareFn ? arrayOrCompFn as (a: TElem, b: TElem) => boolean : isEqual;\n\n const [firstArray, ...restArrays] = withCompareFn ? arrays : [arrayOrCompFn, ...arrays];\n const difference: TElem[] = [];\n\n firstArray.forEach(element => {\n if (!restArrays.some(array => array.some(item => compareFN(item, element)))) {\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 falsey.\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, ({ active }) => 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: 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 falsey.\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, ({ active }) => 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: 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)\n * // => { 'false': [4.2], 'true': [6.1, 6.3] }\n * \n * @param collection The array or object to iterate over.\n * @param criteria The criteria to group by.\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: TElem[], criteria: (value: TElem) => TKey | boolean): Record<TKey, TElem[]> {\n const result = {} as Record<TKey, TElem[]>;\n for (const value of array) {\n let key = criteria(value);\n if (typeof key === 'boolean')\n key = key.toString() as TKey;\n // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition\n result[key] = result[key] ?? [];\n result[key].push(value);\n }\n return result;\n}\n","import type { ArrayMinLength } from '@type/ArrayMinLength.js';\n\nimport { isEqual } from '@validate/isEqual';\n\n/**\n * Create an array with unique values from all input arrays, with order based on the first array. \n * \n * Optionally, use a compare function for element comparison (default: {@link isEqual}).\n * @example\n * intersection([2, 1], [2, 3])\n * // => [2]\n *\n * // ---- Custom compare function ----\n * const compareFn = (a, b) => Math.floor(a) === Math.floor(b);\n * \n * intersection(compareFn, [1.2, 1.1], [1.3, 2.4])\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((a, b) => a.id === b.id, arr1, arr2)\n * // => [{ id: 3, name: 'John' }]\n * @param arrays - The arrays to inspect.\n * @returns Returns the new array of intersecting values.\n */\n\nexport function intersection<TArr>(...arrays: ArrayMinLength<TArr[], 2>): TArr[];\nexport function intersection<TArr>(arrayOrCompFn: (a: TArr, b: TArr) => boolean, ...arrays: ArrayMinLength<TArr[], 2>): TArr[];\nexport function intersection<TArr>(arrayOrCompFn: TArr[] | ((a: TArr, b: TArr) => boolean), ...arrays: ArrayMinLength<TArr[], 2>): TArr[] {\n const withCompareFn = typeof arrayOrCompFn === 'function';\n const compareFN = withCompareFn ? arrayOrCompFn as (a: TArr, b: TArr) => boolean : isEqual;\n\n const [firstArray, ...restArrays] = withCompareFn ? arrays : [arrayOrCompFn, ...arrays];\n const intersection: TArr[] = [];\n\n firstArray.forEach(element => {\n if (restArrays.every(array => array.some(item => compareFN(item, element)))) {\n intersection.push(element);\n }\n });\n\n return intersection;\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 * @example\n * sample([1, 2, 3, 4])\n * // => 2\n *\n * sample([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 sample<TArr>(array: TArr[]): TArr | undefined;\nexport function sample<TArr>(array: TArr[], multi: number): TArr[];\nexport function sample<TArr>(array: TArr[], multi?: number): TArr | undefined | TArr[] {\n if (multi === undefined) {\n if (array.length === 0) return undefined;\n return getSingleSample(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] = getSingleSample(array);\n }\n return result;\n}\n\nfunction getSingleSample<TArr>(array: TArr[]): TArr {\n const randomIndex = Math.floor(Math.random() * array.length);\n return array[randomIndex];\n}","/**\n * Creates a new array of shuffled values, using a version of the\n * [Fisher-Yates shuffle](https://en.wikipedia.org/wiki/Fisher-Yates_shuffle).\n *\n * @example\n * shuffle([1, 2, 3, 4])\n * // => [4, 1, 3, 2]\n * @param array - The array or object to shuffle.\n * @returns Returns the new shuffled array.\n */\n\nexport function shuffle<TArr>(array: TArr[]): TArr[] {\n const shuffledArray = [...array];\n let currentIndex = shuffledArray.length;\n let temporaryValue: TArr;\n let randomIndex: number;\n\n // While there remain elements to shuffle...\n while (0 !== currentIndex) {\n // Pick a remaining element...\n randomIndex = Math.floor(Math.random() * currentIndex);\n currentIndex -= 1;\n\n // And swap it with the current element.\n temporaryValue = shuffledArray[currentIndex];\n shuffledArray[currentIndex] = shuffledArray[randomIndex];\n shuffledArray[randomIndex] = temporaryValue;\n }\n\n return shuffledArray;\n}\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 * @returns Returns the sorted array.\n*/\nexport function sort<TInput>(array: TInput[], ...orders: { order?: 'asc' | 'desc', by?: (item: TInput) => number | bigint | Date | string }[]): TInput[] {\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 falsey.\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(({ active }) => active, users)\n * // => objects for ['fred', 'pebbles']\n * @param predicate - The function invoked per iteration.\n * @param array - The array to query.\n * @returns Returns the slice of `array`.\n */\n\nexport function takeRightWhile<TArr>(predicate: (elem: TArr) => boolean, array: TArr[]): TArr[] {\n const result: TArr[] = [];\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 falsey.\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, ({ active }) => active)\n * // => objects for ['barney', 'fred']\n * @param predicate The function invoked per iteration.\n * @param array The array to query.\n * @returns Returns the slice of `array`.\n */\n\nexport function takeWhile<TArr>(array: TArr[], predicate: (elem: TArr) => boolean): TArr[] {\n const result: TArr[] = [];\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 { isEqual } from '@validate/isEqual';\n\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 * An compare function is optinal to specify how the array is compared (default: {@link isEqual}).\n * \n * @example\n * unique([2, 1, 2])\n * // => [2, 1]\n *\n * const users = [\n * { id: 1, name: 'a' },\n * { id: 1, name: 'c' }\n * ]\n *\n * unique(users, (a, b) => a.id === b.id)\n * // => [{ id: 1, name: 'a' }]\n *\n *\n * @param array - The array to inspect.\n * @param iteratee - The iteratee invoked per element.\n * @returns Returns the new duplicate free array.\n */\n\nexport function unique<TInput>(array: TInput[], compareFn = (a: TInput, b: TInput) => isEqual(a, b)): TInput[] {\n return array.filter((value, index, self) => {\n return self.findIndex(otherValue => compareFn(value, otherValue)) === index;\n });\n}\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 * Debouces 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 TypeScript >=5.0 or `experimentalDecorators` flag enabled.*\n * \n * @example\n * ```typescript\n * class TestClass {\n * @decDebounce(1000)\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 TypeScript >=5.0 or `experimentalDecorators` flag enabled.*\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 caches the result of `func`.\n * \n * The cache key is either determined by the provided `resolver` or by the arguments used in the cached function.\n *\n * The `cache` property is exposed on the cached function. It is an instance of `Map` and can be used to clear or inspect the cache. \n * The cache property can be replaced by a custom cache as long as it implements the `Map` interface.\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 * 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 TypeScript >=5.0 or `experimentalDecorators` flag enabled.*\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 TypeScript >=5.0 or `experimentalDecorators` flag enabled.*\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\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 TypeScript >=5.0 or `experimentalDecorators` flag enabled.*\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: 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: 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: 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 * 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) // => 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('min must be less than or equal to max');\n const range = max - min;\n const randomBuffer = new Uint32Array(1);\n crypto.getRandomValues(randomBuffer);\n const random = randomBuffer[0] / 0xFFFFFFFF;\n return min + (random * range);\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) // => 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 if (min > max)\n throw new Error('min must be less than or equal to max');\n const range = max - min + 1;\n const randomBuffer = new Uint32Array(1);\n crypto.getRandomValues(randomBuffer);\n return min + (randomBuffer[0] % range);\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 * @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 * @returns Returns the new object.\n */\n\nexport function pick<TInput extends PlainObject, Key extends keyof TInput>(object: TInput, keysToPick: Key[]): Pick<TInput, Key> {\n const result = {} as Pick<TInput, 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 * @returns - An object without the specified keys\n *\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\n/**\n * Sets the value at path of object. If a portion of path doesn’t exist, it’s created.\n * \n * @alpha\n * @example\n * const obj = { a: { b: 2 } };\n * set(obj, 'a.c', 1);\n * // => { a: { b: 2, c: 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 * @returns The modified object.\n */\n\nexport function set<TObj extends PlainObject>(obj: TObj, path: string, value: unknown): TObj {\n const pathParts = path.split(/[.[\\]]/g).filter(x => Boolean(x.trim()));\n\n let currentObj: Record<string | number, unknown> = obj;\n for (let index = 0; index < pathParts.length; index++) {\n const key = pathParts[index];\n\n if (index === pathParts.length - 1) {\n currentObj[key] = value;\n break;\n }\n \n const nextIsNumber = !Number.isNaN(Number.parseInt(pathParts[index + 1]));\n if (currentObj[key] === undefined)\n currentObj[key] = nextIsNumber ? [] : {};\n\n currentObj = currentObj[key] as Record<string | number, unknown>;\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 aync functions or an array of async functions to the queue.\n * \n * @param asyncFn - The aync 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 promise1 = Promise.resolve(1);\n * const promise2 = Promise.resolve(2);\n * const promise3 = Promise.resolve(3);\n * \n * const firstThree = await races(3, promise1, promise2, promise3);\n * // => [1, 2, 3]\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 (url: string) => {\n * const response = await fetch(url);\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('https://example.com'), { maxRetries: 3, backoff: retries => retries * 1000, onRetry: logger });\n * // => Will retry 3 times with a 1 second delay between each retry. 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.\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, retry?: 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 }\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 * 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 // eslint-disable-next-line no-control-regex\n return str.replace(/[^\\u0000-\\u007E]/g, (chr: string) =>\n chr.normalize('NFD').replace(/[\\u0300-\\u036F]/g, ''));\n}\n","import { deburr } from '@string/deburr';\n\nexport function splitWords(str: string): string[] {\n str = deburr(str);\n\n // Split non-alphanumeric characters with spaces and deal with camel/PascalCase\n const regex = new RegExp(\n '[^\\\\dA-Za-z]' + // match any character that is not a letter or a digit\n '|' + // or\n '(?<=[a-z])' + // lookbehind for a lowercase letter\n '(?=[A-Z])' + // lookahead for an uppercase letter\n '|' + // or\n '(?<=[A-Z])' + // lookbehind for an uppercase letter\n '(?=[A-Z][a-z])' // lookahead for an uppercase letter followed by a lowercase letter\n );\n\n return str.split(regex).filter(Boolean);\n}\n","import { splitWords } from '@helpers/stringModifiers';\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 const words = splitWords(str);\n\n // Capitalize the first letter of each word\n const camelCase = words.map((word, index) => {\n if (index === 0) {\n return word.toLowerCase();\n }\n return word.charAt(0).toUpperCase() + word.slice(1).toLowerCase();\n });\n\n return camelCase.join('');\n}\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","/**\n * Converts the characters `&`, `<`, `>`, `\"` and `'` in a string to their corresponding HTML entities.\n *\n * @example\n * escapeHtml('fred, barney, & pebbles')\n * // => 'fred, barney, &amp; pebbles'\n * @param str - The string to escape.\n * @returns Returns the escaped string.\n */\n\nexport function escapeHtml(str: string): string {\n const escapeChars: Record<string, string> = {\n '&': '&amp;',\n '<': '&lt;',\n '>': '&gt;',\n '\\'': '&#39;',\n '\"': '&quot;'\n };\n return str.replace(/[\"&'<>]/g, char => escapeChars[char] || char);\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(/[$()*+.?[\\\\\\]^{|}]/g, '\\\\$&');\n}\n","import { splitWords } from '@helpers/stringModifiers';\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 * kebabCase('Héllo World')\n * // => 'hello-world'\n * \n * @param str - The string to convert.\n * @returns Returns the kebab cased string.\n */\n\nexport function kebabCase(str: string): string {\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 '@helpers/stringModifiers';\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 * pascalCase('Héllo World')\n * // => 'HelloWorld'\n * \n * @param str - The string to convert.\n * @returns Returns the pascal cased string.\n */\n\nexport function pascalCase(str: string): string {\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 '@helpers/stringModifiers';\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 * snakeCase('Héllo World')\n * // => 'hello_world'\n * @param str - The string to convert.\n * @returns Returns the snake cased string.\n */\n\nexport function snakeCase(str: string): string {\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 { deburr } from '@string/deburr';\n\n/**\n * Removes all special characters from a string.\n *\n * @example\n * stripSpecial('Héllo! World #$%&*!')\n * // => 'Hello World'\n * @param str - The string to remove special characters from.\n * @returns Returns the string with special characters removed.\n*/\n\nexport function stripSpecial(str: string): string {\n str = deburr(str);\n return str.replace(/[^\\s\\w]/gi, '');\n}\n","import { splitWords } from '@helpers/stringModifiers';\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 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 * Converts the HTML entities `&amp;`, `&lt;`, `&gt;`, `&quot;` and `&#39;`\n * in a string to their corresponding characters.\n *\n * @example\n * unescapeHtml('fred, barney, &amp; 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 const entityMap: Record<string, string> = {\n '&amp;': '&',\n '&lt;': '<',\n '&gt;': '>',\n '&quot;': '\"',\n '&#39;': '\\''\n };\n return str.replace(/&(?:amp|lt|gt|quot|#(0+)?39);/g, (entity: string) => entityMap[entity] || entity);\n}\n","/**\n * Checks if `value` is an empty object, collection, map, or set.\n *\n * Objects are considered empty if they have no own enumerable string keyed\n * properties.\n *\n * Array-like values such as `arguments` objects, arrays, buffers, strings, or\n * Similarly, maps and sets are considered empty if they have a `size` of `0`.\n *\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 given vlaue 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\n if (typeof value === 'string' || Array.isArray(value)) {\n return value.length === 0;\n }\n\n if (value instanceof Map || value instanceof Set) {\n return value.size === 0;\n }\n\n if (typeof value === 'object') {\n return Object.keys(value).length === 0;\n }\n\n return false;\n}\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":";AAeO,SAAS,MAAa,OAAgB,WAA8B;AACvE,QAAM,cAAc,KAAK,MAAM,SAAS;AACxC,MAAI,MAAM,WAAW,KAAK,cAAc,GAAG;AACvC,WAAO,C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AAA,EACX,QAAE;AACE,WAAO;AAAA,EACX;AACJ;","names":["difference","intersection","count","count","retries","timeout","camelCase","kebabCase","pascalCase","snakeCase","titleCase"]}
package/package.json CHANGED
@@ -55,5 +55,5 @@
55
55
  "tsup": "6.6.0",
56
56
  "ctix": "1.8.2"
57
57
  },
58
- "version": "0.12.8"
58
+ "version": "0.13.1"
59
59
  }