moderndash 0.6.0 → 0.6.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 +1 -5
- package/dist/index.cjs +61 -8
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +57 -80
- package/dist/index.js +59 -8
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -33,8 +33,4 @@ npm install moderndash
|
|
|
33
33
|
|
|
34
34
|
## Why is X lodash function not included?
|
|
35
35
|
Please check [You-Dont-Need-Lodash](https://github.com/you-dont-need/You-Dont-Need-Lodash-Underscore) for native replacements.
|
|
36
|
-
If you still think a function is missing please open an issue.
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
## Thank you
|
|
40
|
-
- [type-fest](https://github.com/sindresorhus/type-fest) for the numeric types
|
|
36
|
+
If you still think a function is missing please open an issue.
|
package/dist/index.cjs
CHANGED
|
@@ -47,6 +47,8 @@ __export(src_exports, {
|
|
|
47
47
|
once: () => once,
|
|
48
48
|
pascalCase: () => pascalCase,
|
|
49
49
|
pick: () => pick,
|
|
50
|
+
races: () => races,
|
|
51
|
+
retry: () => retry,
|
|
50
52
|
sample: () => sample,
|
|
51
53
|
shuffle: () => shuffle,
|
|
52
54
|
sleep: () => sleep,
|
|
@@ -94,17 +96,20 @@ function count(array, iteratee) {
|
|
|
94
96
|
}
|
|
95
97
|
|
|
96
98
|
// src/validate/isEqual.ts
|
|
97
|
-
function isEqual(
|
|
98
|
-
if (
|
|
99
|
+
function isEqual(a, b) {
|
|
100
|
+
if (Object.is(a, b))
|
|
99
101
|
return true;
|
|
100
|
-
if (
|
|
101
|
-
return
|
|
102
|
+
if (a instanceof Date && b instanceof Date) {
|
|
103
|
+
return a.getTime() === b.getTime();
|
|
102
104
|
}
|
|
103
|
-
if (
|
|
104
|
-
return
|
|
105
|
+
if (Array.isArray(a) && Array.isArray(b)) {
|
|
106
|
+
return isSameArray(a, b);
|
|
105
107
|
}
|
|
106
|
-
if (
|
|
107
|
-
return
|
|
108
|
+
if (a instanceof RegExp && b instanceof RegExp) {
|
|
109
|
+
return a.toString() === b.toString();
|
|
110
|
+
}
|
|
111
|
+
if (isObject(a) && isObject(b)) {
|
|
112
|
+
return isSameObject(a, b);
|
|
108
113
|
}
|
|
109
114
|
return false;
|
|
110
115
|
}
|
|
@@ -497,11 +502,57 @@ var Queue = class {
|
|
|
497
502
|
}
|
|
498
503
|
};
|
|
499
504
|
|
|
505
|
+
// src/promise/races.ts
|
|
506
|
+
function races(waitFor, ...promises) {
|
|
507
|
+
return new Promise((resolve, reject) => {
|
|
508
|
+
if (promises.length < waitFor)
|
|
509
|
+
waitFor = promises.length;
|
|
510
|
+
const results = [];
|
|
511
|
+
let resolved = 0;
|
|
512
|
+
for (const promise of promises) {
|
|
513
|
+
promise.then((value) => {
|
|
514
|
+
results.push(value);
|
|
515
|
+
resolved++;
|
|
516
|
+
if (resolved >= waitFor) {
|
|
517
|
+
resolve(results);
|
|
518
|
+
}
|
|
519
|
+
}).catch((error) => {
|
|
520
|
+
reject(error);
|
|
521
|
+
});
|
|
522
|
+
}
|
|
523
|
+
});
|
|
524
|
+
}
|
|
525
|
+
|
|
500
526
|
// src/promise/sleep.ts
|
|
501
527
|
function sleep(ms) {
|
|
502
528
|
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
503
529
|
}
|
|
504
530
|
|
|
531
|
+
// src/promise/retry.ts
|
|
532
|
+
async function retry(func, options) {
|
|
533
|
+
const backOffFn = options?.backoff ?? ((retries2) => 2 ** retries2 * 100);
|
|
534
|
+
const maxRetries = options?.maxRetries ?? 5;
|
|
535
|
+
const onRetry = options?.onRetry ?? (() => {
|
|
536
|
+
});
|
|
537
|
+
let retries = 0;
|
|
538
|
+
let lastError;
|
|
539
|
+
while (retries <= maxRetries) {
|
|
540
|
+
try {
|
|
541
|
+
if (retries > 0)
|
|
542
|
+
onRetry(lastError, retries);
|
|
543
|
+
return await func();
|
|
544
|
+
} catch (error) {
|
|
545
|
+
lastError = error;
|
|
546
|
+
retries++;
|
|
547
|
+
if (retries > maxRetries) {
|
|
548
|
+
throw error;
|
|
549
|
+
}
|
|
550
|
+
await sleep(backOffFn(retries));
|
|
551
|
+
}
|
|
552
|
+
}
|
|
553
|
+
throw new Error("Retry terminated without success, this should never happen");
|
|
554
|
+
}
|
|
555
|
+
|
|
505
556
|
// src/promise/timeout.ts
|
|
506
557
|
function timeout(promise, timeout2) {
|
|
507
558
|
return new Promise((resolve, reject) => {
|
|
@@ -700,6 +751,8 @@ function isUrl(str) {
|
|
|
700
751
|
once,
|
|
701
752
|
pascalCase,
|
|
702
753
|
pick,
|
|
754
|
+
races,
|
|
755
|
+
retry,
|
|
703
756
|
sample,
|
|
704
757
|
shuffle,
|
|
705
758
|
sleep,
|
package/dist/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts","../src/array/chunk.ts","../src/array/count.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/function/after.ts","../src/function/before.ts","../src/function/debounce.ts","../src/function/memoize.ts","../src/function/once.ts","../src/function/throttle.ts","../src/function/times.ts","../src/object/pick.ts","../src/object/omit.ts","../src/promise/queue.ts","../src/promise/sleep.ts","../src/promise/timeout.ts","../src/string/deburr.ts","../src/helpers/stringModifiers.ts","../src/string/camelCase.ts","../src/string/capitalize.ts","../src/string/dashCase.ts","../src/string/escapeHtml.ts","../src/string/escapeRegExp.ts","../src/string/kebabCase.ts","../src/string/pascalCase.ts","../src/string/snakeCase.ts","../src/string/startCase.ts","../src/string/stripSpecial.ts","../src/string/unescapeHtml.ts","../src/validate/isEmpty.ts","../src/validate/isPlainObject.ts","../src/validate/isUrl.ts"],"sourcesContent":["export * from './array';\nexport * from './function';\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 * @category Array\n * @returns Returns the new array of chunks.\n * @param chunkSize - The array to process.\n * @param array - The length of each chunk\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 */\n\nexport function chunk<TInput>(array: TInput[], chunkSize: number): TInput[][] {\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","import type { RecordKey } from '@helpers/types';\n\n/**\n * Creates an object composed of keys generated from the results of running \n * each element of `collection` thru `iteratee`. \n * The corresponding value of each key is the number of times the key was returned by `iteratee`.\n *\n * @example\n * const users = [\n * { 'user': 'barney', 'active': true },\n * { 'user': 'betty', 'active': true },\n * { 'user': 'fred', 'active': false }\n * ]\n *\n * count(users, value => value.active);\n * // => { 'true': 2, 'false': 1 }\n * @category Array\n * @param iteratee - The iteratee to transform keys.\n * @param collection - The array or record to iterate over.\n * @returns Returns the composed aggregate object.\n */\n\nexport function count<TInput, TKey extends RecordKey>(array: TInput[], iteratee: (value: TInput) => TKey): Record<TKey, number> {\n const result = {} as Record<TKey, number>;\n for (const value of array) {\n const key = iteratee(value);\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 }\n return result;\n}\n","import type { RecordKey } from '@helpers/types';\n\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 * @category Validate\n * @param value1 - The value to compare.\n * @param value2 - The other value to compare.\n * @returns Returns `true` if the values are equivalent, else `false`.\n */\n\nexport function isEqual(value1: unknown, value2: unknown): boolean {\n if (value1 === value2) return true;\n\n if (Array.isArray(value1) && Array.isArray(value2)) {\n return isSameArray(value1, value2);\n }\n\n if (value1 instanceof RegExp && value2 instanceof RegExp) {\n return value1.toString() === value2.toString();\n }\n\n if (isObject(value1) && isObject(value2)) {\n return isSameObject(value1, value2);\n }\n\n return false;\n}\n\ntype KeyValueObject = Record<RecordKey, unknown>;\nfunction isObject(value: unknown): value is KeyValueObject {\n return typeof value === 'object'\n && value !== null\n && !Array.isArray(value)\n && Object.prototype.toString.call(value) === '[object Object]';\n}\n\nfunction isSameObject(value1: KeyValueObject, value2: KeyValueObject) {\n // check if the objects have the same keys\n const keys1 = Object.keys(value1);\n const keys2 = Object.keys(value2);\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(value1[key], value2[key])) return false;\n }\n\n // the objects are deeply equal\n return true;\n}\n\nfunction isSameArray(value1: unknown[], value2: unknown[]) {\n if (value1.length !== value2.length) return false;\n\n // check if the values of each element in the arrays are equal\n for (const [i, element] of value1.entries()) {\n if (!isEqual(element, value2[i])) return false;\n }\n\n return true;\n}\n","import type { MinimumTwoArrays } from '@helpers/types';\n\nimport { isEqual } from '@validate/isEqual';\n\n/**\n * Creates an array values not included in the other given arrays. \n * The order and references of result values are determined by the first array.\n *\n * An compare function is optinal to specify how the elements of the arrays are compared. \n * Default compare function is {@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 * @category Array\n * @param arrays - First array is inspected, others are excluded.\n * @returns Returns the new array of filtered values.\n */\n\nexport function difference<TArr>(...arrays: MinimumTwoArrays<TArr>): TArr[];\nexport function difference<TArr>(arrayOrCompFn: (a: TArr, b: TArr) => boolean, ...arrays: MinimumTwoArrays<TArr>): TArr[];\nexport function difference<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 difference: TArr[] = [];\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 * @category Array\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 dropRightWhile<TArr>(array: TArr[], predicate: (value: TArr) => 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 * @category Array\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 dropWhile<TArr>(array: TArr[], predicate: (value: TArr) => boolean): TArr[] {\n const index = array.findIndex(x => !predicate(x));\n return array.slice(index === -1 ? array.length : index);\n}\n","import type { RecordKey } from '@helpers/types';\n\n/**\n * Creates an object composed of keys generated from the results of running\n * each element of `collection` thru `iteratee`. The order of grouped values\n * is determined by the order they occur in `collection`. The corresponding\n * value of each key is an array of elements responsible for generating the\n * key.\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 * @category Array\n * @param collection - The array or object to iterate over.\n * @param iteratee - The iteratee to transform keys.\n * @returns Returns the composed aggregate object.\n */\n\nexport function group<T, U extends RecordKey>(array: T[], iteratee: (value: T) => U): Record<U, T[]> {\n const result = {} as Record<U, T[]>;\n for (const value of array) {\n const key = iteratee(value);\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 '@helpers/types';\n\nimport { isEqual } from '@validate/isEqual';\n\n/**\n * Creates an array of unique values that are included in all given arrays. \n * The order and references of result values are determined by the first array.\n *\n * An compare function is optinal to specify how the elements of the arrays are compared. \n * Default compare function is {@link isEqual}.\n * @example\n * intersection([2, 1], [2, 3])\n * // => [2]\n *\n * // ---- Custom compare function ----\n * intersection((a, b) => Math.floor(a) === Math.floor(b), [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 * @category Array\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 * @category Array\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 * @category Array\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. \n * An iteratee function is optional to sort the array based on a specific property.\n *\n * @example\n * sort([1, 2, 3, 4], 'desc')\n * // => [4, 3, 2, 1]\n *\n * sort([{ a: 1 }, { a: 2 }, { a: 3 }], 'asc', item => item.a)\n * // => [{ a: 1 }, { a: 2 }, { a: 3 }]\n * @category Array\n * @param array - The array to sort.\n * @param order - The order in which to sort the array.\n * @param iteratee - The iteratee function to sort the array based on a specific property.\n * @returns Returns the sorted array.\n */\n\nexport function sort<TInput>(array: TInput[], order?: 'asc' | 'desc', iteratee?: (item: TInput) => number | bigint | Date | string): TInput[] {\n return [...array].sort((a, b) => {\n const aValue = iteratee ? iteratee(a) : a;\n const bValue = iteratee ? iteratee(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 return 0;\n });\n}\n","/**\n * Creates a slice of `array` with elements taken from the end. \n * Elements are taken until `predicate` returns falsey.\n *\n * @returns Returns the slice of `array`.\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 * @category Array\n * @param predicate - The function invoked per iteration.\n * @param array - The array to query.\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 * @category Array\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.\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 * @category Array\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 '@helpers/types.js';\n\n/**\n * The opposite of `before`. This method creates a function that invokes `func` once it's called `n` or more times.\n *\n * @example\n * const caution = () => console.log(\"Caution!\");\n * const afterFN = after(2, caution);\n *\n * afterFN()\n * afterFN()\n * afterFN()\n * // => `caution` is invoked after called twice\n * @category Function\n * @param n The number of calls before `func` is invoked.\n * @param func The function to restrict.\n * @returns Returns the new restricted function.\n */\n\nexport function after<TFunc extends GenericFunction<TFunc>>(n: number, func: TFunc) {\n let count = 1;\n return (...args: Parameters<TFunc>): ReturnType<TFunc> | undefined => {\n if (count >= n) {\n return func(...args);\n }\n count += 1;\n };\n}\n","import type { GenericFunction } from '@helpers/types.js';\n\n/**\n * Creates a function that invokes `func`, while it's called less than `n` times. Subsequent\n * calls to the created function return the result of the last `func` invocation.\n *\n * @category Function\n * @param n - The number of calls at which `func` is no longer invoked.\n * @param func - The function to restrict.\n * @returns Returns the new restricted function.\n * @example\n * const caution = () => console.log(\"Caution!\");\n *\n * // Only call caution two times\n * const reducedCaution = before(2, caution)\n *\n * reducedCaution()\n * reducedCaution()\n * reducedCaution()\n * // => `caution` is invoked twice\n */\n\nexport function before<TFunc extends GenericFunction<TFunc>>(n: number, func: TFunc): TFunc {\n let count = 0;\n let result: ReturnType<TFunc>;\n return ((...args: Parameters<TFunc>): ReturnType<TFunc> => {\n if (count < n) {\n count += 1;\n result = func(...args);\n }\n return result;\n }) as TFunc;\n}\n","import type { GenericFunction } from '@helpers/types.js';\n\n// TODO this is a port from lodash, it probably can be improved and shortened, also fix TS errors\nexport function debounce<TFunc extends GenericFunction<TFunc>>(\n fn: TFunc, wait = 0, options: { leading?: boolean, maxWait?: number, trailing?: boolean } = {}\n): (this: ThisParameterType<TFunc>, ...args: Parameters<TFunc>) => ReturnType<TFunc> {\n let lastArgs: Parameters<TFunc> | undefined;\n let lastThis: ThisParameterType<TFunc> | undefined;\n let result: ReturnType<TFunc>;\n let timerId: ReturnType<typeof setTimeout> | undefined;\n let lastCallTime: number | undefined;\n let lastInvokeTime = 0;\n const maxing = options.maxWait ?? false;\n const leading = options.leading ?? false;\n const trailing = options.trailing ?? true;\n const maxWait = options.maxWait ?? 0;\n\n function invokeFunc(time: number) {\n const args: Parameters<TFunc> | undefined = lastArgs;\n const thisArg: ThisParameterType<TFunc> | undefined = lastThis;\n\n lastArgs = lastThis = undefined;\n lastInvokeTime = time;\n // @ts-expect-error\n result = fn.apply(thisArg, args);\n return result;\n }\n\n function leadingEdge(time: number) {\n // Reset any `maxWait` timer.\n lastInvokeTime = time;\n // Start the timer for the trailing edge.\n timerId = setTimeout(timerExpired, wait);\n // Invoke the leading edge.\n return leading ? invokeFunc(time) : result;\n }\n\n function remainingWait(time: number) {\n // @ts-expect-error\n const timeSinceLastCall = time - lastCallTime;\n const timeSinceLastInvoke = time - lastInvokeTime;\n const timeWaiting = wait - timeSinceLastCall;\n\n return maxing\n ? Math.min(timeWaiting, maxWait - timeSinceLastInvoke)\n : timeWaiting;\n }\n\n function shouldInvoke(time: number) {\n if (lastCallTime === undefined)\n return true;\n\n const timeSinceLastCall = time - lastCallTime;\n const timeSinceLastInvoke = time - lastInvokeTime;\n\n // Either this is the first call, activity has stopped and we're at the\n // trailing edge, the system time has gone backwards and we're treating\n // it as the trailing edge, or we've hit the `maxWait` limit.\n return timeSinceLastCall >= wait || timeSinceLastCall < 0 || (maxing && timeSinceLastInvoke >= maxWait);\n }\n\n function timerExpired() {\n const time = Date.now();\n if (shouldInvoke(time)) {\n return trailingEdge(time);\n }\n // Restart the timer.\n timerId = setTimeout(timerExpired, remainingWait(time));\n }\n\n function trailingEdge(time: number) {\n timerId = undefined;\n\n // Only invoke if we have `lastArgs` which means `fn` has been\n // debounced at least once.\n if (trailing && lastArgs) {\n return invokeFunc(time);\n }\n lastArgs = lastThis = undefined;\n return result;\n }\n\n function cancel() {\n if (timerId !== undefined) {\n clearTimeout(timerId);\n }\n lastInvokeTime = 0;\n lastArgs = lastCallTime = lastThis = timerId = undefined;\n }\n\n function flush() {\n return timerId === undefined ? result : trailingEdge(Date.now());\n }\n\n function debounced(this: ThisParameterType<TFunc>, ...args: Parameters<TFunc>): ReturnType<TFunc> {\n const time = Date.now();\n const isInvoking = shouldInvoke(time);\n\n lastArgs = args;\n // TODO Fix this assignment\n // eslint-disable-next-line @typescript-eslint/no-this-alias,unicorn/no-this-assignment\n lastThis = this;\n lastCallTime = time;\n\n if (isInvoking) {\n if (timerId === undefined) {\n return leadingEdge(lastCallTime);\n }\n if (maxing) {\n // Handle invocations in a tight loop.\n clearTimeout(timerId);\n timerId = setTimeout(timerExpired, wait);\n return invokeFunc(lastCallTime);\n }\n }\n if (timerId === undefined) {\n timerId = setTimeout(timerExpired, wait);\n }\n return result;\n }\n\n debounced.cancel = cancel;\n debounced.flush = flush;\n return debounced;\n}\n","import type{ GenericFunction } from '@helpers/types.js';\n\nconst defaultResolver = (...args: unknown[]) => JSON.stringify(args);\n\n/**\n * Creates a function that memoizes the result of `func`. If `resolver` is\n * provided, it determines the cache key for storing the result based on the\n * arguments provided to the memoized function. By default, all arguments\n * provided to the memoized function are used as the map cache key.\n *\n * The cache is exposed as the `cache` property on the memoized\n * function. Its creation may be customized by replacing the `memoize.Cache`\n * constructor with one whose instances implement the\n * [`Map`](http://ecma-international.org/ecma-262/7.0/#sec-properties-of-the-map-prototype-object)\n * method interface of `clear`, `delete`, `get`, `has`, and `set`.\n *\n * @example\n * const object = \\{ 'a': 1, 'b': 2 \\}\n *\n * const values = memoize(values)\n * values(object)\n * // => [1, 2]\n *\n * values(object)\n * // => [1, 2]\n *\n * object.a = 2\n * values(object)\n * // => [2, 2]\n *\n * // Modify the result cache.\n * values.cache.set(object, ['a', 'b'])\n * values(object)\n * // => ['a', 'b']\n *\n * // Replace `memoize.Cache`.\n * memoize.Cache = WeakMap\n * @category Function\n * @param func - The function to have its output memoized.\n * @param resolver - The function to resolve the cache key.\n * @returns Returns the new memoized function.\n */\n\nexport function memoize<TFunc extends GenericFunction<TFunc>, Cache extends Map<string | symbol, ReturnType<TFunc>>>(\n func: TFunc, resolver: ((...args: Parameters<TFunc>) => string | symbol) = defaultResolver\n): TFunc & { cache: Cache } {\n\n const cache = new Map() as Cache;\n const memoizedFunc = (...args: Parameters<TFunc>): ReturnType<TFunc> => {\n const key = resolver(...args);\n if (cache.has(key)) {\n // eslint-disable-next-line @typescript-eslint/non-nullable-type-assertion-style\n return cache.get(key) as ReturnType<TFunc>;\n }\n const result = func(...args);\n cache.set(key, result);\n return result;\n };\n memoizedFunc.cache = cache;\n return memoizedFunc as TFunc & { cache: Cache };\n}\n","import type { GenericFunction } from '@helpers/types.js';\n\nimport { before } from '@function/before';\n\n/**\n * Creates a function that is restricted to invoking `func` once.\n * Repeat calls to the function return the value of the first invocation.\n *\n * @example\n * const initialize = once(() => console.log('initialize'))\n * initialize()\n * initialize()\n * // => `createApplication` is invoked once\n *\n * @category Function\n * @param func - The function to restrict.\n * @returns Returns the new restricted function.\n */\n\nexport function once<TFunc extends GenericFunction<TFunc>>(func: TFunc): TFunc {\n return before(1, func);\n}\n","import type { GenericFunction } from '@helpers/types.js';\n\nimport { debounce } from '@function/debounce';\n\nexport function throttle<TFunc extends GenericFunction<TFunc>>(\n func: TFunc, wait = 0, options: { leading?: boolean, trailing?: boolean } = {}\n): (this: ThisParameterType<TFunc>, ...args: Parameters<TFunc>) => ReturnType<TFunc> {\n return debounce(func, wait, {\n leading: options.leading ?? true,\n maxWait: wait,\n trailing: options.trailing ?? true\n });\n}\n","/**\n * Invokes a function `n` times, returning an array of the results of\n * each invocation.\n *\n * The function is invoked with one argument: `index`\n *\n * @example\n * times(3, index => console.log(\"Run\", index)))\n * // => \"Run 0\" | \"Run 1\" | \"Run 2\"\n * times(3, Math.random)\n * // => [0.123, 0.456, 0.789]\n * times(4, () => 0)\n * // => [0, 0, 0, 0]\n * @category Function\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>(n: number, func: (index: number) => TInput): TInput[] {\n const result: TInput[] = [];\n for (let i = 0; i < n; i++) {\n result.push(func(i));\n }\n return result;\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 * @category Object\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, 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 { 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 object, 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}","/**\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 * ---\n * \n * **Methods:**\n * - {@link Queue.add} - adds a async function or array of functions to the queue. \n * Returns a promise that resolves when the added function(s) finish.\n * - {@link Queue.clear} - clears the queue.\n * - {@link Queue.pause} - pauses the queue.\n * - {@link Queue.resume} - resumes the queue. \n * - {@link Queue.getQueue} - returns the queue.\n * - {@link Queue.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 functions in 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 /** Returns 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 * 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}","/**\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 * @category String\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 * @category String\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 * @category String\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","import { splitWords } from '@helpers/stringModifiers.js';\n\n/**\n * Converts a string to dash-case.\n *\n * @example\n * dashCase('Foo Bar')\n * // => 'foo-bar'\n * dashCase('fooBar')\n * // => 'foo-bar'\n * dashCase('__FOO_BAR__')\n * // => 'foo-bar'\n * @category String\n * @param str - The string to convert.\n * @returns Returns the dash cased string.\n */\n\nexport function dashCase(str: string): string {\n const words = splitWords(str);\n\n let dashCase = '';\n for (const word of words) {\n dashCase += word.toLowerCase() + '-';\n }\n return dashCase.slice(0, -1);\n}","/**\n * Converts the characters `&`, `<`, `>`, `\"` and `'` in a string to their corresponding HTML entities.\n *\n * @example\n * escape('fred, barney, & pebbles')\n * // => 'fred, barney, & pebbles'\n * @category String\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 '&': '&',\n '<': '<',\n '>': '>',\n '\\'': ''',\n '\"': '"'\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 * @category String\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 * @category String\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 * @category String\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 * @category String\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 { splitWords } from '@helpers/stringModifiers';\n\n/**\n * Converts a string to Start Case.\n *\n * @example\n * startCase('--foo-bar--')\n * // => 'Foo Bar'\n * startCase('fooBar')\n * // => 'Foo Bar'\n * startCase('__FOO_BAR__')\n * // => 'Foo Bar'\n * @category String\n * @param str - The string to convert.\n * @returns Returns the start cased string.\n */\n\nexport function startCase(str: string): string {\n const words = splitWords(str);\n let startCase = '';\n for (const word of words) {\n startCase += word.charAt(0).toUpperCase() + word.slice(1).toLowerCase() + ' ';\n }\n return startCase.trimEnd();\n}\n","import { deburr } from '@string/deburr';\n\n/**\n * Removes all special characters from a string.\n *\n * @example\n * stripSpecialChars('Héllo! World #$%&*!')\n * // => 'Hello World'\n * @category String\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","/**\n * Converts the HTML entities `&`, `<`, `>`, `"` and `'`\n * in a string to their corresponding characters.\n *\n * @example\n * unescape('fred, barney, & pebbles')\n * // => 'fred, barney, & pebbles'\n * @category String\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 '&': '&',\n '<': '<',\n '>': '>',\n '"': '\"',\n ''': '\\''\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 * @category Validate\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","export function isPlainObject(value: unknown): value is object {\n return value !== null && typeof value === 'object' && value.constructor === Object;\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;AAA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QAAQ,kCAAkC,CAAC,WAAmB,UAAU,WAAW,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;;;AClDO,SAAS,cAAc,OAAiC;AAC3D,SAAO,UAAU,QAAQ,OAAO,UAAU,YAAY,MAAM,gBAAgB;AAChF;;;ACUO,SAAS,MAAM,KAAsB;AACxC,MAAI;AACA,QAAI,IAAI,GAAG;AACX,WAAO;AAAA,EACX,QAAE;AACE,WAAO;AAAA,EACX;AACJ;","names":["difference","intersection","count","count","timeout","camelCase","dashCase","kebabCase","pascalCase","snakeCase","startCase"]}
|
|
1
|
+
{"version":3,"sources":["../src/index.ts","../src/array/chunk.ts","../src/array/count.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/function/after.ts","../src/function/before.ts","../src/function/debounce.ts","../src/function/memoize.ts","../src/function/once.ts","../src/function/throttle.ts","../src/function/times.ts","../src/object/pick.ts","../src/object/omit.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/dashCase.ts","../src/string/escapeHtml.ts","../src/string/escapeRegExp.ts","../src/string/kebabCase.ts","../src/string/pascalCase.ts","../src/string/snakeCase.ts","../src/string/startCase.ts","../src/string/stripSpecial.ts","../src/string/unescapeHtml.ts","../src/validate/isEmpty.ts","../src/validate/isPlainObject.ts","../src/validate/isUrl.ts"],"sourcesContent":["export * from './array';\nexport * from './function';\nexport * from './object';\nexport * from './promise';\nexport * from './string';\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 * @category Array\n * @returns Returns the new array of chunks.\n * @param chunkSize - The array to process.\n * @param array - The length of each chunk\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 */\n\nexport function chunk<TInput>(array: TInput[], chunkSize: number): TInput[][] {\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","import type { RecordKey } from '@helpers/types';\n\n/**\n * Creates an object composed of keys generated from the results of running \n * each element of `collection` thru `iteratee`. \n * The corresponding value of each key is the number of times the key was returned by `iteratee`.\n *\n * @example\n * const users = [\n * { 'user': 'barney', 'active': true },\n * { 'user': 'betty', 'active': true },\n * { 'user': 'fred', 'active': false }\n * ]\n *\n * count(users, value => value.active);\n * // => { 'true': 2, 'false': 1 }\n * @category Array\n * @param iteratee - The iteratee to transform keys.\n * @param collection - The array or record to iterate over.\n * @returns Returns the composed aggregate object.\n */\n\nexport function count<TInput, TKey extends RecordKey>(array: TInput[], iteratee: (value: TInput) => TKey): Record<TKey, number> {\n const result = {} as Record<TKey, number>;\n for (const value of array) {\n const key = iteratee(value);\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 }\n return result;\n}\n","import type { RecordKey } from '@helpers/types';\n\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 * @category Validate\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 (a instanceof Date && b instanceof Date) {\n return a.getTime() === b.getTime();\n }\n\n if (Array.isArray(a) && Array.isArray(b)) {\n return isSameArray(a, b);\n }\n\n if (a instanceof RegExp && b instanceof RegExp) {\n return a.toString() === b.toString();\n }\n\n if (isObject(a) && isObject(b)) {\n return isSameObject(a, b);\n }\n\n return false;\n}\n\ntype KeyValueObject = Record<RecordKey, unknown>;\nfunction isObject(value: unknown): value is KeyValueObject {\n return typeof value === 'object'\n && value !== null\n && !Array.isArray(value)\n && Object.prototype.toString.call(value) === '[object Object]';\n}\n\nfunction isSameObject(value1: KeyValueObject, value2: KeyValueObject) {\n // check if the objects have the same keys\n const keys1 = Object.keys(value1);\n const keys2 = Object.keys(value2);\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(value1[key], value2[key])) return false;\n }\n\n // the objects are deeply equal\n return true;\n}\n\nfunction isSameArray(value1: unknown[], value2: unknown[]) {\n if (value1.length !== value2.length) return false;\n\n // check if the values of each element in the arrays are equal\n for (const [i, element] of value1.entries()) {\n if (!isEqual(element, value2[i])) return false;\n }\n\n return true;\n}\n","import type { MinimumTwoArrays } from '@helpers/types';\n\nimport { isEqual } from '@validate/isEqual';\n\n/**\n * Creates an array values not included in the other given arrays. \n * The order and references of result values are determined by the first array.\n *\n * An compare function is optinal to specify how the elements of the arrays are compared. \n * Default compare function is {@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 * @category Array\n * @param arrays - First array is inspected, others are excluded.\n * @returns Returns the new array of filtered values.\n */\n\nexport function difference<TArr>(...arrays: MinimumTwoArrays<TArr>): TArr[];\nexport function difference<TArr>(arrayOrCompFn: (a: TArr, b: TArr) => boolean, ...arrays: MinimumTwoArrays<TArr>): TArr[];\nexport function difference<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 difference: TArr[] = [];\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 * @category Array\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 dropRightWhile<TArr>(array: TArr[], predicate: (value: TArr) => 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 * @category Array\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 dropWhile<TArr>(array: TArr[], predicate: (value: TArr) => boolean): TArr[] {\n const index = array.findIndex(x => !predicate(x));\n return array.slice(index === -1 ? array.length : index);\n}\n","import type { RecordKey } from '@helpers/types';\n\n/**\n * Creates an object composed of keys generated from the results of running\n * each element of `collection` thru `iteratee`. The order of grouped values\n * is determined by the order they occur in `collection`. The corresponding\n * value of each key is an array of elements responsible for generating the\n * key.\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 * @category Array\n * @param collection - The array or object to iterate over.\n * @param iteratee - The iteratee to transform keys.\n * @returns Returns the composed aggregate object.\n */\n\nexport function group<T, U extends RecordKey>(array: T[], iteratee: (value: T) => U): Record<U, T[]> {\n const result = {} as Record<U, T[]>;\n for (const value of array) {\n const key = iteratee(value);\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 '@helpers/types';\n\nimport { isEqual } from '@validate/isEqual';\n\n/**\n * Creates an array of unique values that are included in all given arrays. \n * The order and references of result values are determined by the first array.\n *\n * An compare function is optinal to specify how the elements of the arrays are compared. \n * Default compare function is {@link isEqual}.\n * @example\n * intersection([2, 1], [2, 3])\n * // => [2]\n *\n * // ---- Custom compare function ----\n * intersection((a, b) => Math.floor(a) === Math.floor(b), [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 * @category Array\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 * @category Array\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 * @category Array\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. \n * An iteratee function is optional to sort the array based on a specific property.\n *\n * @example\n * sort([1, 2, 3, 4], 'desc')\n * // => [4, 3, 2, 1]\n *\n * sort([{ a: 1 }, { a: 2 }, { a: 3 }], 'asc', item => item.a)\n * // => [{ a: 1 }, { a: 2 }, { a: 3 }]\n * @category Array\n * @param array - The array to sort.\n * @param order - The order in which to sort the array.\n * @param iteratee - The iteratee function to sort the array based on a specific property.\n * @returns Returns the sorted array.\n */\n\nexport function sort<TInput>(array: TInput[], order?: 'asc' | 'desc', iteratee?: (item: TInput) => number | bigint | Date | string): TInput[] {\n return [...array].sort((a, b) => {\n const aValue = iteratee ? iteratee(a) : a;\n const bValue = iteratee ? iteratee(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 return 0;\n });\n}\n","/**\n * Creates a slice of `array` with elements taken from the end. \n * Elements are taken until `predicate` returns falsey.\n *\n * @returns Returns the slice of `array`.\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 * @category Array\n * @param predicate - The function invoked per iteration.\n * @param array - The array to query.\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 * @category Array\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.\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 * @category Array\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 '@helpers/types.js';\n\n/**\n * The opposite of `before`. This method creates a function that invokes `func` once it's called `n` or more times.\n *\n * @example\n * const caution = () => console.log(\"Caution!\");\n * const afterFN = after(2, caution);\n *\n * afterFN()\n * afterFN()\n * afterFN()\n * // => `caution` is invoked after called twice\n * @category Function\n * @param n The number of calls before `func` is invoked.\n * @param func The function to restrict.\n * @returns Returns the new restricted function.\n */\n\nexport function after<TFunc extends GenericFunction<TFunc>>(n: number, func: TFunc) {\n let count = 1;\n return (...args: Parameters<TFunc>): ReturnType<TFunc> | undefined => {\n if (count >= n) {\n return func(...args);\n }\n count += 1;\n };\n}\n","import type { GenericFunction } from '@helpers/types.js';\n\n/**\n * Creates a function that invokes `func`, while it's called less than `n` times. Subsequent\n * calls to the created function return the result of the last `func` invocation.\n *\n * @category Function\n * @param n - The number of calls at which `func` is no longer invoked.\n * @param func - The function to restrict.\n * @returns Returns the new restricted function.\n * @example\n * const caution = () => console.log(\"Caution!\");\n *\n * // Only call caution two times\n * const reducedCaution = before(2, caution)\n *\n * reducedCaution()\n * reducedCaution()\n * reducedCaution()\n * // => `caution` is invoked twice\n */\n\nexport function before<TFunc extends GenericFunction<TFunc>>(n: number, func: TFunc): TFunc {\n let count = 0;\n let result: ReturnType<TFunc>;\n return ((...args: Parameters<TFunc>): ReturnType<TFunc> => {\n if (count < n) {\n count += 1;\n result = func(...args);\n }\n return result;\n }) as TFunc;\n}\n","import type { GenericFunction } from '@helpers/types.js';\n\n// TODO this is a port from lodash, it probably can be improved and shortened, also fix TS errors\nexport function debounce<TFunc extends GenericFunction<TFunc>>(\n fn: TFunc, wait = 0, options: { leading?: boolean, maxWait?: number, trailing?: boolean } = {}\n): (this: ThisParameterType<TFunc>, ...args: Parameters<TFunc>) => ReturnType<TFunc> {\n let lastArgs: Parameters<TFunc> | undefined;\n let lastThis: ThisParameterType<TFunc> | undefined;\n let result: ReturnType<TFunc>;\n let timerId: ReturnType<typeof setTimeout> | undefined;\n let lastCallTime: number | undefined;\n let lastInvokeTime = 0;\n const maxing = options.maxWait ?? false;\n const leading = options.leading ?? false;\n const trailing = options.trailing ?? true;\n const maxWait = options.maxWait ?? 0;\n\n function invokeFunc(time: number) {\n const args: Parameters<TFunc> | undefined = lastArgs;\n const thisArg: ThisParameterType<TFunc> | undefined = lastThis;\n\n lastArgs = lastThis = undefined;\n lastInvokeTime = time;\n // @ts-expect-error\n result = fn.apply(thisArg, args);\n return result;\n }\n\n function leadingEdge(time: number) {\n // Reset any `maxWait` timer.\n lastInvokeTime = time;\n // Start the timer for the trailing edge.\n timerId = setTimeout(timerExpired, wait);\n // Invoke the leading edge.\n return leading ? invokeFunc(time) : result;\n }\n\n function remainingWait(time: number) {\n // @ts-expect-error\n const timeSinceLastCall = time - lastCallTime;\n const timeSinceLastInvoke = time - lastInvokeTime;\n const timeWaiting = wait - timeSinceLastCall;\n\n return maxing\n ? Math.min(timeWaiting, maxWait - timeSinceLastInvoke)\n : timeWaiting;\n }\n\n function shouldInvoke(time: number) {\n if (lastCallTime === undefined)\n return true;\n\n const timeSinceLastCall = time - lastCallTime;\n const timeSinceLastInvoke = time - lastInvokeTime;\n\n // Either this is the first call, activity has stopped and we're at the\n // trailing edge, the system time has gone backwards and we're treating\n // it as the trailing edge, or we've hit the `maxWait` limit.\n return timeSinceLastCall >= wait || timeSinceLastCall < 0 || (maxing && timeSinceLastInvoke >= maxWait);\n }\n\n function timerExpired() {\n const time = Date.now();\n if (shouldInvoke(time)) {\n return trailingEdge(time);\n }\n // Restart the timer.\n timerId = setTimeout(timerExpired, remainingWait(time));\n }\n\n function trailingEdge(time: number) {\n timerId = undefined;\n\n // Only invoke if we have `lastArgs` which means `fn` has been\n // debounced at least once.\n if (trailing && lastArgs) {\n return invokeFunc(time);\n }\n lastArgs = lastThis = undefined;\n return result;\n }\n\n function cancel() {\n if (timerId !== undefined) {\n clearTimeout(timerId);\n }\n lastInvokeTime = 0;\n lastArgs = lastCallTime = lastThis = timerId = undefined;\n }\n\n function flush() {\n return timerId === undefined ? result : trailingEdge(Date.now());\n }\n\n function debounced(this: ThisParameterType<TFunc>, ...args: Parameters<TFunc>): ReturnType<TFunc> {\n const time = Date.now();\n const isInvoking = shouldInvoke(time);\n\n lastArgs = args;\n // TODO Fix this assignment\n // eslint-disable-next-line @typescript-eslint/no-this-alias,unicorn/no-this-assignment\n lastThis = this;\n lastCallTime = time;\n\n if (isInvoking) {\n if (timerId === undefined) {\n return leadingEdge(lastCallTime);\n }\n if (maxing) {\n // Handle invocations in a tight loop.\n clearTimeout(timerId);\n timerId = setTimeout(timerExpired, wait);\n return invokeFunc(lastCallTime);\n }\n }\n if (timerId === undefined) {\n timerId = setTimeout(timerExpired, wait);\n }\n return result;\n }\n\n debounced.cancel = cancel;\n debounced.flush = flush;\n return debounced;\n}\n","import type{ GenericFunction } from '@helpers/types.js';\n\nconst defaultResolver = (...args: unknown[]) => JSON.stringify(args);\n\n/**\n * Creates a function that memoizes the result of `func`. If `resolver` is\n * provided, it determines the cache key for storing the result based on the\n * arguments provided to the memoized function. By default, all arguments\n * provided to the memoized function are used as the map cache key.\n *\n * The cache is exposed as the `cache` property on the memoized\n * function. Its creation may be customized by replacing the `memoize.Cache`\n * constructor with one whose instances implement the\n * [`Map`](http://ecma-international.org/ecma-262/7.0/#sec-properties-of-the-map-prototype-object)\n * method interface of `clear`, `delete`, `get`, `has`, and `set`.\n *\n * @example\n * const object = \\{ 'a': 1, 'b': 2 \\}\n *\n * const values = memoize(values)\n * values(object)\n * // => [1, 2]\n *\n * values(object)\n * // => [1, 2]\n *\n * object.a = 2\n * values(object)\n * // => [2, 2]\n *\n * // Modify the result cache.\n * values.cache.set(object, ['a', 'b'])\n * values(object)\n * // => ['a', 'b']\n *\n * // Replace `memoize.Cache`.\n * memoize.Cache = WeakMap\n * @category Function\n * @param func - The function to have its output memoized.\n * @param resolver - The function to resolve the cache key.\n * @returns Returns the new memoized function.\n */\n\nexport function memoize<TFunc extends GenericFunction<TFunc>, Cache extends Map<string | symbol, ReturnType<TFunc>>>(\n func: TFunc, resolver: ((...args: Parameters<TFunc>) => string | symbol) = defaultResolver\n): TFunc & { cache: Cache } {\n\n const cache = new Map() as Cache;\n const memoizedFunc = (...args: Parameters<TFunc>): ReturnType<TFunc> => {\n const key = resolver(...args);\n if (cache.has(key)) {\n // eslint-disable-next-line @typescript-eslint/non-nullable-type-assertion-style\n return cache.get(key) as ReturnType<TFunc>;\n }\n const result = func(...args);\n cache.set(key, result);\n return result;\n };\n memoizedFunc.cache = cache;\n return memoizedFunc as TFunc & { cache: Cache };\n}\n","import type { GenericFunction } from '@helpers/types.js';\n\nimport { before } from '@function/before';\n\n/**\n * Creates a function that is restricted to invoking `func` once.\n * Repeat calls to the function return the value of the first invocation.\n *\n * @example\n * const initialize = once(() => console.log('initialize'))\n * initialize()\n * initialize()\n * // => `createApplication` is invoked once\n *\n * @category Function\n * @param func - The function to restrict.\n * @returns Returns the new restricted function.\n */\n\nexport function once<TFunc extends GenericFunction<TFunc>>(func: TFunc): TFunc {\n return before(1, func);\n}\n","import type { GenericFunction } from '@helpers/types.js';\n\nimport { debounce } from '@function/debounce';\n\nexport function throttle<TFunc extends GenericFunction<TFunc>>(\n func: TFunc, wait = 0, options: { leading?: boolean, trailing?: boolean } = {}\n): (this: ThisParameterType<TFunc>, ...args: Parameters<TFunc>) => ReturnType<TFunc> {\n return debounce(func, wait, {\n leading: options.leading ?? true,\n maxWait: wait,\n trailing: options.trailing ?? true\n });\n}\n","/**\n * Invokes a function `n` times, returning an array of the results of\n * each invocation.\n *\n * The function is invoked with one argument: `index`\n *\n * @example\n * times(3, index => console.log(\"Run\", index)))\n * // => \"Run 0\" | \"Run 1\" | \"Run 2\"\n * times(3, Math.random)\n * // => [0.123, 0.456, 0.789]\n * times(4, () => 0)\n * // => [0, 0, 0, 0]\n * @category Function\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>(n: number, func: (index: number) => TInput): TInput[] {\n const result: TInput[] = [];\n for (let i = 0; i < n; i++) {\n result.push(func(i));\n }\n return result;\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 * @category Object\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, 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 { 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 object, 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}","/**\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 * ---\n * \n * **Methods:**\n * - {@link Queue.add} - adds a async function or array of functions to the queue. \n * Returns a promise that resolves when the added function(s) finish.\n * - {@link Queue.clear} - clears the queue.\n * - {@link Queue.pause} - pauses the queue.\n * - {@link Queue.resume} - resumes the queue. \n * - {@link Queue.getQueue} - returns the queue.\n * - {@link Queue.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 functions in 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 /** Returns 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 promise2 = 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 * response.ok || 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 * @category String\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 * @category String\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 * @category String\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","import { splitWords } from '@helpers/stringModifiers.js';\n\n/**\n * Converts a string to dash-case.\n *\n * @example\n * dashCase('Foo Bar')\n * // => 'foo-bar'\n * dashCase('fooBar')\n * // => 'foo-bar'\n * dashCase('__FOO_BAR__')\n * // => 'foo-bar'\n * @category String\n * @param str - The string to convert.\n * @returns Returns the dash cased string.\n */\n\nexport function dashCase(str: string): string {\n const words = splitWords(str);\n\n let dashCase = '';\n for (const word of words) {\n dashCase += word.toLowerCase() + '-';\n }\n return dashCase.slice(0, -1);\n}","/**\n * Converts the characters `&`, `<`, `>`, `\"` and `'` in a string to their corresponding HTML entities.\n *\n * @example\n * escape('fred, barney, & pebbles')\n * // => 'fred, barney, & pebbles'\n * @category String\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 '&': '&',\n '<': '<',\n '>': '>',\n '\\'': ''',\n '\"': '"'\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 * @category String\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 * @category String\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 * @category String\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 * @category String\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 { splitWords } from '@helpers/stringModifiers';\n\n/**\n * Converts a string to Start Case.\n *\n * @example\n * startCase('--foo-bar--')\n * // => 'Foo Bar'\n * startCase('fooBar')\n * // => 'Foo Bar'\n * startCase('__FOO_BAR__')\n * // => 'Foo Bar'\n * @category String\n * @param str - The string to convert.\n * @returns Returns the start cased string.\n */\n\nexport function startCase(str: string): string {\n const words = splitWords(str);\n let startCase = '';\n for (const word of words) {\n startCase += word.charAt(0).toUpperCase() + word.slice(1).toLowerCase() + ' ';\n }\n return startCase.trimEnd();\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 * @category String\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","/**\n * Converts the HTML entities `&`, `<`, `>`, `"` and `'`\n * in a string to their corresponding characters.\n *\n * @example\n * unescape('fred, barney, & pebbles')\n * // => 'fred, barney, & pebbles'\n * @category String\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 '&': '&',\n '<': '<',\n '>': '>',\n '"': '\"',\n ''': '\\''\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 * @category Validate\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","export function isPlainObject(value: unknown): value is object {\n return value !== null && typeof value === 'object' && value.constructor === Object;\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;;;ACeO,SAAS,MAAc,OAAiB,WAA+B;AAC1E,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,MAAsC,OAAiB,UAAyD;AAC5H,QAAM,SAAS,CAAC;AAChB,aAAW,SAAS,OAAO;AACvB,UAAM,MAAM,SAAS,KAAK;AAE1B,QAAI,OAAO,SAAS,QAAW;AAC3B,aAAO,OAAO;AAAA,IAClB,OAAO;AACH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AIC,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;;;ACXO,SAAS,aAAa,KAAqB;AAC9C,QAAM,OAAO,GAAG;AAChB,SAAO,IAAI,QAAQ,aAAa,EAAE;AACtC;;;ACJO,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,WAAW,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;;;AClDO,SAAS,cAAc,OAAiC;AAC3D,SAAO,UAAU,QAAQ,OAAO,UAAU,YAAY,MAAM,gBAAgB;AAChF;;;ACUO,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","dashCase","kebabCase","pascalCase","snakeCase","startCase"]}
|
package/dist/index.d.ts
CHANGED
|
@@ -498,6 +498,58 @@ declare class Queue {
|
|
|
498
498
|
isPaused(): boolean;
|
|
499
499
|
}
|
|
500
500
|
|
|
501
|
+
/**
|
|
502
|
+
* Similar to [Promise.race](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise/race?retiredLocale=de)
|
|
503
|
+
* but allows to specify how many promises to wait for.
|
|
504
|
+
*
|
|
505
|
+
* @example
|
|
506
|
+
* const promise1 = Promise.resolve(1);
|
|
507
|
+
* const promise2 = Promise.resolve(2);
|
|
508
|
+
* const promise2 = Promise.resolve(3);
|
|
509
|
+
*
|
|
510
|
+
* const firstThree = await races(3, promise1, promise2, promise3);
|
|
511
|
+
* // => [1, 2, 3]
|
|
512
|
+
* @template TRes - The type of the result of the promises.
|
|
513
|
+
* @param waitFor - The number of promises to wait for.
|
|
514
|
+
* @param promises - The promises to wait for.
|
|
515
|
+
* @returns A promise that resolves an array of the results of the first n promises.
|
|
516
|
+
*/
|
|
517
|
+
declare function races<TRes>(waitFor: number, ...promises: Promise<TRes>[]): Promise<TRes[]>;
|
|
518
|
+
|
|
519
|
+
/**
|
|
520
|
+
* Retry a function until it succeeds or the maximum number of retries is reached.
|
|
521
|
+
*
|
|
522
|
+
* Default maxRetries: `5`.
|
|
523
|
+
* Default backoff: `2^retries * 100ms` (100, 200, 400, 800, 1600, 3200, ...)
|
|
524
|
+
*
|
|
525
|
+
* @example
|
|
526
|
+
* await retry(() => fetch('https://example.com'));
|
|
527
|
+
*
|
|
528
|
+
* // ---- Advanced example ----
|
|
529
|
+
* const fetchSite = async (url: string) => {
|
|
530
|
+
* const response = await fetch(url);
|
|
531
|
+
* response.ok || throw new Error('Failed to fetch');
|
|
532
|
+
* }
|
|
533
|
+
*
|
|
534
|
+
* const logger = (error: unknown, retry?: number) => console.log("Retrying", retry, error);
|
|
535
|
+
*
|
|
536
|
+
* await retry(() => fetchSite('https://example.com'), { maxRetries: 3, backoff: retries => retries * 1000, onRetry: logger }));
|
|
537
|
+
* // => Will retry 3 times with a 1 second delay between each retry. Will log the error and retry number.
|
|
538
|
+
*
|
|
539
|
+
* @param func The function to retry.
|
|
540
|
+
* @param options The options for the retry.
|
|
541
|
+
* @param options.maxRetries The maximum number of retries. Defaults to `5`.
|
|
542
|
+
* @param options.backoff The backoff function to use. Defaults to `2^retries * 100`.
|
|
543
|
+
* @param options.onRetry The function to call when a retry is attempted.
|
|
544
|
+
* @template TRes The type of the result of the function.
|
|
545
|
+
* @returns A promise that resolves when the function succeeds.
|
|
546
|
+
*/
|
|
547
|
+
declare function retry<TRes>(func: () => Promise<TRes>, options?: {
|
|
548
|
+
maxRetries?: number;
|
|
549
|
+
backoff?: ((retries: number) => number);
|
|
550
|
+
onRetry: (error?: unknown, retry?: number) => void;
|
|
551
|
+
}): Promise<TRes>;
|
|
552
|
+
|
|
501
553
|
/**
|
|
502
554
|
* Sleeps for the given amount of time.
|
|
503
555
|
*
|
|
@@ -682,7 +734,7 @@ declare function startCase(str: string): string;
|
|
|
682
734
|
* Removes all special characters from a string.
|
|
683
735
|
*
|
|
684
736
|
* @example
|
|
685
|
-
*
|
|
737
|
+
* stripSpecial('Héllo! World #$%&*!')
|
|
686
738
|
* // => 'Hello World'
|
|
687
739
|
* @category String
|
|
688
740
|
* @param str - The string to remove special characters from.
|
|
@@ -703,81 +755,6 @@ declare function stripSpecial(str: string): string;
|
|
|
703
755
|
*/
|
|
704
756
|
declare function unescapeHtml(str: string): string;
|
|
705
757
|
|
|
706
|
-
/**
|
|
707
|
-
* A `number` that is an integer.
|
|
708
|
-
* You can't pass a `bigint` as they are already guaranteed to be integers.
|
|
709
|
-
*
|
|
710
|
-
* Use-case: Validating and documenting parameters. Other usage is limited.
|
|
711
|
-
*
|
|
712
|
-
* *Note: Check this [writeup](https://github.com/sindresorhus/type-fest/issues/334#issuecomment-987787840) for more details.*
|
|
713
|
-
* @example
|
|
714
|
-
* function setYear<T extends number>(x: Integer<T>){};
|
|
715
|
-
*
|
|
716
|
-
* setYear(1); // OK
|
|
717
|
-
* setYear(1.1); // Error
|
|
718
|
-
* @category type
|
|
719
|
-
*/
|
|
720
|
-
type Int<T extends number> = `${T}` extends `${bigint}` ? T : never;
|
|
721
|
-
|
|
722
|
-
/**
|
|
723
|
-
* A `number` that is not an integer.
|
|
724
|
-
* You can't pass a `bigint` as they are already guaranteed to be integers.
|
|
725
|
-
*
|
|
726
|
-
* Use-case: Validating and documenting parameters. Other usage is limited.
|
|
727
|
-
*
|
|
728
|
-
* *Note: Check this [writeup](https://github.com/sindresorhus/type-fest/issues/334#issuecomment-987787840) for more details.*
|
|
729
|
-
* @example
|
|
730
|
-
* function setPercentage<T extends number>(x: Float<T>) {};
|
|
731
|
-
*
|
|
732
|
-
* setPercentage(1.1); // OK
|
|
733
|
-
* setPercentage(1); // Error
|
|
734
|
-
* @category type
|
|
735
|
-
*/
|
|
736
|
-
type Float<T extends number> = T extends Int<T> ? never : T;
|
|
737
|
-
|
|
738
|
-
/**
|
|
739
|
-
* A negative `number`/`bigint` (`-∞ < x < 0`)
|
|
740
|
-
*
|
|
741
|
-
* Use-case: Validating and documenting parameters. Other usage is limited.
|
|
742
|
-
*
|
|
743
|
-
* *Note: Check this [writeup](https://github.com/sindresorhus/type-fest/issues/334#issuecomment-987787840) for more details.*
|
|
744
|
-
* @example
|
|
745
|
-
* function setNegative<T extends number>(x: Negative<T>) {};
|
|
746
|
-
*
|
|
747
|
-
* setNegative(-1.2); // OK
|
|
748
|
-
* setNegative(1); // Error
|
|
749
|
-
*
|
|
750
|
-
* function setNegInt<T extends number>(x: Negative<Int<T>>) {};
|
|
751
|
-
*
|
|
752
|
-
* setNegInt(-1); // OK
|
|
753
|
-
* setNegInt(1); // Error
|
|
754
|
-
* setNegInt(-1.1); // Error
|
|
755
|
-
* @category type
|
|
756
|
-
*/
|
|
757
|
-
type Negative<T extends number | bigint> = T extends 0 | 0n ? never : `${T}` extends `-${string}` ? T : never;
|
|
758
|
-
|
|
759
|
-
/**
|
|
760
|
-
* A positive `number`/`bigint` (`0 < x < ∞`).
|
|
761
|
-
*
|
|
762
|
-
* Use-case: Validating and documenting parameters. Other usage is limited.
|
|
763
|
-
*
|
|
764
|
-
* *Note: Check this [writeup](https://github.com/sindresorhus/type-fest/issues/334#issuecomment-987787840) for more details.*
|
|
765
|
-
* @example
|
|
766
|
-
* function setPositive<T extends number>(x: Positive<T>) {};
|
|
767
|
-
*
|
|
768
|
-
* setPositive(1.2); // OK
|
|
769
|
-
* setPositive(-1); // Error
|
|
770
|
-
*
|
|
771
|
-
* function setPosInt<T extends number>(x: Positive<Int<T>>) {};
|
|
772
|
-
*
|
|
773
|
-
* setPosInt(1); // OK
|
|
774
|
-
* setPosInt(-1); // Error
|
|
775
|
-
* setPosInt(1.1); // Error
|
|
776
|
-
*
|
|
777
|
-
* @category type
|
|
778
|
-
*/
|
|
779
|
-
type Positive<T extends number | bigint> = T extends 0 | 0n ? never : Negative<T> extends never ? T : never;
|
|
780
|
-
|
|
781
758
|
/**
|
|
782
759
|
* Checks if `value` is an empty object, collection, map, or set.
|
|
783
760
|
*
|
|
@@ -831,11 +808,11 @@ declare function isEmpty(value: string | object | null | undefined): boolean;
|
|
|
831
808
|
* object === other;
|
|
832
809
|
* // => false
|
|
833
810
|
* @category Validate
|
|
834
|
-
* @param
|
|
835
|
-
* @param
|
|
811
|
+
* @param a - The value to compare.
|
|
812
|
+
* @param b - The other value to compare.
|
|
836
813
|
* @returns Returns `true` if the values are equivalent, else `false`.
|
|
837
814
|
*/
|
|
838
|
-
declare function isEqual(
|
|
815
|
+
declare function isEqual(a: unknown, b: unknown): boolean;
|
|
839
816
|
|
|
840
817
|
declare function isPlainObject(value: unknown): value is object;
|
|
841
818
|
|
|
@@ -852,4 +829,4 @@ declare function isPlainObject(value: unknown): value is object;
|
|
|
852
829
|
*/
|
|
853
830
|
declare function isUrl(str: string): boolean;
|
|
854
831
|
|
|
855
|
-
export {
|
|
832
|
+
export { Queue, after, before, camelCase, capitalize, chunk, count, dashCase, debounce, deburr, difference, dropRightWhile, dropWhile, escapeHtml, escapeRegExp, group, intersection, isEmpty, isEqual, isPlainObject, isUrl, kebabCase, memoize, omit, once, pascalCase, pick, races, retry, sample, shuffle, sleep, snakeCase, sort, startCase, stripSpecial, takeRightWhile, takeWhile, throttle, timeout, times, unescapeHtml, unique };
|
package/dist/index.js
CHANGED
|
@@ -28,17 +28,20 @@ function count(array, iteratee) {
|
|
|
28
28
|
}
|
|
29
29
|
|
|
30
30
|
// src/validate/isEqual.ts
|
|
31
|
-
function isEqual(
|
|
32
|
-
if (
|
|
31
|
+
function isEqual(a, b) {
|
|
32
|
+
if (Object.is(a, b))
|
|
33
33
|
return true;
|
|
34
|
-
if (
|
|
35
|
-
return
|
|
34
|
+
if (a instanceof Date && b instanceof Date) {
|
|
35
|
+
return a.getTime() === b.getTime();
|
|
36
36
|
}
|
|
37
|
-
if (
|
|
38
|
-
return
|
|
37
|
+
if (Array.isArray(a) && Array.isArray(b)) {
|
|
38
|
+
return isSameArray(a, b);
|
|
39
39
|
}
|
|
40
|
-
if (
|
|
41
|
-
return
|
|
40
|
+
if (a instanceof RegExp && b instanceof RegExp) {
|
|
41
|
+
return a.toString() === b.toString();
|
|
42
|
+
}
|
|
43
|
+
if (isObject(a) && isObject(b)) {
|
|
44
|
+
return isSameObject(a, b);
|
|
42
45
|
}
|
|
43
46
|
return false;
|
|
44
47
|
}
|
|
@@ -431,11 +434,57 @@ var Queue = class {
|
|
|
431
434
|
}
|
|
432
435
|
};
|
|
433
436
|
|
|
437
|
+
// src/promise/races.ts
|
|
438
|
+
function races(waitFor, ...promises) {
|
|
439
|
+
return new Promise((resolve, reject) => {
|
|
440
|
+
if (promises.length < waitFor)
|
|
441
|
+
waitFor = promises.length;
|
|
442
|
+
const results = [];
|
|
443
|
+
let resolved = 0;
|
|
444
|
+
for (const promise of promises) {
|
|
445
|
+
promise.then((value) => {
|
|
446
|
+
results.push(value);
|
|
447
|
+
resolved++;
|
|
448
|
+
if (resolved >= waitFor) {
|
|
449
|
+
resolve(results);
|
|
450
|
+
}
|
|
451
|
+
}).catch((error) => {
|
|
452
|
+
reject(error);
|
|
453
|
+
});
|
|
454
|
+
}
|
|
455
|
+
});
|
|
456
|
+
}
|
|
457
|
+
|
|
434
458
|
// src/promise/sleep.ts
|
|
435
459
|
function sleep(ms) {
|
|
436
460
|
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
437
461
|
}
|
|
438
462
|
|
|
463
|
+
// src/promise/retry.ts
|
|
464
|
+
async function retry(func, options) {
|
|
465
|
+
const backOffFn = options?.backoff ?? ((retries2) => 2 ** retries2 * 100);
|
|
466
|
+
const maxRetries = options?.maxRetries ?? 5;
|
|
467
|
+
const onRetry = options?.onRetry ?? (() => {
|
|
468
|
+
});
|
|
469
|
+
let retries = 0;
|
|
470
|
+
let lastError;
|
|
471
|
+
while (retries <= maxRetries) {
|
|
472
|
+
try {
|
|
473
|
+
if (retries > 0)
|
|
474
|
+
onRetry(lastError, retries);
|
|
475
|
+
return await func();
|
|
476
|
+
} catch (error) {
|
|
477
|
+
lastError = error;
|
|
478
|
+
retries++;
|
|
479
|
+
if (retries > maxRetries) {
|
|
480
|
+
throw error;
|
|
481
|
+
}
|
|
482
|
+
await sleep(backOffFn(retries));
|
|
483
|
+
}
|
|
484
|
+
}
|
|
485
|
+
throw new Error("Retry terminated without success, this should never happen");
|
|
486
|
+
}
|
|
487
|
+
|
|
439
488
|
// src/promise/timeout.ts
|
|
440
489
|
function timeout(promise, timeout2) {
|
|
441
490
|
return new Promise((resolve, reject) => {
|
|
@@ -633,6 +682,8 @@ export {
|
|
|
633
682
|
once,
|
|
634
683
|
pascalCase,
|
|
635
684
|
pick,
|
|
685
|
+
races,
|
|
686
|
+
retry,
|
|
636
687
|
sample,
|
|
637
688
|
shuffle,
|
|
638
689
|
sleep,
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/array/chunk.ts","../src/array/count.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/function/after.ts","../src/function/before.ts","../src/function/debounce.ts","../src/function/memoize.ts","../src/function/once.ts","../src/function/throttle.ts","../src/function/times.ts","../src/object/pick.ts","../src/object/omit.ts","../src/promise/queue.ts","../src/promise/sleep.ts","../src/promise/timeout.ts","../src/string/deburr.ts","../src/helpers/stringModifiers.ts","../src/string/camelCase.ts","../src/string/capitalize.ts","../src/string/dashCase.ts","../src/string/escapeHtml.ts","../src/string/escapeRegExp.ts","../src/string/kebabCase.ts","../src/string/pascalCase.ts","../src/string/snakeCase.ts","../src/string/startCase.ts","../src/string/stripSpecial.ts","../src/string/unescapeHtml.ts","../src/validate/isEmpty.ts","../src/validate/isPlainObject.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 * @category Array\n * @returns Returns the new array of chunks.\n * @param chunkSize - The array to process.\n * @param array - The length of each chunk\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 */\n\nexport function chunk<TInput>(array: TInput[], chunkSize: number): TInput[][] {\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","import type { RecordKey } from '@helpers/types';\n\n/**\n * Creates an object composed of keys generated from the results of running \n * each element of `collection` thru `iteratee`. \n * The corresponding value of each key is the number of times the key was returned by `iteratee`.\n *\n * @example\n * const users = [\n * { 'user': 'barney', 'active': true },\n * { 'user': 'betty', 'active': true },\n * { 'user': 'fred', 'active': false }\n * ]\n *\n * count(users, value => value.active);\n * // => { 'true': 2, 'false': 1 }\n * @category Array\n * @param iteratee - The iteratee to transform keys.\n * @param collection - The array or record to iterate over.\n * @returns Returns the composed aggregate object.\n */\n\nexport function count<TInput, TKey extends RecordKey>(array: TInput[], iteratee: (value: TInput) => TKey): Record<TKey, number> {\n const result = {} as Record<TKey, number>;\n for (const value of array) {\n const key = iteratee(value);\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 }\n return result;\n}\n","import type { RecordKey } from '@helpers/types';\n\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 * @category Validate\n * @param value1 - The value to compare.\n * @param value2 - The other value to compare.\n * @returns Returns `true` if the values are equivalent, else `false`.\n */\n\nexport function isEqual(value1: unknown, value2: unknown): boolean {\n if (value1 === value2) return true;\n\n if (Array.isArray(value1) && Array.isArray(value2)) {\n return isSameArray(value1, value2);\n }\n\n if (value1 instanceof RegExp && value2 instanceof RegExp) {\n return value1.toString() === value2.toString();\n }\n\n if (isObject(value1) && isObject(value2)) {\n return isSameObject(value1, value2);\n }\n\n return false;\n}\n\ntype KeyValueObject = Record<RecordKey, unknown>;\nfunction isObject(value: unknown): value is KeyValueObject {\n return typeof value === 'object'\n && value !== null\n && !Array.isArray(value)\n && Object.prototype.toString.call(value) === '[object Object]';\n}\n\nfunction isSameObject(value1: KeyValueObject, value2: KeyValueObject) {\n // check if the objects have the same keys\n const keys1 = Object.keys(value1);\n const keys2 = Object.keys(value2);\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(value1[key], value2[key])) return false;\n }\n\n // the objects are deeply equal\n return true;\n}\n\nfunction isSameArray(value1: unknown[], value2: unknown[]) {\n if (value1.length !== value2.length) return false;\n\n // check if the values of each element in the arrays are equal\n for (const [i, element] of value1.entries()) {\n if (!isEqual(element, value2[i])) return false;\n }\n\n return true;\n}\n","import type { MinimumTwoArrays } from '@helpers/types';\n\nimport { isEqual } from '@validate/isEqual';\n\n/**\n * Creates an array values not included in the other given arrays. \n * The order and references of result values are determined by the first array.\n *\n * An compare function is optinal to specify how the elements of the arrays are compared. \n * Default compare function is {@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 * @category Array\n * @param arrays - First array is inspected, others are excluded.\n * @returns Returns the new array of filtered values.\n */\n\nexport function difference<TArr>(...arrays: MinimumTwoArrays<TArr>): TArr[];\nexport function difference<TArr>(arrayOrCompFn: (a: TArr, b: TArr) => boolean, ...arrays: MinimumTwoArrays<TArr>): TArr[];\nexport function difference<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 difference: TArr[] = [];\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 * @category Array\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 dropRightWhile<TArr>(array: TArr[], predicate: (value: TArr) => 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 * @category Array\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 dropWhile<TArr>(array: TArr[], predicate: (value: TArr) => boolean): TArr[] {\n const index = array.findIndex(x => !predicate(x));\n return array.slice(index === -1 ? array.length : index);\n}\n","import type { RecordKey } from '@helpers/types';\n\n/**\n * Creates an object composed of keys generated from the results of running\n * each element of `collection` thru `iteratee`. The order of grouped values\n * is determined by the order they occur in `collection`. The corresponding\n * value of each key is an array of elements responsible for generating the\n * key.\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 * @category Array\n * @param collection - The array or object to iterate over.\n * @param iteratee - The iteratee to transform keys.\n * @returns Returns the composed aggregate object.\n */\n\nexport function group<T, U extends RecordKey>(array: T[], iteratee: (value: T) => U): Record<U, T[]> {\n const result = {} as Record<U, T[]>;\n for (const value of array) {\n const key = iteratee(value);\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 '@helpers/types';\n\nimport { isEqual } from '@validate/isEqual';\n\n/**\n * Creates an array of unique values that are included in all given arrays. \n * The order and references of result values are determined by the first array.\n *\n * An compare function is optinal to specify how the elements of the arrays are compared. \n * Default compare function is {@link isEqual}.\n * @example\n * intersection([2, 1], [2, 3])\n * // => [2]\n *\n * // ---- Custom compare function ----\n * intersection((a, b) => Math.floor(a) === Math.floor(b), [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 * @category Array\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 * @category Array\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 * @category Array\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. \n * An iteratee function is optional to sort the array based on a specific property.\n *\n * @example\n * sort([1, 2, 3, 4], 'desc')\n * // => [4, 3, 2, 1]\n *\n * sort([{ a: 1 }, { a: 2 }, { a: 3 }], 'asc', item => item.a)\n * // => [{ a: 1 }, { a: 2 }, { a: 3 }]\n * @category Array\n * @param array - The array to sort.\n * @param order - The order in which to sort the array.\n * @param iteratee - The iteratee function to sort the array based on a specific property.\n * @returns Returns the sorted array.\n */\n\nexport function sort<TInput>(array: TInput[], order?: 'asc' | 'desc', iteratee?: (item: TInput) => number | bigint | Date | string): TInput[] {\n return [...array].sort((a, b) => {\n const aValue = iteratee ? iteratee(a) : a;\n const bValue = iteratee ? iteratee(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 return 0;\n });\n}\n","/**\n * Creates a slice of `array` with elements taken from the end. \n * Elements are taken until `predicate` returns falsey.\n *\n * @returns Returns the slice of `array`.\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 * @category Array\n * @param predicate - The function invoked per iteration.\n * @param array - The array to query.\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 * @category Array\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.\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 * @category Array\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 '@helpers/types.js';\n\n/**\n * The opposite of `before`. This method creates a function that invokes `func` once it's called `n` or more times.\n *\n * @example\n * const caution = () => console.log(\"Caution!\");\n * const afterFN = after(2, caution);\n *\n * afterFN()\n * afterFN()\n * afterFN()\n * // => `caution` is invoked after called twice\n * @category Function\n * @param n The number of calls before `func` is invoked.\n * @param func The function to restrict.\n * @returns Returns the new restricted function.\n */\n\nexport function after<TFunc extends GenericFunction<TFunc>>(n: number, func: TFunc) {\n let count = 1;\n return (...args: Parameters<TFunc>): ReturnType<TFunc> | undefined => {\n if (count >= n) {\n return func(...args);\n }\n count += 1;\n };\n}\n","import type { GenericFunction } from '@helpers/types.js';\n\n/**\n * Creates a function that invokes `func`, while it's called less than `n` times. Subsequent\n * calls to the created function return the result of the last `func` invocation.\n *\n * @category Function\n * @param n - The number of calls at which `func` is no longer invoked.\n * @param func - The function to restrict.\n * @returns Returns the new restricted function.\n * @example\n * const caution = () => console.log(\"Caution!\");\n *\n * // Only call caution two times\n * const reducedCaution = before(2, caution)\n *\n * reducedCaution()\n * reducedCaution()\n * reducedCaution()\n * // => `caution` is invoked twice\n */\n\nexport function before<TFunc extends GenericFunction<TFunc>>(n: number, func: TFunc): TFunc {\n let count = 0;\n let result: ReturnType<TFunc>;\n return ((...args: Parameters<TFunc>): ReturnType<TFunc> => {\n if (count < n) {\n count += 1;\n result = func(...args);\n }\n return result;\n }) as TFunc;\n}\n","import type { GenericFunction } from '@helpers/types.js';\n\n// TODO this is a port from lodash, it probably can be improved and shortened, also fix TS errors\nexport function debounce<TFunc extends GenericFunction<TFunc>>(\n fn: TFunc, wait = 0, options: { leading?: boolean, maxWait?: number, trailing?: boolean } = {}\n): (this: ThisParameterType<TFunc>, ...args: Parameters<TFunc>) => ReturnType<TFunc> {\n let lastArgs: Parameters<TFunc> | undefined;\n let lastThis: ThisParameterType<TFunc> | undefined;\n let result: ReturnType<TFunc>;\n let timerId: ReturnType<typeof setTimeout> | undefined;\n let lastCallTime: number | undefined;\n let lastInvokeTime = 0;\n const maxing = options.maxWait ?? false;\n const leading = options.leading ?? false;\n const trailing = options.trailing ?? true;\n const maxWait = options.maxWait ?? 0;\n\n function invokeFunc(time: number) {\n const args: Parameters<TFunc> | undefined = lastArgs;\n const thisArg: ThisParameterType<TFunc> | undefined = lastThis;\n\n lastArgs = lastThis = undefined;\n lastInvokeTime = time;\n // @ts-expect-error\n result = fn.apply(thisArg, args);\n return result;\n }\n\n function leadingEdge(time: number) {\n // Reset any `maxWait` timer.\n lastInvokeTime = time;\n // Start the timer for the trailing edge.\n timerId = setTimeout(timerExpired, wait);\n // Invoke the leading edge.\n return leading ? invokeFunc(time) : result;\n }\n\n function remainingWait(time: number) {\n // @ts-expect-error\n const timeSinceLastCall = time - lastCallTime;\n const timeSinceLastInvoke = time - lastInvokeTime;\n const timeWaiting = wait - timeSinceLastCall;\n\n return maxing\n ? Math.min(timeWaiting, maxWait - timeSinceLastInvoke)\n : timeWaiting;\n }\n\n function shouldInvoke(time: number) {\n if (lastCallTime === undefined)\n return true;\n\n const timeSinceLastCall = time - lastCallTime;\n const timeSinceLastInvoke = time - lastInvokeTime;\n\n // Either this is the first call, activity has stopped and we're at the\n // trailing edge, the system time has gone backwards and we're treating\n // it as the trailing edge, or we've hit the `maxWait` limit.\n return timeSinceLastCall >= wait || timeSinceLastCall < 0 || (maxing && timeSinceLastInvoke >= maxWait);\n }\n\n function timerExpired() {\n const time = Date.now();\n if (shouldInvoke(time)) {\n return trailingEdge(time);\n }\n // Restart the timer.\n timerId = setTimeout(timerExpired, remainingWait(time));\n }\n\n function trailingEdge(time: number) {\n timerId = undefined;\n\n // Only invoke if we have `lastArgs` which means `fn` has been\n // debounced at least once.\n if (trailing && lastArgs) {\n return invokeFunc(time);\n }\n lastArgs = lastThis = undefined;\n return result;\n }\n\n function cancel() {\n if (timerId !== undefined) {\n clearTimeout(timerId);\n }\n lastInvokeTime = 0;\n lastArgs = lastCallTime = lastThis = timerId = undefined;\n }\n\n function flush() {\n return timerId === undefined ? result : trailingEdge(Date.now());\n }\n\n function debounced(this: ThisParameterType<TFunc>, ...args: Parameters<TFunc>): ReturnType<TFunc> {\n const time = Date.now();\n const isInvoking = shouldInvoke(time);\n\n lastArgs = args;\n // TODO Fix this assignment\n // eslint-disable-next-line @typescript-eslint/no-this-alias,unicorn/no-this-assignment\n lastThis = this;\n lastCallTime = time;\n\n if (isInvoking) {\n if (timerId === undefined) {\n return leadingEdge(lastCallTime);\n }\n if (maxing) {\n // Handle invocations in a tight loop.\n clearTimeout(timerId);\n timerId = setTimeout(timerExpired, wait);\n return invokeFunc(lastCallTime);\n }\n }\n if (timerId === undefined) {\n timerId = setTimeout(timerExpired, wait);\n }\n return result;\n }\n\n debounced.cancel = cancel;\n debounced.flush = flush;\n return debounced;\n}\n","import type{ GenericFunction } from '@helpers/types.js';\n\nconst defaultResolver = (...args: unknown[]) => JSON.stringify(args);\n\n/**\n * Creates a function that memoizes the result of `func`. If `resolver` is\n * provided, it determines the cache key for storing the result based on the\n * arguments provided to the memoized function. By default, all arguments\n * provided to the memoized function are used as the map cache key.\n *\n * The cache is exposed as the `cache` property on the memoized\n * function. Its creation may be customized by replacing the `memoize.Cache`\n * constructor with one whose instances implement the\n * [`Map`](http://ecma-international.org/ecma-262/7.0/#sec-properties-of-the-map-prototype-object)\n * method interface of `clear`, `delete`, `get`, `has`, and `set`.\n *\n * @example\n * const object = \\{ 'a': 1, 'b': 2 \\}\n *\n * const values = memoize(values)\n * values(object)\n * // => [1, 2]\n *\n * values(object)\n * // => [1, 2]\n *\n * object.a = 2\n * values(object)\n * // => [2, 2]\n *\n * // Modify the result cache.\n * values.cache.set(object, ['a', 'b'])\n * values(object)\n * // => ['a', 'b']\n *\n * // Replace `memoize.Cache`.\n * memoize.Cache = WeakMap\n * @category Function\n * @param func - The function to have its output memoized.\n * @param resolver - The function to resolve the cache key.\n * @returns Returns the new memoized function.\n */\n\nexport function memoize<TFunc extends GenericFunction<TFunc>, Cache extends Map<string | symbol, ReturnType<TFunc>>>(\n func: TFunc, resolver: ((...args: Parameters<TFunc>) => string | symbol) = defaultResolver\n): TFunc & { cache: Cache } {\n\n const cache = new Map() as Cache;\n const memoizedFunc = (...args: Parameters<TFunc>): ReturnType<TFunc> => {\n const key = resolver(...args);\n if (cache.has(key)) {\n // eslint-disable-next-line @typescript-eslint/non-nullable-type-assertion-style\n return cache.get(key) as ReturnType<TFunc>;\n }\n const result = func(...args);\n cache.set(key, result);\n return result;\n };\n memoizedFunc.cache = cache;\n return memoizedFunc as TFunc & { cache: Cache };\n}\n","import type { GenericFunction } from '@helpers/types.js';\n\nimport { before } from '@function/before';\n\n/**\n * Creates a function that is restricted to invoking `func` once.\n * Repeat calls to the function return the value of the first invocation.\n *\n * @example\n * const initialize = once(() => console.log('initialize'))\n * initialize()\n * initialize()\n * // => `createApplication` is invoked once\n *\n * @category Function\n * @param func - The function to restrict.\n * @returns Returns the new restricted function.\n */\n\nexport function once<TFunc extends GenericFunction<TFunc>>(func: TFunc): TFunc {\n return before(1, func);\n}\n","import type { GenericFunction } from '@helpers/types.js';\n\nimport { debounce } from '@function/debounce';\n\nexport function throttle<TFunc extends GenericFunction<TFunc>>(\n func: TFunc, wait = 0, options: { leading?: boolean, trailing?: boolean } = {}\n): (this: ThisParameterType<TFunc>, ...args: Parameters<TFunc>) => ReturnType<TFunc> {\n return debounce(func, wait, {\n leading: options.leading ?? true,\n maxWait: wait,\n trailing: options.trailing ?? true\n });\n}\n","/**\n * Invokes a function `n` times, returning an array of the results of\n * each invocation.\n *\n * The function is invoked with one argument: `index`\n *\n * @example\n * times(3, index => console.log(\"Run\", index)))\n * // => \"Run 0\" | \"Run 1\" | \"Run 2\"\n * times(3, Math.random)\n * // => [0.123, 0.456, 0.789]\n * times(4, () => 0)\n * // => [0, 0, 0, 0]\n * @category Function\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>(n: number, func: (index: number) => TInput): TInput[] {\n const result: TInput[] = [];\n for (let i = 0; i < n; i++) {\n result.push(func(i));\n }\n return result;\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 * @category Object\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, 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 { 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 object, 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}","/**\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 * ---\n * \n * **Methods:**\n * - {@link Queue.add} - adds a async function or array of functions to the queue. \n * Returns a promise that resolves when the added function(s) finish.\n * - {@link Queue.clear} - clears the queue.\n * - {@link Queue.pause} - pauses the queue.\n * - {@link Queue.resume} - resumes the queue. \n * - {@link Queue.getQueue} - returns the queue.\n * - {@link Queue.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 functions in 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 /** Returns 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 * 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}","/**\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 * @category String\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 * @category String\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 * @category String\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","import { splitWords } from '@helpers/stringModifiers.js';\n\n/**\n * Converts a string to dash-case.\n *\n * @example\n * dashCase('Foo Bar')\n * // => 'foo-bar'\n * dashCase('fooBar')\n * // => 'foo-bar'\n * dashCase('__FOO_BAR__')\n * // => 'foo-bar'\n * @category String\n * @param str - The string to convert.\n * @returns Returns the dash cased string.\n */\n\nexport function dashCase(str: string): string {\n const words = splitWords(str);\n\n let dashCase = '';\n for (const word of words) {\n dashCase += word.toLowerCase() + '-';\n }\n return dashCase.slice(0, -1);\n}","/**\n * Converts the characters `&`, `<`, `>`, `\"` and `'` in a string to their corresponding HTML entities.\n *\n * @example\n * escape('fred, barney, & pebbles')\n * // => 'fred, barney, & pebbles'\n * @category String\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 '&': '&',\n '<': '<',\n '>': '>',\n '\\'': ''',\n '\"': '"'\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 * @category String\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 * @category String\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 * @category String\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 * @category String\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 { splitWords } from '@helpers/stringModifiers';\n\n/**\n * Converts a string to Start Case.\n *\n * @example\n * startCase('--foo-bar--')\n * // => 'Foo Bar'\n * startCase('fooBar')\n * // => 'Foo Bar'\n * startCase('__FOO_BAR__')\n * // => 'Foo Bar'\n * @category String\n * @param str - The string to convert.\n * @returns Returns the start cased string.\n */\n\nexport function startCase(str: string): string {\n const words = splitWords(str);\n let startCase = '';\n for (const word of words) {\n startCase += word.charAt(0).toUpperCase() + word.slice(1).toLowerCase() + ' ';\n }\n return startCase.trimEnd();\n}\n","import { deburr } from '@string/deburr';\n\n/**\n * Removes all special characters from a string.\n *\n * @example\n * stripSpecialChars('Héllo! World #$%&*!')\n * // => 'Hello World'\n * @category String\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","/**\n * Converts the HTML entities `&`, `<`, `>`, `"` and `'`\n * in a string to their corresponding characters.\n *\n * @example\n * unescape('fred, barney, & pebbles')\n * // => 'fred, barney, & pebbles'\n * @category String\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 '&': '&',\n '<': '<',\n '>': '>',\n '"': '\"',\n ''': '\\''\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 * @category Validate\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","export function isPlainObject(value: unknown): value is object {\n return value !== null && typeof value === 'object' && value.constructor === Object;\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,MAAc,OAAiB,WAA+B;AAC1E,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,MAAsC,OAAiB,UAAyD;AAC5H,QAAM,SAAS,CAAC;AAChB,aAAW,SAAS,OAAO;AACvB,UAAM,MAAM,SAAS,KAAK;AAE1B,QAAI,OAAO,SAAS,QAAW;AAC3B,aAAO,OAAO;AAAA,IAClB,OAAO;AACH,aAAO,QAAQ;AAAA,IACnB;AAAA,EACJ;AACA,SAAO;AACX;;;ACNO,SAAS,QAAQ,QAAiB,QAA0B;AAC/D,MAAI,WAAW;AAAQ,WAAO;AAE9B,MAAI,MAAM,QAAQ,MAAM,KAAK,MAAM,QAAQ,MAAM,GAAG;AAChD,WAAO,YAAY,QAAQ,MAAM;AAAA,EACrC;AAEA,MAAI,kBAAkB,UAAU,kBAAkB,QAAQ;AACtD,WAAO,OAAO,SAAS,MAAM,OAAO,SAAS;AAAA,EACjD;AAEA,MAAI,SAAS,MAAM,KAAK,SAAS,MAAM,GAAG;AACtC,WAAO,aAAa,QAAQ,MAAM;AAAA,EACtC;AAEA,SAAO;AACX;AAGA,SAAS,SAAS,OAAyC;AACvD,SAAO,OAAO,UAAU,YACjB,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,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,WAAW,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;;;AClDO,SAAS,cAAc,OAAiC;AAC3D,SAAO,UAAU,QAAQ,OAAO,UAAU,YAAY,MAAM,gBAAgB;AAChF;;;ACUO,SAAS,MAAM,KAAsB;AACxC,MAAI;AACA,QAAI,IAAI,GAAG;AACX,WAAO;AAAA,EACX,QAAE;AACE,WAAO;AAAA,EACX;AACJ;","names":["difference","intersection","count","count","timeout","camelCase","dashCase","kebabCase","pascalCase","snakeCase","startCase"]}
|
|
1
|
+
{"version":3,"sources":["../src/array/chunk.ts","../src/array/count.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/function/after.ts","../src/function/before.ts","../src/function/debounce.ts","../src/function/memoize.ts","../src/function/once.ts","../src/function/throttle.ts","../src/function/times.ts","../src/object/pick.ts","../src/object/omit.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/dashCase.ts","../src/string/escapeHtml.ts","../src/string/escapeRegExp.ts","../src/string/kebabCase.ts","../src/string/pascalCase.ts","../src/string/snakeCase.ts","../src/string/startCase.ts","../src/string/stripSpecial.ts","../src/string/unescapeHtml.ts","../src/validate/isEmpty.ts","../src/validate/isPlainObject.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 * @category Array\n * @returns Returns the new array of chunks.\n * @param chunkSize - The array to process.\n * @param array - The length of each chunk\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 */\n\nexport function chunk<TInput>(array: TInput[], chunkSize: number): TInput[][] {\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","import type { RecordKey } from '@helpers/types';\n\n/**\n * Creates an object composed of keys generated from the results of running \n * each element of `collection` thru `iteratee`. \n * The corresponding value of each key is the number of times the key was returned by `iteratee`.\n *\n * @example\n * const users = [\n * { 'user': 'barney', 'active': true },\n * { 'user': 'betty', 'active': true },\n * { 'user': 'fred', 'active': false }\n * ]\n *\n * count(users, value => value.active);\n * // => { 'true': 2, 'false': 1 }\n * @category Array\n * @param iteratee - The iteratee to transform keys.\n * @param collection - The array or record to iterate over.\n * @returns Returns the composed aggregate object.\n */\n\nexport function count<TInput, TKey extends RecordKey>(array: TInput[], iteratee: (value: TInput) => TKey): Record<TKey, number> {\n const result = {} as Record<TKey, number>;\n for (const value of array) {\n const key = iteratee(value);\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 }\n return result;\n}\n","import type { RecordKey } from '@helpers/types';\n\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 * @category Validate\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 (a instanceof Date && b instanceof Date) {\n return a.getTime() === b.getTime();\n }\n\n if (Array.isArray(a) && Array.isArray(b)) {\n return isSameArray(a, b);\n }\n\n if (a instanceof RegExp && b instanceof RegExp) {\n return a.toString() === b.toString();\n }\n\n if (isObject(a) && isObject(b)) {\n return isSameObject(a, b);\n }\n\n return false;\n}\n\ntype KeyValueObject = Record<RecordKey, unknown>;\nfunction isObject(value: unknown): value is KeyValueObject {\n return typeof value === 'object'\n && value !== null\n && !Array.isArray(value)\n && Object.prototype.toString.call(value) === '[object Object]';\n}\n\nfunction isSameObject(value1: KeyValueObject, value2: KeyValueObject) {\n // check if the objects have the same keys\n const keys1 = Object.keys(value1);\n const keys2 = Object.keys(value2);\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(value1[key], value2[key])) return false;\n }\n\n // the objects are deeply equal\n return true;\n}\n\nfunction isSameArray(value1: unknown[], value2: unknown[]) {\n if (value1.length !== value2.length) return false;\n\n // check if the values of each element in the arrays are equal\n for (const [i, element] of value1.entries()) {\n if (!isEqual(element, value2[i])) return false;\n }\n\n return true;\n}\n","import type { MinimumTwoArrays } from '@helpers/types';\n\nimport { isEqual } from '@validate/isEqual';\n\n/**\n * Creates an array values not included in the other given arrays. \n * The order and references of result values are determined by the first array.\n *\n * An compare function is optinal to specify how the elements of the arrays are compared. \n * Default compare function is {@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 * @category Array\n * @param arrays - First array is inspected, others are excluded.\n * @returns Returns the new array of filtered values.\n */\n\nexport function difference<TArr>(...arrays: MinimumTwoArrays<TArr>): TArr[];\nexport function difference<TArr>(arrayOrCompFn: (a: TArr, b: TArr) => boolean, ...arrays: MinimumTwoArrays<TArr>): TArr[];\nexport function difference<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 difference: TArr[] = [];\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 * @category Array\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 dropRightWhile<TArr>(array: TArr[], predicate: (value: TArr) => 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 * @category Array\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 dropWhile<TArr>(array: TArr[], predicate: (value: TArr) => boolean): TArr[] {\n const index = array.findIndex(x => !predicate(x));\n return array.slice(index === -1 ? array.length : index);\n}\n","import type { RecordKey } from '@helpers/types';\n\n/**\n * Creates an object composed of keys generated from the results of running\n * each element of `collection` thru `iteratee`. The order of grouped values\n * is determined by the order they occur in `collection`. The corresponding\n * value of each key is an array of elements responsible for generating the\n * key.\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 * @category Array\n * @param collection - The array or object to iterate over.\n * @param iteratee - The iteratee to transform keys.\n * @returns Returns the composed aggregate object.\n */\n\nexport function group<T, U extends RecordKey>(array: T[], iteratee: (value: T) => U): Record<U, T[]> {\n const result = {} as Record<U, T[]>;\n for (const value of array) {\n const key = iteratee(value);\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 '@helpers/types';\n\nimport { isEqual } from '@validate/isEqual';\n\n/**\n * Creates an array of unique values that are included in all given arrays. \n * The order and references of result values are determined by the first array.\n *\n * An compare function is optinal to specify how the elements of the arrays are compared. \n * Default compare function is {@link isEqual}.\n * @example\n * intersection([2, 1], [2, 3])\n * // => [2]\n *\n * // ---- Custom compare function ----\n * intersection((a, b) => Math.floor(a) === Math.floor(b), [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 * @category Array\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 * @category Array\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 * @category Array\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. \n * An iteratee function is optional to sort the array based on a specific property.\n *\n * @example\n * sort([1, 2, 3, 4], 'desc')\n * // => [4, 3, 2, 1]\n *\n * sort([{ a: 1 }, { a: 2 }, { a: 3 }], 'asc', item => item.a)\n * // => [{ a: 1 }, { a: 2 }, { a: 3 }]\n * @category Array\n * @param array - The array to sort.\n * @param order - The order in which to sort the array.\n * @param iteratee - The iteratee function to sort the array based on a specific property.\n * @returns Returns the sorted array.\n */\n\nexport function sort<TInput>(array: TInput[], order?: 'asc' | 'desc', iteratee?: (item: TInput) => number | bigint | Date | string): TInput[] {\n return [...array].sort((a, b) => {\n const aValue = iteratee ? iteratee(a) : a;\n const bValue = iteratee ? iteratee(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 return 0;\n });\n}\n","/**\n * Creates a slice of `array` with elements taken from the end. \n * Elements are taken until `predicate` returns falsey.\n *\n * @returns Returns the slice of `array`.\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 * @category Array\n * @param predicate - The function invoked per iteration.\n * @param array - The array to query.\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 * @category Array\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.\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 * @category Array\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 '@helpers/types.js';\n\n/**\n * The opposite of `before`. This method creates a function that invokes `func` once it's called `n` or more times.\n *\n * @example\n * const caution = () => console.log(\"Caution!\");\n * const afterFN = after(2, caution);\n *\n * afterFN()\n * afterFN()\n * afterFN()\n * // => `caution` is invoked after called twice\n * @category Function\n * @param n The number of calls before `func` is invoked.\n * @param func The function to restrict.\n * @returns Returns the new restricted function.\n */\n\nexport function after<TFunc extends GenericFunction<TFunc>>(n: number, func: TFunc) {\n let count = 1;\n return (...args: Parameters<TFunc>): ReturnType<TFunc> | undefined => {\n if (count >= n) {\n return func(...args);\n }\n count += 1;\n };\n}\n","import type { GenericFunction } from '@helpers/types.js';\n\n/**\n * Creates a function that invokes `func`, while it's called less than `n` times. Subsequent\n * calls to the created function return the result of the last `func` invocation.\n *\n * @category Function\n * @param n - The number of calls at which `func` is no longer invoked.\n * @param func - The function to restrict.\n * @returns Returns the new restricted function.\n * @example\n * const caution = () => console.log(\"Caution!\");\n *\n * // Only call caution two times\n * const reducedCaution = before(2, caution)\n *\n * reducedCaution()\n * reducedCaution()\n * reducedCaution()\n * // => `caution` is invoked twice\n */\n\nexport function before<TFunc extends GenericFunction<TFunc>>(n: number, func: TFunc): TFunc {\n let count = 0;\n let result: ReturnType<TFunc>;\n return ((...args: Parameters<TFunc>): ReturnType<TFunc> => {\n if (count < n) {\n count += 1;\n result = func(...args);\n }\n return result;\n }) as TFunc;\n}\n","import type { GenericFunction } from '@helpers/types.js';\n\n// TODO this is a port from lodash, it probably can be improved and shortened, also fix TS errors\nexport function debounce<TFunc extends GenericFunction<TFunc>>(\n fn: TFunc, wait = 0, options: { leading?: boolean, maxWait?: number, trailing?: boolean } = {}\n): (this: ThisParameterType<TFunc>, ...args: Parameters<TFunc>) => ReturnType<TFunc> {\n let lastArgs: Parameters<TFunc> | undefined;\n let lastThis: ThisParameterType<TFunc> | undefined;\n let result: ReturnType<TFunc>;\n let timerId: ReturnType<typeof setTimeout> | undefined;\n let lastCallTime: number | undefined;\n let lastInvokeTime = 0;\n const maxing = options.maxWait ?? false;\n const leading = options.leading ?? false;\n const trailing = options.trailing ?? true;\n const maxWait = options.maxWait ?? 0;\n\n function invokeFunc(time: number) {\n const args: Parameters<TFunc> | undefined = lastArgs;\n const thisArg: ThisParameterType<TFunc> | undefined = lastThis;\n\n lastArgs = lastThis = undefined;\n lastInvokeTime = time;\n // @ts-expect-error\n result = fn.apply(thisArg, args);\n return result;\n }\n\n function leadingEdge(time: number) {\n // Reset any `maxWait` timer.\n lastInvokeTime = time;\n // Start the timer for the trailing edge.\n timerId = setTimeout(timerExpired, wait);\n // Invoke the leading edge.\n return leading ? invokeFunc(time) : result;\n }\n\n function remainingWait(time: number) {\n // @ts-expect-error\n const timeSinceLastCall = time - lastCallTime;\n const timeSinceLastInvoke = time - lastInvokeTime;\n const timeWaiting = wait - timeSinceLastCall;\n\n return maxing\n ? Math.min(timeWaiting, maxWait - timeSinceLastInvoke)\n : timeWaiting;\n }\n\n function shouldInvoke(time: number) {\n if (lastCallTime === undefined)\n return true;\n\n const timeSinceLastCall = time - lastCallTime;\n const timeSinceLastInvoke = time - lastInvokeTime;\n\n // Either this is the first call, activity has stopped and we're at the\n // trailing edge, the system time has gone backwards and we're treating\n // it as the trailing edge, or we've hit the `maxWait` limit.\n return timeSinceLastCall >= wait || timeSinceLastCall < 0 || (maxing && timeSinceLastInvoke >= maxWait);\n }\n\n function timerExpired() {\n const time = Date.now();\n if (shouldInvoke(time)) {\n return trailingEdge(time);\n }\n // Restart the timer.\n timerId = setTimeout(timerExpired, remainingWait(time));\n }\n\n function trailingEdge(time: number) {\n timerId = undefined;\n\n // Only invoke if we have `lastArgs` which means `fn` has been\n // debounced at least once.\n if (trailing && lastArgs) {\n return invokeFunc(time);\n }\n lastArgs = lastThis = undefined;\n return result;\n }\n\n function cancel() {\n if (timerId !== undefined) {\n clearTimeout(timerId);\n }\n lastInvokeTime = 0;\n lastArgs = lastCallTime = lastThis = timerId = undefined;\n }\n\n function flush() {\n return timerId === undefined ? result : trailingEdge(Date.now());\n }\n\n function debounced(this: ThisParameterType<TFunc>, ...args: Parameters<TFunc>): ReturnType<TFunc> {\n const time = Date.now();\n const isInvoking = shouldInvoke(time);\n\n lastArgs = args;\n // TODO Fix this assignment\n // eslint-disable-next-line @typescript-eslint/no-this-alias,unicorn/no-this-assignment\n lastThis = this;\n lastCallTime = time;\n\n if (isInvoking) {\n if (timerId === undefined) {\n return leadingEdge(lastCallTime);\n }\n if (maxing) {\n // Handle invocations in a tight loop.\n clearTimeout(timerId);\n timerId = setTimeout(timerExpired, wait);\n return invokeFunc(lastCallTime);\n }\n }\n if (timerId === undefined) {\n timerId = setTimeout(timerExpired, wait);\n }\n return result;\n }\n\n debounced.cancel = cancel;\n debounced.flush = flush;\n return debounced;\n}\n","import type{ GenericFunction } from '@helpers/types.js';\n\nconst defaultResolver = (...args: unknown[]) => JSON.stringify(args);\n\n/**\n * Creates a function that memoizes the result of `func`. If `resolver` is\n * provided, it determines the cache key for storing the result based on the\n * arguments provided to the memoized function. By default, all arguments\n * provided to the memoized function are used as the map cache key.\n *\n * The cache is exposed as the `cache` property on the memoized\n * function. Its creation may be customized by replacing the `memoize.Cache`\n * constructor with one whose instances implement the\n * [`Map`](http://ecma-international.org/ecma-262/7.0/#sec-properties-of-the-map-prototype-object)\n * method interface of `clear`, `delete`, `get`, `has`, and `set`.\n *\n * @example\n * const object = \\{ 'a': 1, 'b': 2 \\}\n *\n * const values = memoize(values)\n * values(object)\n * // => [1, 2]\n *\n * values(object)\n * // => [1, 2]\n *\n * object.a = 2\n * values(object)\n * // => [2, 2]\n *\n * // Modify the result cache.\n * values.cache.set(object, ['a', 'b'])\n * values(object)\n * // => ['a', 'b']\n *\n * // Replace `memoize.Cache`.\n * memoize.Cache = WeakMap\n * @category Function\n * @param func - The function to have its output memoized.\n * @param resolver - The function to resolve the cache key.\n * @returns Returns the new memoized function.\n */\n\nexport function memoize<TFunc extends GenericFunction<TFunc>, Cache extends Map<string | symbol, ReturnType<TFunc>>>(\n func: TFunc, resolver: ((...args: Parameters<TFunc>) => string | symbol) = defaultResolver\n): TFunc & { cache: Cache } {\n\n const cache = new Map() as Cache;\n const memoizedFunc = (...args: Parameters<TFunc>): ReturnType<TFunc> => {\n const key = resolver(...args);\n if (cache.has(key)) {\n // eslint-disable-next-line @typescript-eslint/non-nullable-type-assertion-style\n return cache.get(key) as ReturnType<TFunc>;\n }\n const result = func(...args);\n cache.set(key, result);\n return result;\n };\n memoizedFunc.cache = cache;\n return memoizedFunc as TFunc & { cache: Cache };\n}\n","import type { GenericFunction } from '@helpers/types.js';\n\nimport { before } from '@function/before';\n\n/**\n * Creates a function that is restricted to invoking `func` once.\n * Repeat calls to the function return the value of the first invocation.\n *\n * @example\n * const initialize = once(() => console.log('initialize'))\n * initialize()\n * initialize()\n * // => `createApplication` is invoked once\n *\n * @category Function\n * @param func - The function to restrict.\n * @returns Returns the new restricted function.\n */\n\nexport function once<TFunc extends GenericFunction<TFunc>>(func: TFunc): TFunc {\n return before(1, func);\n}\n","import type { GenericFunction } from '@helpers/types.js';\n\nimport { debounce } from '@function/debounce';\n\nexport function throttle<TFunc extends GenericFunction<TFunc>>(\n func: TFunc, wait = 0, options: { leading?: boolean, trailing?: boolean } = {}\n): (this: ThisParameterType<TFunc>, ...args: Parameters<TFunc>) => ReturnType<TFunc> {\n return debounce(func, wait, {\n leading: options.leading ?? true,\n maxWait: wait,\n trailing: options.trailing ?? true\n });\n}\n","/**\n * Invokes a function `n` times, returning an array of the results of\n * each invocation.\n *\n * The function is invoked with one argument: `index`\n *\n * @example\n * times(3, index => console.log(\"Run\", index)))\n * // => \"Run 0\" | \"Run 1\" | \"Run 2\"\n * times(3, Math.random)\n * // => [0.123, 0.456, 0.789]\n * times(4, () => 0)\n * // => [0, 0, 0, 0]\n * @category Function\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>(n: number, func: (index: number) => TInput): TInput[] {\n const result: TInput[] = [];\n for (let i = 0; i < n; i++) {\n result.push(func(i));\n }\n return result;\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 * @category Object\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, 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 { 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 object, 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}","/**\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 * ---\n * \n * **Methods:**\n * - {@link Queue.add} - adds a async function or array of functions to the queue. \n * Returns a promise that resolves when the added function(s) finish.\n * - {@link Queue.clear} - clears the queue.\n * - {@link Queue.pause} - pauses the queue.\n * - {@link Queue.resume} - resumes the queue. \n * - {@link Queue.getQueue} - returns the queue.\n * - {@link Queue.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 functions in 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 /** Returns 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 promise2 = 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 * response.ok || 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 * @category String\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 * @category String\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 * @category String\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","import { splitWords } from '@helpers/stringModifiers.js';\n\n/**\n * Converts a string to dash-case.\n *\n * @example\n * dashCase('Foo Bar')\n * // => 'foo-bar'\n * dashCase('fooBar')\n * // => 'foo-bar'\n * dashCase('__FOO_BAR__')\n * // => 'foo-bar'\n * @category String\n * @param str - The string to convert.\n * @returns Returns the dash cased string.\n */\n\nexport function dashCase(str: string): string {\n const words = splitWords(str);\n\n let dashCase = '';\n for (const word of words) {\n dashCase += word.toLowerCase() + '-';\n }\n return dashCase.slice(0, -1);\n}","/**\n * Converts the characters `&`, `<`, `>`, `\"` and `'` in a string to their corresponding HTML entities.\n *\n * @example\n * escape('fred, barney, & pebbles')\n * // => 'fred, barney, & pebbles'\n * @category String\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 '&': '&',\n '<': '<',\n '>': '>',\n '\\'': ''',\n '\"': '"'\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 * @category String\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 * @category String\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 * @category String\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 * @category String\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 { splitWords } from '@helpers/stringModifiers';\n\n/**\n * Converts a string to Start Case.\n *\n * @example\n * startCase('--foo-bar--')\n * // => 'Foo Bar'\n * startCase('fooBar')\n * // => 'Foo Bar'\n * startCase('__FOO_BAR__')\n * // => 'Foo Bar'\n * @category String\n * @param str - The string to convert.\n * @returns Returns the start cased string.\n */\n\nexport function startCase(str: string): string {\n const words = splitWords(str);\n let startCase = '';\n for (const word of words) {\n startCase += word.charAt(0).toUpperCase() + word.slice(1).toLowerCase() + ' ';\n }\n return startCase.trimEnd();\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 * @category String\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","/**\n * Converts the HTML entities `&`, `<`, `>`, `"` and `'`\n * in a string to their corresponding characters.\n *\n * @example\n * unescape('fred, barney, & pebbles')\n * // => 'fred, barney, & pebbles'\n * @category String\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 '&': '&',\n '<': '<',\n '>': '>',\n '"': '\"',\n ''': '\\''\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 * @category Validate\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","export function isPlainObject(value: unknown): value is object {\n return value !== null && typeof value === 'object' && value.constructor === Object;\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,MAAc,OAAiB,WAA+B;AAC1E,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,MAAsC,OAAiB,UAAyD;AAC5H,QAAM,SAAS,CAAC;AAChB,aAAW,SAAS,OAAO;AACvB,UAAM,MAAM,SAAS,KAAK;AAE1B,QAAI,OAAO,SAAS,QAAW;AAC3B,aAAO,OAAO;AAAA,IAClB,OAAO;AACH,aAAO,QAAQ;AAAA,IACnB;AAAA,EACJ;AACA,SAAO;AACX;;;ACNO,SAAS,QAAQ,GAAY,GAAqB;AACrD,MAAI,OAAO,GAAG,GAAG,CAAC;AAAG,WAAO;AAE5B,MAAI,aAAa,QAAQ,aAAa,MAAM;AACxC,WAAO,EAAE,QAAQ,MAAM,EAAE,QAAQ;AAAA,EAC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ChB,SAAO,IAAI,QAAQ,aAAa,EAAE;AACtC;;;ACJO,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,WAAW,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;;;AClDO,SAAS,cAAc,OAAiC;AAC3D,SAAO,UAAU,QAAQ,OAAO,UAAU,YAAY,MAAM,gBAAgB;AAChF;;;ACUO,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","dashCase","kebabCase","pascalCase","snakeCase","startCase"]}
|
package/package.json
CHANGED