es-toolkit 1.13.1-dev.344 → 1.13.1-dev.346

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.
Files changed (41) hide show
  1. package/dist/browser.global.js +1 -1
  2. package/dist/browser.global.js.map +1 -1
  3. package/dist/compat/index.d.mts +4 -1
  4. package/dist/compat/index.d.ts +4 -1
  5. package/dist/compat/index.js +3 -0
  6. package/dist/compat/index.js.map +1 -1
  7. package/dist/compat/index.mjs +4 -1
  8. package/dist/compat/index.mjs.map +1 -1
  9. package/dist/function/before.d.mts +31 -0
  10. package/dist/function/before.d.ts +31 -0
  11. package/dist/function/before.mjs +15 -0
  12. package/dist/function/before.mjs.map +1 -0
  13. package/dist/function/index.d.mts +1 -0
  14. package/dist/function/index.d.ts +1 -0
  15. package/dist/function/index.js +14 -0
  16. package/dist/function/index.js.map +1 -1
  17. package/dist/function/index.mjs +1 -0
  18. package/dist/function/index.mjs.map +1 -1
  19. package/dist/index.d.mts +4 -1
  20. package/dist/index.d.ts +4 -1
  21. package/dist/index.js +3 -0
  22. package/dist/index.js.map +1 -1
  23. package/dist/index.mjs +4 -1
  24. package/dist/index.mjs.map +1 -1
  25. package/dist/object/cloneDeep.mjs +1 -2
  26. package/dist/object/cloneDeep.mjs.map +1 -1
  27. package/dist/object/index.d.mts +3 -1
  28. package/dist/object/index.d.ts +3 -1
  29. package/dist/object/index.js +50 -27
  30. package/dist/object/index.js.map +1 -1
  31. package/dist/object/index.mjs +3 -1
  32. package/dist/object/index.mjs.map +1 -1
  33. package/dist/object/mapKeys.d.mts +21 -0
  34. package/dist/object/mapKeys.d.ts +21 -0
  35. package/dist/object/mapKeys.mjs +13 -0
  36. package/dist/object/mapKeys.mjs.map +1 -0
  37. package/dist/object/mapValues.d.mts +21 -0
  38. package/dist/object/mapValues.d.ts +21 -0
  39. package/dist/object/mapValues.mjs +13 -0
  40. package/dist/object/mapValues.mjs.map +1 -0
  41. package/package.json +1 -1
@@ -48,6 +48,7 @@ export { last } from '../array/last.mjs';
48
48
  export { initial } from '../array/initial.mjs';
49
49
  export { AbortError } from '../error/AbortError.mjs';
50
50
  export { TimeoutError } from '../error/TimeoutError.mjs';
51
+ export { before } from '../function/before.mjs';
51
52
  export { after } from '../function/after.mjs';
52
53
  export { debounce } from '../function/debounce.mjs';
53
54
  export { noop } from '../function/noop.mjs';
@@ -70,8 +71,10 @@ export { pick } from '../object/pick.mjs';
70
71
  export { pickBy } from '../object/pickBy.mjs';
71
72
  export { invert } from '../object/invert.mjs';
72
73
  export { clone } from '../object/clone.mjs';
73
- export { cloneDeep } from '../object/cloneDeep.mjs';
74
74
  export { flattenObject } from '../object/flattenObject.mjs';
75
+ export { mapKeys } from '../object/mapKeys.mjs';
76
+ export { mapValues } from '../object/mapValues.mjs';
77
+ export { cloneDeep } from '../object/cloneDeep.mjs';
75
78
  export { isEqual } from '../predicate/isEqual.mjs';
76
79
  export { isNil } from '../predicate/isNil.mjs';
77
80
  export { isNotNil } from '../predicate/isNotNil.mjs';
@@ -48,6 +48,7 @@ export { last } from '../array/last.js';
48
48
  export { initial } from '../array/initial.js';
49
49
  export { AbortError } from '../error/AbortError.js';
50
50
  export { TimeoutError } from '../error/TimeoutError.js';
51
+ export { before } from '../function/before.js';
51
52
  export { after } from '../function/after.js';
52
53
  export { debounce } from '../function/debounce.js';
53
54
  export { noop } from '../function/noop.js';
@@ -70,8 +71,10 @@ export { pick } from '../object/pick.js';
70
71
  export { pickBy } from '../object/pickBy.js';
71
72
  export { invert } from '../object/invert.js';
72
73
  export { clone } from '../object/clone.js';
73
- export { cloneDeep } from '../object/cloneDeep.js';
74
74
  export { flattenObject } from '../object/flattenObject.js';
75
+ export { mapKeys } from '../object/mapKeys.js';
76
+ export { mapValues } from '../object/mapValues.js';
77
+ export { cloneDeep } from '../object/cloneDeep.js';
75
78
  export { isEqual } from '../predicate/isEqual.js';
76
79
  export { isNil } from '../predicate/isNil.js';
77
80
  export { isNotNil } from '../predicate/isNotNil.js';
@@ -398,6 +398,7 @@ exports.TimeoutError = promise_index.TimeoutError;
398
398
  exports.delay = promise_index.delay;
399
399
  exports.withTimeout = promise_index.withTimeout;
400
400
  exports.after = function_index.after;
401
+ exports.before = function_index.before;
401
402
  exports.debounce = function_index.debounce;
402
403
  exports.negate = function_index.negate;
403
404
  exports.noop = function_index.noop;
@@ -417,6 +418,8 @@ exports.clone = object_index.clone;
417
418
  exports.cloneDeep = object_index.cloneDeep;
418
419
  exports.flattenObject = object_index.flattenObject;
419
420
  exports.invert = object_index.invert;
421
+ exports.mapKeys = object_index.mapKeys;
422
+ exports.mapValues = object_index.mapValues;
420
423
  exports.omit = object_index.omit;
421
424
  exports.omitBy = object_index.omitBy;
422
425
  exports.pick = object_index.pick;
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../../src/compat/array/chunk.ts","../../src/compat/array/concat.ts","../../src/compat/array/difference.ts","../../src/compat/array/fill.ts","../../src/compat/_internal/isIndex.ts","../../src/compat/_internal/toPath.ts","../../src/compat/object/set.ts","../../src/compat/array/zipObjectDeep.ts","../../src/compat/_internal/isDeepKey.ts","../../src/compat/object/get.ts","../../src/compat/predicate/isPlainObject.ts","../../src/compat/predicate/isArray.ts","../../src/compat/predicate/isTypedArray.ts","../../src/compat/_internal/isArrayMatch.ts","../../src/compat/_internal/isMapMatch.ts","../../src/compat/_internal/isSetMatch.ts","../../src/compat/predicate/isMatch.ts","../../src/compat/predicate/matches.ts","../../src/compat/string/startsWith.ts","../../src/compat/string/endsWith.ts","../../src/compat/math/max.ts","../../src/compat/math/min.ts"],"sourcesContent":["import { chunk as chunkToolkit } from '../../array/chunk.ts';\n\n/**\n * Splits an array into smaller arrays of a specified length.\n *\n * This function takes an input array and divides it into multiple smaller arrays,\n * each of a specified length. If the input array cannot be evenly divided,\n * the final sub-array will contain the remaining elements.\n *\n * @template T The type of elements in the array.\n * @param {T[]} arr - The array to be chunked into smaller arrays.\n * @param {number} size - The size of each smaller array. Must be a positive integer.\n * @returns {T[][]} A two-dimensional array where each sub-array has a maximum length of `size`.\n * @throws {Error} Throws an error if `size` is not a positive integer.\n *\n * @example\n * // Splits an array of numbers into sub-arrays of length 2\n * chunk([1, 2, 3, 4, 5], 2);\n * // Returns: [[1, 2], [3, 4], [5]]\n *\n * @example\n * // Splits an array of strings into sub-arrays of length 3\n * chunk(['a', 'b', 'c', 'd', 'e', 'f', 'g'], 3);\n * // Returns: [['a', 'b', 'c'], ['d', 'e', 'f'], ['g']]\n */\nexport function chunk<T>(arr: readonly T[], size = 1): T[][] {\n size = Math.max(Math.floor(size), 0);\n\n if (size === 0) {\n return [];\n }\n\n return chunkToolkit(arr, size);\n}\n","import { flatten } from '../../array/flatten.ts';\n\n/**\n * Concatenates multiple arrays and values into a single array.\n *\n * @template T The type of elements in the array.\n * @param {...(T | T[])} values - The values and/or arrays to concatenate.\n * @returns {T[]} A new array containing all the input values.\n *\n * @example\n * // Concatenate individual values\n * concat(1, 2, 3);\n * // returns [1, 2, 3]\n *\n * @example\n * // Concatenate arrays of values\n * concat([1, 2], [3, 4]);\n * // returns [1, 2, 3, 4]\n *\n * @example\n * // Concatenate a mix of individual values and arrays\n * concat(1, [2, 3], 4);\n * // returns [1, 2, 3, 4]\n *\n * @example\n * // Concatenate nested arrays\n * concat([1, [2, 3]], 4);\n * // returns [1, [2, 3], 4]\n */\nexport function concat<T>(...values: Array<T | readonly T[]>): T[] {\n return flatten(values) as T[];\n}\n","import { difference as differenceToolkit } from '../../array/difference.ts';\nimport { flatten } from '../../array/flatten.ts';\n\nexport function difference<T>(arr: readonly T[], ...values: Array<readonly T[]>): T[] {\n const arr1 = arr;\n const arr2 = flatten(values);\n\n return differenceToolkit(arr1, arr2);\n}","import { fill as fillToolkit } from '../../array/fill.ts';\n\n/**\n * Fills elements of an array with a specified value from the start position up to, but not including, the end position.\n *\n * This function mutates the original array and replaces its elements with the provided value, starting from the specified\n * start index up to the end index (non-inclusive). If the start or end indices are not provided, it defaults to filling the\n * entire array.\n *\n * @template T, U, S, V\n * @param {Array<T | U>} array - The array to fill.\n * @param {U} value - The value to fill the array with.\n * @param {S} [start=0] - The start position. Defaults to 0.\n * @param {V} [end=arr.length] - The end position. Defaults to the array's length.\n * @returns {Array<T | U>} The array with the filled values.\n *\n * @example\n * const array = [1, 2, 3];\n * const result = fill(array, 'a');\n * // => ['a', 'a', 'a']\n *\n * const result = fill(Array(3), 2);\n * // => [2, 2, 2]\n *\n * const result = fill([4, 6, 8, 10], '*', 1, 3);\n * // => [4, '*', '*', 10]\n *\n * const result = fill(array, '*', -2, -1);\n * // => [1, '*', 3]\n */\nexport function fill<T>(array: unknown[], value?: T): T[];\nexport function fill<T, U, S>(array: Array<T | U>, value: U, start: S): Array<T | U>;\nexport function fill<T, U, S, V>(array: Array<T | U>, value: U, start: S, end: V): Array<T | U>;\nexport function fill<T, U>(array: Array<T | U>, value: U, start = 0, end = array.length): Array<T | U> {\n start = Math.floor(start);\n end = Math.floor(end);\n\n if (!start) {\n start = 0;\n }\n if (!end) {\n end = 0;\n }\n\n return fillToolkit(array, value, start, end);\n}\n","const IS_UNSIGNED_INTEGER = /^(?:0|[1-9]\\d*)$/\n\nexport function isIndex(value: PropertyKey) {\n switch (typeof value) {\n case 'number': {\n return Number.isInteger(value) && value >= 0 && value < Number.MAX_SAFE_INTEGER;\n }\n case 'symbol': {\n return false;\n }\n case 'string': {\n return IS_UNSIGNED_INTEGER.test(value);\n }\n }\n}","/**\n * Converts a deep key string into an array of path segments.\n *\n * This function takes a string representing a deep key (e.g., 'a.b.c' or 'a[b][c]') and breaks it down into an array of strings, each representing a segment of the path.\n *\n * @param {string} deepKey - The deep key string to convert.\n * @returns {string[]} An array of strings, each representing a segment of the path.\n *\n * Examples:\n *\n * toPath('a.b.c') // Returns ['a', 'b', 'c']\n * toPath('a[b][c]') // Returns ['a', 'b', 'c']\n * toPath('.a.b.c') // Returns ['', 'a', 'b', 'c']\n * toPath('a[\"b.c\"].d') // Returns ['a', 'b.c', 'd']\n * toPath('') // Returns []\n * toPath('.a[b].c.d[e][\"f.g\"].h') // Returns ['', 'a', 'b', 'c', 'd', 'e', 'f.g', 'h']\n */\nexport function toPath(deepKey: string): string[] {\n const ESCAPE_REGEXP = /\\\\(\\\\)?/g;\n const PROPERTY_REGEXP = RegExp(\n // Match anything that isn't a dot or bracket.\n '[^.[\\\\]]+' +\n '|' +\n // Or match property names within brackets.\n '\\\\[(?:' +\n // Match a non-string expression.\n '([^\"\\'][^[]*)' +\n '|' +\n // Or match strings (supports escaping characters).\n '([\"\\'])((?:(?!\\\\2)[^\\\\\\\\]|\\\\\\\\.)*?)\\\\2' +\n ')\\\\]' +\n '|' +\n // Or match \"\" as the space between consecutive dots or empty brackets.\n '(?=(?:\\\\.|\\\\[\\\\])(?:\\\\.|\\\\[\\\\]|$))',\n 'g'\n );\n\n const result: string[] = [];\n\n if (deepKey[0] === '.') {\n result.push('');\n }\n\n let match: RegExpExecArray | null;\n let lastIndex = 0;\n\n while ((match = PROPERTY_REGEXP.exec(deepKey)) !== null) {\n let key = match[0];\n const expr = match[1];\n const quote = match[2];\n const substr = match[3];\n\n if (quote) {\n key = substr.replace(ESCAPE_REGEXP, '$1');\n } else if (expr) {\n key = expr;\n }\n\n result.push(key);\n\n if (PROPERTY_REGEXP.lastIndex === lastIndex) {\n PROPERTY_REGEXP.lastIndex++;\n } else {\n lastIndex = PROPERTY_REGEXP.lastIndex;\n }\n }\n\n return result;\n}\n","import { isIndex } from \"../_internal/isIndex.ts\";\nimport { toPath } from \"../_internal/toPath.ts\";\n\n/**\n * Sets the value at the specified path of the given object. If any part of the path does not exist, it will be created.\n *\n * @template T - The type of the object.\n * @param {Settable} obj - The object to modify.\n * @param {Path} path - The path of the property to set.\n * @param {any} value - The value to set.\n * @returns {T} - The modified object.\n *\n * @example\n * // Set a value in a nested object\n * const obj = { a: { b: { c: 3 } } };\n * set(obj, 'a.b.c', 4);\n * console.log(obj.a.b.c); // 4\n *\n * @example\n * // Set a value in an array\n * const arr = [1, 2, 3];\n * set(arr, 1, 4);\n * console.log(arr[1]); // 4\n *\n * @example\n * // Create non-existent path and set value\n * const obj = {};\n * set(obj, 'a.b.c', 4);\n * console.log(obj); // { a: { b: { c: 4 } } }\n */\nexport function set<T>(obj: object, path: PropertyKey | readonly PropertyKey[], value: unknown): T;\nexport function set<T extends object>(obj: T, path: PropertyKey | readonly PropertyKey[], value: unknown): T {\n const resolvedPath = Array.isArray(path)\n ? path\n : typeof path === 'string'\n ? toPath(path)\n : [path];\n\n let current: any = obj;\n\n for (let i = 0; i < resolvedPath.length - 1; i++) {\n const key = resolvedPath[i];\n const nextKey = resolvedPath[i + 1];\n\n if (current[key] == null) {\n current[key] = isIndex(nextKey) ? [] : {};\n }\n\n current = current[key];\n }\n\n const lastKey = resolvedPath[resolvedPath.length - 1];\n current[lastKey] = value;\n\n return obj;\n}\n","import { zip } from \"../../array/zip.ts\";\nimport { set } from \"../object/set.ts\";\n\n/**\n * Creates a deeply nested object given arrays of paths and values.\n *\n * This function takes two arrays: one containing arrays of property paths, and the other containing corresponding values.\n * It returns a new object where paths from the first array are used as key paths to set values, with corresponding elements from the second array as values.\n * Paths can be dot-separated strings or arrays of property names.\n * \n * If the `keys` array is longer than the `values` array, the remaining keys will have `undefined` as their values.\n *\n * @template V - The type of elements in the array.\n * @param {P[] | P[][]} keys - An array of property paths, each path can be a dot-separated string or an array of property names.\n * @param {V[]} values - An array of values corresponding to the property paths.\n * @returns {object} A new object composed of the given property paths and values.\n *\n * @example\n * const paths = ['a.b.c', 'd.e.f'];\n * const values = [1, 2];\n * const result = zipObjectDeep(paths, values);\n * // result will be { a: { b: { c: 1 } }, d: { e: { f: 2 } } }\n *\n * @example\n * const paths = [['a', 'b', 'c'], ['d', 'e', 'f']];\n * const values = [1, 2];\n * const result = zipObjectDeep(paths, values);\n * // result will be { a: { b: { c: 1 } }, d: { e: { f: 2 } } }\n * \n * @example\n * const paths = ['a.b[0].c', 'a.b[1].d'];\n * const values = [1, 2];\n * const result = zipObjectDeep(paths, values);\n * // result will be { 'a': { 'b': [{ 'c': 1 }, { 'd': 2 }] } }\n */\nexport function zipObjectDeep<P extends PropertyKey, V>(keys: P[] | P[][], values: V[]): { [K in P]: V } {\n const result = {} as { [K in P]: V };\n const zipped = zip<P | P[], V>(keys, values);\n\n for (let i = 0; i < zipped.length; i++) {\n const [key, value] = zipped[i];\n\n if (key != null) {\n set(result, key, value);\n }\n }\n\n return result;\n}\n","const IS_PLAIN = /^\\w*$/;\nconst IS_DEEP = /\\.|\\[(?:[^[\\]]*|([\"'])(?:(?!\\1)[^\\\\]|\\\\.)*?\\1)\\]/;\n\n/**\n * Checks if a given key is a deep key.\n *\n * A deep key is a string that contains a dot (.) or square brackets with a property accessor.\n *\n * @param {PropertyKey} key - The key to check.\n * @returns {boolean} - Returns true if the key is a deep key, otherwise false.\n *\n * Examples:\n *\n * isDeepKey('a.b') // true\n * isDeepKey('a[b]') // true\n * isDeepKey('a') // false\n * isDeepKey(123) // false\n * isDeepKey('a.b.c') // true\n * isDeepKey('a[b][c]') // true\n */\nexport function isDeepKey(key: PropertyKey): boolean {\n switch (typeof key) {\n case 'number':\n case 'symbol': {\n return false;\n }\n case 'string': {\n return !IS_PLAIN.test(key) && IS_DEEP.test(key);\n }\n }\n}\n","import { isDeepKey } from \"../_internal/isDeepKey.ts\";\nimport { toPath } from \"../_internal/toPath.ts\";\nimport type { Get } from \"./get.types.ts\";\n\n/**\n * Retrieves the value at a given path from an object. If the resolved value is undefined, the defaultValue is returned instead.\n * \n * @template T - The type of the object.\n * @template K - The type of the key in the object.\n * @template D - The type of the default value.\n * \n * @param {T} object - The object to query.\n * @param {K | [K]} path - The path of the property to get.\n * @returns {T[K]} - Returns the resolved value.\n */\nexport function get<T extends object, K extends keyof T>(object: T, path: K | [K]): T[K];\n/**\n * Retrieves the value at a given path from an object. If the resolved value is undefined, the defaultValue is returned instead.\n * \n * @template T - The type of the object.\n * @template K - The type of the key in the object.\n * \n * @param {T | null | undefined} object - The object to query.\n * @param {K | [K]} path - The path of the property to get.\n * @returns {T[K] | undefined} - Returns the resolved value.\n */\nexport function get<T extends object, K extends keyof T>(object: T | null | undefined, path: K | [K]): T[K] | undefined;\n/**\n * Retrieves the value at a given path from an object. If the resolved value is undefined, the defaultValue is returned instead.\n * \n * @template T - The type of the object.\n * @template K - The type of the key in the object.\n * @template D - The type of the default value.\n * \n * @param {T | null | undefined} object - The object to query.\n * @param {K | [K]} path - The path of the property to get.\n * @param {D} defaultValue - The value returned if the resolved value is undefined.\n * @returns {Exclude<T[K], undefined> | D} - Returns the resolved value.\n */\nexport function get<T extends object, K extends keyof T, D>(object: T | null | undefined, path: K | [K], defaultValue: D): Exclude<T[K], undefined> | D;\n/**\n * Retrieves the value at a given path from an object. If the resolved value is undefined, the defaultValue is returned instead.\n * \n * @template T - The type of the object.\n * @template K1 - The type of the first key in the object.\n * @template K2 - The type of the second key in the object.\n * \n * @param {T} object - The object to query.\n * @param {[K1, K2]} path - The path of the property to get.\n * @returns {T[K1][K2]} - Returns the resolved value.\n */\nexport function get<T extends object, K1 extends keyof T, K2 extends keyof T[K1]>(object: T, path: [K1, K2]): T[K1][K2];\n/**\n * Retrieves the value at a given path from an object. If the resolved value is undefined, the defaultValue is returned instead.\n * \n * @template T - The type of the object.\n * @template K1 - The type of the first key in the object.\n * @template K2 - The type of the second key in the object.\n * \n * @param {T | null | undefined} object - The object to query.\n * @param {[K1, K2]} path - The path of the property to get.\n * @returns {T[K1][K2] | undefined} - Returns the resolved value.\n */\nexport function get<T extends object, K1 extends keyof T, K2 extends keyof T[K1]>(object: T | null | undefined, path: [K1, K2]): T[K1][K2] | undefined;\n/**\n * Retrieves the value at a given path from an object. If the resolved value is undefined, the defaultValue is returned instead.\n * \n * @template T - The type of the object.\n * @template K1 - The type of the first key in the object.\n * @template K2 - The type of the second key in the object.\n * @template D - The type of the default value.\n * \n * @param {T | null | undefined} object - The object to query.\n * @param {[K1, K2]} path - The path of the property to get.\n * @param {D} defaultValue - The value returned if the resolved value is undefined.\n * @returns {Exclude<T[K1][K2], undefined> | D} - Returns the resolved value.\n */\nexport function get<T extends object, K1 extends keyof T, K2 extends keyof T[K1], D>(object: T | null | undefined, path: [K1, K2], defaultValue: D): Exclude<T[K1][K2], undefined> | D;\n/**\n * Retrieves the value at a given path from an object. If the resolved value is undefined, the defaultValue is returned instead.\n * \n * @template T - The type of the object.\n * @template K1 - The type of the first key in the object.\n * @template K2 - The type of the second key in the object.\n * @template K3 - The type of the third key in the object.\n * \n * @param {T} object - The object to query.\n * @param {[K1, K2, K3]} path - The path of the property to get.\n * @returns {T[K1][K2][K3]} - Returns the resolved value.\n */\nexport function get<T extends object, K1 extends keyof T, K2 extends keyof T[K1], K3 extends keyof T[K1][K2]>(object: T, path: [K1, K2, K3]): T[K1][K2][K3];\n/**\n * Retrieves the value at a given path from an object. If the resolved value is undefined, the defaultValue is returned instead.\n * \n * @template T - The type of the object.\n * @template K1 - The type of the first key in the object.\n * @template K2 - The type of the second key in the object.\n * @template K3 - The type of the third key in the object.\n * \n * @param {T | null | undefined} object - The object to query.\n * @param {[K1, K2, K3]} path - The path of the property to get.\n * @returns {T[K1][K2][K3] | undefined} - Returns the resolved value.\n */\nexport function get<T extends object, K1 extends keyof T, K2 extends keyof T[K1], K3 extends keyof T[K1][K2]>(object: T | null | undefined, path: [K1, K2, K3]): T[K1][K2][K3] | undefined;\n/**\n * Retrieves the value at a given path from an object. If the resolved value is undefined, the defaultValue is returned instead.\n * \n * @template T - The type of the object.\n * @template K1 - The type of the first key in the object.\n * @template K2 - The type of the second key in the object.\n * @template K3 - The type of the third key in the object.\n * @template D - The type of the default value.\n * \n * @param {T | null | undefined} object - The object to query.\n * @param {[K1, K2, K3]} path - The path of the property to get.\n * @param {D} defaultValue - The value returned if the resolved value is undefined.\n * @returns {Exclude<T[K1][K2][K3], undefined> | D} - Returns the resolved value.\n */\nexport function get<T extends object, K1 extends keyof T, K2 extends keyof T[K1], K3 extends keyof T[K1][K2], D>(object: T | null | undefined, path: [K1, K2, K3], defaultValue: D): Exclude<T[K1][K2][K3], undefined> | D;\n/**\n * Retrieves the value at a given path from an object. If the resolved value is undefined, the defaultValue is returned instead.\n * \n * @template T - The type of the object.\n * @template K1 - The type of the first key in the object.\n * @template K2 - The type of the second key in the object.\n * @template K3 - The type of the third key in the object.\n * @template K4 - The type of the fourth key in the object.\n * \n * @param {T} object - The object to query.\n * @param {[K1, K2, K3, K4]} path - The path of the property to get.\n * @returns {T[K1][K2][K3][K4]} - Returns the resolved value.\n */\nexport function get<T extends object, K1 extends keyof T, K2 extends keyof T[K1], K3 extends keyof T[K1][K2], K4 extends keyof T[K1][K2][K3]>(object: T, path: [K1, K2, K3, K4]): T[K1][K2][K3][K4];\n/**\n * Retrieves the value at a given path from an object. If the resolved value is undefined, the defaultValue is returned instead.\n * \n * @template T - The type of the object.\n * @template K1 - The type of the first key in the object.\n * @template K2 - The type of the second key in the object.\n * @template K3 - The type of the third key in the object.\n * @template K4 - The type of the fourth key in the object.\n * \n * @param {T | null | undefined} object - The object to query.\n * @param {[K1, K2, K3, K4]} path - The path of the property to get.\n * @returns {T[K1][K2][K3][K4] | undefined} - Returns the resolved value.\n */\nexport function get<T extends object, K1 extends keyof T, K2 extends keyof T[K1], K3 extends keyof T[K1][K2], K4 extends keyof T[K1][K2][K3]>(object: T | null | undefined, path: [K1, K2, K3, K4]): T[K1][K2][K3][K4] | undefined;\n/**\n * Retrieves the value at a given path from an object. If the resolved value is undefined, the defaultValue is returned instead.\n * \n * @template T - The type of the object.\n * @template K1 - The type of the first key in the object.\n * @template K2 - The type of the second key in the object.\n * @template K3 - The type of the third key in the object.\n * @template K4 - The type of the fourth key in the object.\n * @template D - The type of the default value.\n * \n * @param {T | null | undefined} object - The object to query.\n * @param {[K1, K2, K3, K4]} path - The path of the property to get.\n * @param {D} defaultValue - The value returned if the resolved value is undefined.\n * @returns {Exclude<T[K1][K2][K3][K4], undefined> | D} - Returns the resolved value.\n */\nexport function get<T extends object, K1 extends keyof T, K2 extends keyof T[K1], K3 extends keyof T[K1][K2], K4 extends keyof T[K1][K2][K3], D>(object: T | null | undefined, path: [K1, K2, K3, K4], defaultValue: D): Exclude<T[K1][K2][K3][K4], undefined> | D;\n/**\n * Retrieves the value at a given path from an object with numeric keys. If the resolved value is undefined, the defaultValue is returned instead.\n * \n * @template T - The type of the value.\n * \n * @param {Record<number, T>} object - The object to query.\n * @param {number} path - The path of the property to get.\n * @returns {T} - Returns the resolved value.\n */\nexport function get<T>(object: Record<number, T>, path: number): T;\n/**\n * Retrieves the value at a given path from an object with numeric keys. If the resolved value is undefined, the defaultValue is returned instead.\n * \n * @template T - The type of the value.\n * \n * @param {Record<number, T> | null | undefined} object - The object to query.\n * @param {number} path - The path of the property to get.\n * @returns {T | undefined} - Returns the resolved value.\n */\nexport function get<T>(object: Record<number, T> | null | undefined, path: number): T | undefined;\n/**\n * Retrieves the value at a given path from an object with numeric keys. If the resolved value is undefined, the defaultValue is returned instead.\n * \n * @template T - The type of the value.\n * @template D - The type of the default value.\n * \n * @param {Record<number, T> | null | undefined} object - The object to query.\n * @param {number} path - The path of the property to get.\n * @param {D} defaultValue - The value returned if the resolved value is undefined.\n * @returns {T | D} - Returns the resolved value.\n */\nexport function get<T, D>(object: Record<number, T> | null | undefined, path: number, defaultValue: D): T | D;\n/**\n * Retrieves the value at a given path from a null or undefined object, returning the default value.\n * \n * @template D - The type of the default value.\n * \n * @param {null | undefined} object - The object to query.\n * @param {PropertyKey} path - The path of the property to get.\n * @param {D} defaultValue - The value returned if the resolved value is undefined.\n * @returns {D} - Returns the default value.\n */\nexport function get<D>(object: null | undefined, path: PropertyKey, defaultValue: D): D;\n/**\n * Retrieves the value at a given path from a null or undefined object, returning undefined.\n * \n * @param {null | undefined} object - The object to query.\n * @param {PropertyKey} path - The path of the property to get.\n * @returns {undefined} - Returns undefined.\n */\nexport function get(object: null | undefined, path: PropertyKey): undefined;\n/**\n * Retrieves the value at a given path from a string-keyed object. If the resolved value is undefined, the defaultValue is returned instead.\n * \n * @template T - The type of the object.\n * @template P - The type of the path.\n * \n * @param {T} data - The object to query.\n * @param {P} path - The path of the property to get.\n * @returns {string extends P ? any : Get<T, P>} - Returns the resolved value.\n */\nexport function get<T, P extends string>(data: T, path: P): string extends P ? any : Get<T, P>;\n/**\n * Retrieves the value at a given path from a string-keyed object. If the resolved value is undefined, the defaultValue is returned instead.\n * \n * @template T - The type of the object.\n * @template P - The type of the path.\n * @template D - The type of the default value.\n * \n * @param {T} data - The object to query.\n * @param {P} path - The path of the property to get.\n * @param {D} defaultValue - The value returned if the resolved value is undefined.\n * @returns {Exclude<Get<T, P>, null | undefined> | D} - Returns the resolved value.\n */\nexport function get<T, P extends string, D = Get<T, P>>(data: T, path: P, defaultValue: D): Exclude<Get<T, P>, null | undefined> | D;\n/**\n * Retrieves the value at a given path from an object. If the resolved value is undefined, the defaultValue is returned instead.\n * \n * @param {unknown} object - The object to query.\n * @param {PropertyKey | readonly PropertyKey[]} path - The path of the property to get.\n * @param {unknown} [defaultValue] - The value returned if the resolved value is undefined.\n * @returns {any} - Returns the resolved value.\n */\nexport function get(object: unknown, path: PropertyKey | readonly PropertyKey[], defaultValue?: unknown): any;\nexport function get(object: any, path: PropertyKey | readonly PropertyKey[], defaultValue?: any): any {\n let resolvedPath;\n\n if (Array.isArray(path)) {\n resolvedPath = path;\n } else if (typeof path === 'string' && isDeepKey(path) && object?.[path] == null) {\n resolvedPath = toPath(path);\n } else {\n resolvedPath = [path];\n }\n\n if (resolvedPath.length === 0) {\n return defaultValue;\n }\n\n let current = object;\n let index;\n\n for (index = 0; index < resolvedPath.length && current != null; index++) {\n let key = resolvedPath[index];\n\n if (Object.is(key.valueOf(), -0)) {\n key = '-0';\n }\n\n current = current[key];\n }\n\n if (current === null && index === resolvedPath.length) {\n return current;\n }\n\n return current ?? defaultValue;\n}","/**\n * Checks if a given value is a plain object.\n *\n * A plain object is an object created by the `{}` literal, `new Object()`, or\n * `Object.create(null)`.\n *\n * This function also handles objects with custom\n * `Symbol.toStringTag` properties.\n *\n * `Symbol.toStringTag` is a built-in symbol that a constructor can use to customize the\n * default string description of objects.\n *\n * @param {unknown} [object] - The value to check.\n * @returns {boolean} - True if the value is a plain object, otherwise false.\n *\n * @example\n * console.log(isPlainObject({})); // true\n * console.log(isPlainObject([])); // false\n * console.log(isPlainObject(null)); // false\n * console.log(isPlainObject(Object.create(null))); // true\n * console.log(isPlainObject(new Map())); // false\n */\nexport function isPlainObject(object?: unknown): boolean {\n if (typeof object !== 'object') {\n return false;\n }\n\n if (object == null) {\n return false;\n }\n\n if (Object.getPrototypeOf(object) === null) {\n return true;\n }\n\n if (object.toString() !== '[object Object]') {\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n const tag = object[Symbol.toStringTag];\n\n if (tag == null) {\n return false;\n }\n\n const isTagReadonly = !Object.getOwnPropertyDescriptor(object, Symbol.toStringTag)?.writable;\n\n if (isTagReadonly) {\n return false;\n }\n\n return object.toString() === `[object ${tag}]`;\n }\n\n let proto = object;\n\n while (Object.getPrototypeOf(proto) !== null) {\n proto = Object.getPrototypeOf(proto);\n }\n\n return Object.getPrototypeOf(object) === proto;\n}\n","/**\n * Checks if the given value is an array.\n *\n * This function tests whether the provided value is an array or not.\n * It returns `true` if the value is an array, and `false` otherwise.\n *\n * This function can also serve as a type predicate in TypeScript, narrowing the type of the argument to an array.\n *\n * @template T - The type of value.\n * @param {T} value - The value to test if it is an array.\n * @returns {value is Extract<T, unknown[]>} `true` if the value is an array, `false` otherwise.\n *\n * @example\n * const value1 = [1, 2, 3];\n * const value2 = 'abc';\n * const value3 = () => {};\n *\n * console.log(isArray(value1)); // true\n * console.log(isArray(value2)); // false\n * console.log(isArray(value3)); // false\n */\nexport function isArray<T>(value?: T): value is Extract<T, readonly unknown[]> {\n return Array.isArray(value);\n}\n","import { isTypedArray as isTypedArrayToolkit } from '../../predicate/isTypedArray.ts';\n\n/**\n * Checks if a value is a TypedArray.\n * @param {unknown} x The value to check.\n * @returns {x is\n * | Uint8Array\n * | Uint8ClampedArray\n * | Uint16Array\n * | Uint32Array\n * | BigUint64Array\n * | Int8Array\n * | Int16Array\n * | Int32Array\n * | BigInt64Array\n * | Float32Array\n * | Float64Array} Returns true if `x` is a TypedArray, false otherwise.\n */\nexport function isTypedArray(\n x?: unknown\n): x is\n | Uint8Array\n | Uint8ClampedArray\n | Uint16Array\n | Uint32Array\n | BigUint64Array\n | Int8Array\n | Int16Array\n | Int32Array\n | BigInt64Array\n | Float32Array\n | Float64Array {\n return isTypedArrayToolkit(x);\n}\n","import { isMatch } from '../predicate/isMatch.ts';\n\nexport function isArrayMatch(target: unknown, source: readonly unknown[]) {\n if (source.length === 0) {\n return true;\n }\n\n if (!Array.isArray(target)) {\n return false;\n }\n\n const countedIndex = new Set<number>();\n\n for (let i = 0; i < source.length; i++) {\n const sourceItem = source[i];\n const index = target.findIndex((targetItem, index) => {\n return isMatch(targetItem, sourceItem) && !countedIndex.has(index);\n });\n\n if (index === -1) {\n return false;\n }\n\n countedIndex.add(index);\n }\n\n return true;\n}\n","import { isMatch } from '../predicate/isMatch.ts';\n\nexport function isMapMatch(target: unknown, source: Map<any, any>) {\n if (source.size === 0) {\n return true;\n }\n\n if (!(target instanceof Map)) {\n return false;\n }\n\n for (const [key, value] of source.entries()) {\n if (!isMatch(target.get(key), value)) {\n return false;\n }\n }\n\n return true;\n}\n","import { isArrayMatch } from './isArrayMatch.ts';\n\nexport function isSetMatch(target: unknown, source: Set<any>) {\n if (source.size === 0) {\n return true;\n }\n\n if (!(target instanceof Set)) {\n return false;\n }\n\n return isArrayMatch([...target], [...source]);\n}\n","import { isPrimitive } from '../../predicate/isPrimitive.ts';\nimport { isArrayMatch } from '../_internal/isArrayMatch.ts';\nimport { isMapMatch } from '../_internal/isMapMatch.ts';\nimport { isSetMatch } from '../_internal/isSetMatch.ts';\n\n/**\n * Checks if the target matches the source by comparing their structures and values.\n * This function supports deep comparison for objects, arrays, maps, and sets.\n * \n * @param {unknown} target - The target value to match against.\n * @param {unknown} source - The source value to match with.\n * @returns {boolean} - Returns `true` if the target matches the source, otherwise `false`.\n *\n * @example\n * // Basic usage\n * isMatch({ a: 1, b: 2 }, { a: 1 }); // true\n *\n * @example\n * // Matching arrays\n * isMatch([1, 2, 3], [1, 2, 3]); // true\n *\n * @example\n * // Matching maps\n * const targetMap = new Map([['key1', 'value1'], ['key2', 'value2']]);\n * const sourceMap = new Map([['key1', 'value1']]);\n * isMatch(targetMap, sourceMap); // true\n *\n * @example\n * // Matching sets\n * const targetSet = new Set([1, 2, 3]);\n * const sourceSet = new Set([1, 2]);\n * isMatch(targetSet, sourceSet); // true\n */\nexport function isMatch(target: unknown, source: unknown): boolean;\nexport function isMatch(target: any, source: any): boolean {\n if (source === target) {\n return true;\n }\n\n switch (typeof source) {\n case 'object': {\n if (source == null) {\n return true;\n }\n\n source = source ?? {};\n\n const keys = Object.keys(source as any);\n\n if (target == null) {\n if (keys.length === 0) {\n return true;\n }\n\n return false;\n }\n\n if (Array.isArray(source)) {\n return isArrayMatch(target, source);\n }\n\n if (source instanceof Map) {\n return isMapMatch(target, source);\n }\n\n if (source instanceof Set) {\n return isSetMatch(target, source);\n }\n\n for (let i = 0; i < keys.length; i++) {\n const key = keys[i];\n\n if (!isPrimitive(target) && !(key in target)) {\n return false;\n }\n\n if (source[key] === undefined && target[key] !== undefined) {\n return false;\n }\n\n if (!isMatch(target[key], source[key])) {\n return false;\n }\n }\n\n return true;\n }\n case 'function': {\n if (Object.keys(source).length > 0) {\n return isMatch(target, { ...source });\n }\n\n return false;\n }\n default: {\n return !source;\n }\n }\n}\n","import { cloneDeep } from '../../object/cloneDeep.ts';\nimport { isMatch } from './isMatch.ts';\n\n/**\n * Creates a function that performs a deep comparison between a given target and the source object.\n * \n * @param {unknown} source - The source object to create the matcher from.\n * @returns {(target: unknown) => boolean} - Returns a function that takes a target object and returns `true` if the target matches the source, otherwise `false`.\n *\n * @example\n * // Basic usage\n * const matcher = matches({ a: 1, b: 2 });\n * matcher({ a: 1, b: 2, c: 3 }); // true\n * matcher({ a: 1, c: 3 }); // false\n *\n * @example\n * // Matching arrays\n * const arrayMatcher = matches([1, 2, 3]);\n * arrayMatcher([1, 2, 3, 4]); // true\n * arrayMatcher([4, 5, 6]); // false\n *\n * @example\n * // Matching objects with nested structures\n * const nestedMatcher = matches({ a: { b: 2 } });\n * nestedMatcher({ a: { b: 2, c: 3 } }); // true\n * nestedMatcher({ a: { c: 3 } }); // false\n */\nexport function matches(source: unknown): (target: unknown) => boolean {\n source = cloneDeep(source);\n\n return (target?: unknown): boolean => {\n return isMatch(target, source);\n };\n}\n","/**\n * Checks if a string contains another string at the beginning of the string.\n *\n * Checks if one string startsWith another string. Optional position parameter to start searching from a certain index.\n *\n * @param {string} str - The string that might contain the target string.\n * @param {string} target - The string to search for.\n * @param {number} position - An optional offset to start searching in the str string\n * @returns {boolean} - True if the str string starts with the target string.\n *\n * @example\n * const isPrefix = startsWith('fooBar', 'foo') // returns true\n * const isPrefix = startsWith('fooBar', 'bar') // returns false\n * const isPrefix = startsWith('fooBar', 'abc') // returns false\n * const isPrefix = startsWith('fooBar', 'Bar', 2) // returns true\n * const isPrefix = startsWith('fooBar', 'Bar', 5) // returns false\n */\nexport const startsWith = (str: string, target: string, position = 0): boolean => {\n return str.startsWith(target, position);\n};\n","/**\n * Checks if a string contains another string at the end of the string.\n *\n * Checks if one string endsWith another string. Optional position parameter to offset searching before a certain index.\n *\n * @param {string} str - The string that might contain the target string.\n * @param {string} target - The string to search for.\n * @param {number} position - An optional position from the start to search up to this index\n * @returns {boolean} - True if the str string ends with the target string.\n *\n * @example\n * const isPrefix = endsWith('fooBar', 'foo') // returns true\n * const isPrefix = endsWith('fooBar', 'bar') // returns false\n * const isPrefix = endsWith('fooBar', 'abc') // returns false\n * const isPrefix = endsWith('fooBar', 'foo', 3) // returns true\n * const isPrefix = endsWith('fooBar', 'abc', 5) // returns false\n */\nexport const endsWith = (str: string, target: string, position: number = str.length): boolean => {\n return str.endsWith(target, position);\n};\n","/**\n * Finds the element in an array that has the maximum value.\n *\n * @template T - The type of elements in the array.\n * @param {T[]} items The array of elements to search.\n * @returns {T | undefined} The element with the maximum value.\n * @example\n * // Returns 9\n * max([3, 1, 4, 1, 5, 9])\n *\n * @example\n * // Returns 8\n * max([0, -3, 2, 8, 7])\n */\nexport function max<T>(items: readonly [T, ...T[]]): T;\nexport function max(): undefined;\nexport function max<T>(items?: readonly T[]): T | undefined;\nexport function max<T>(items: readonly T[] = []): T | undefined {\n let maxElement = items[0];\n let max = undefined;\n\n for (const element of items) {\n if (max == null || element > max) {\n max = element;\n maxElement = element;\n }\n }\n\n return maxElement;\n}\n","/**\n * Finds the element in an array that has the minimum value.\n *\n * @template T - The type of elements in the array.\n * @param {T[]} items The array of elements to search.\n * @returns {T | undefined} The element with the minimum value.\n * @example\n * // Returns 1\n * min([3, 1, 4, 1, 5, 9])\n *\n * @example\n * // Returns -3\n * min([0, -3, 2, 8, 7])\n */\nexport function min<T>(items: readonly [T, ...T[]]): T;\nexport function min(): undefined;\nexport function min<T>(items?: readonly T[]): T | undefined;\nexport function min<T>(items: readonly T[] = []): T {\n let minElement = items[0];\n let min = undefined;\n\n for (const element of items) {\n if (min == null || element < min) {\n min = element;\n minElement = element;\n }\n }\n\n return minElement;\n}\n"],"names":["chunkToolkit","flatten","differenceToolkit","fillToolkit","zip","isTypedArrayToolkit","isPrimitive","cloneDeep"],"mappings":";;;;;;;;;;;;;;SAyBgB,KAAK,CAAI,GAAiB,EAAE,IAAI,GAAG,CAAC,EAAA;AAClD,IAAA,IAAI,GAAG,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC;AAErC,IAAA,IAAI,IAAI,KAAK,CAAC,EAAE;AACd,QAAA,OAAO,EAAE,CAAC;KACX;AAED,IAAA,OAAOA,iBAAY,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC;AACjC;;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AAG,IAAI,IAAI,IAAI,OAAO,GAAG,GAAG,EAAE;YAChC,GAAG,GAAG,OAAO,CAAC;YACd,UAAU,GAAG,OAAO,CAAC;SACtB;KACF;AAED,IAAA,OAAO,UAAU,CAAC;AACpB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"index.js","sources":["../../src/compat/array/chunk.ts","../../src/compat/array/concat.ts","../../src/compat/array/difference.ts","../../src/compat/array/fill.ts","../../src/compat/_internal/isIndex.ts","../../src/compat/_internal/toPath.ts","../../src/compat/object/set.ts","../../src/compat/array/zipObjectDeep.ts","../../src/compat/_internal/isDeepKey.ts","../../src/compat/object/get.ts","../../src/compat/predicate/isPlainObject.ts","../../src/compat/predicate/isArray.ts","../../src/compat/predicate/isTypedArray.ts","../../src/compat/_internal/isArrayMatch.ts","../../src/compat/_internal/isMapMatch.ts","../../src/compat/_internal/isSetMatch.ts","../../src/compat/predicate/isMatch.ts","../../src/compat/predicate/matches.ts","../../src/compat/string/startsWith.ts","../../src/compat/string/endsWith.ts","../../src/compat/math/max.ts","../../src/compat/math/min.ts"],"sourcesContent":["import { chunk as chunkToolkit } from '../../array/chunk.ts';\n\n/**\n * Splits an array into smaller arrays of a specified length.\n *\n * This function takes an input array and divides it into multiple smaller arrays,\n * each of a specified length. If the input array cannot be evenly divided,\n * the final sub-array will contain the remaining elements.\n *\n * @template T The type of elements in the array.\n * @param {T[]} arr - The array to be chunked into smaller arrays.\n * @param {number} size - The size of each smaller array. Must be a positive integer.\n * @returns {T[][]} A two-dimensional array where each sub-array has a maximum length of `size`.\n * @throws {Error} Throws an error if `size` is not a positive integer.\n *\n * @example\n * // Splits an array of numbers into sub-arrays of length 2\n * chunk([1, 2, 3, 4, 5], 2);\n * // Returns: [[1, 2], [3, 4], [5]]\n *\n * @example\n * // Splits an array of strings into sub-arrays of length 3\n * chunk(['a', 'b', 'c', 'd', 'e', 'f', 'g'], 3);\n * // Returns: [['a', 'b', 'c'], ['d', 'e', 'f'], ['g']]\n */\nexport function chunk<T>(arr: readonly T[], size = 1): T[][] {\n size = Math.max(Math.floor(size), 0);\n\n if (size === 0) {\n return [];\n }\n\n return chunkToolkit(arr, size);\n}\n","import { flatten } from '../../array/flatten.ts';\n\n/**\n * Concatenates multiple arrays and values into a single array.\n *\n * @template T The type of elements in the array.\n * @param {...(T | T[])} values - The values and/or arrays to concatenate.\n * @returns {T[]} A new array containing all the input values.\n *\n * @example\n * // Concatenate individual values\n * concat(1, 2, 3);\n * // returns [1, 2, 3]\n *\n * @example\n * // Concatenate arrays of values\n * concat([1, 2], [3, 4]);\n * // returns [1, 2, 3, 4]\n *\n * @example\n * // Concatenate a mix of individual values and arrays\n * concat(1, [2, 3], 4);\n * // returns [1, 2, 3, 4]\n *\n * @example\n * // Concatenate nested arrays\n * concat([1, [2, 3]], 4);\n * // returns [1, [2, 3], 4]\n */\nexport function concat<T>(...values: Array<T | readonly T[]>): T[] {\n return flatten(values) as T[];\n}\n","import { difference as differenceToolkit } from '../../array/difference.ts';\nimport { flatten } from '../../array/flatten.ts';\n\nexport function difference<T>(arr: readonly T[], ...values: Array<readonly T[]>): T[] {\n const arr1 = arr;\n const arr2 = flatten(values);\n\n return differenceToolkit(arr1, arr2);\n}","import { fill as fillToolkit } from '../../array/fill.ts';\n\n/**\n * Fills elements of an array with a specified value from the start position up to, but not including, the end position.\n *\n * This function mutates the original array and replaces its elements with the provided value, starting from the specified\n * start index up to the end index (non-inclusive). If the start or end indices are not provided, it defaults to filling the\n * entire array.\n *\n * @template T, U, S, V\n * @param {Array<T | U>} array - The array to fill.\n * @param {U} value - The value to fill the array with.\n * @param {S} [start=0] - The start position. Defaults to 0.\n * @param {V} [end=arr.length] - The end position. Defaults to the array's length.\n * @returns {Array<T | U>} The array with the filled values.\n *\n * @example\n * const array = [1, 2, 3];\n * const result = fill(array, 'a');\n * // => ['a', 'a', 'a']\n *\n * const result = fill(Array(3), 2);\n * // => [2, 2, 2]\n *\n * const result = fill([4, 6, 8, 10], '*', 1, 3);\n * // => [4, '*', '*', 10]\n *\n * const result = fill(array, '*', -2, -1);\n * // => [1, '*', 3]\n */\nexport function fill<T>(array: unknown[], value?: T): T[];\nexport function fill<T, U, S>(array: Array<T | U>, value: U, start: S): Array<T | U>;\nexport function fill<T, U, S, V>(array: Array<T | U>, value: U, start: S, end: V): Array<T | U>;\nexport function fill<T, U>(array: Array<T | U>, value: U, start = 0, end = array.length): Array<T | U> {\n start = Math.floor(start);\n end = Math.floor(end);\n\n if (!start) {\n start = 0;\n }\n if (!end) {\n end = 0;\n }\n\n return fillToolkit(array, value, start, end);\n}\n","const IS_UNSIGNED_INTEGER = /^(?:0|[1-9]\\d*)$/\n\nexport function isIndex(value: PropertyKey) {\n switch (typeof value) {\n case 'number': {\n return Number.isInteger(value) && value >= 0 && value < Number.MAX_SAFE_INTEGER;\n }\n case 'symbol': {\n return false;\n }\n case 'string': {\n return IS_UNSIGNED_INTEGER.test(value);\n }\n }\n}","/**\n * Converts a deep key string into an array of path segments.\n *\n * This function takes a string representing a deep key (e.g., 'a.b.c' or 'a[b][c]') and breaks it down into an array of strings, each representing a segment of the path.\n *\n * @param {string} deepKey - The deep key string to convert.\n * @returns {string[]} An array of strings, each representing a segment of the path.\n *\n * Examples:\n *\n * toPath('a.b.c') // Returns ['a', 'b', 'c']\n * toPath('a[b][c]') // Returns ['a', 'b', 'c']\n * toPath('.a.b.c') // Returns ['', 'a', 'b', 'c']\n * toPath('a[\"b.c\"].d') // Returns ['a', 'b.c', 'd']\n * toPath('') // Returns []\n * toPath('.a[b].c.d[e][\"f.g\"].h') // Returns ['', 'a', 'b', 'c', 'd', 'e', 'f.g', 'h']\n */\nexport function toPath(deepKey: string): string[] {\n const ESCAPE_REGEXP = /\\\\(\\\\)?/g;\n const PROPERTY_REGEXP = RegExp(\n // Match anything that isn't a dot or bracket.\n '[^.[\\\\]]+' +\n '|' +\n // Or match property names within brackets.\n '\\\\[(?:' +\n // Match a non-string expression.\n '([^\"\\'][^[]*)' +\n '|' +\n // Or match strings (supports escaping characters).\n '([\"\\'])((?:(?!\\\\2)[^\\\\\\\\]|\\\\\\\\.)*?)\\\\2' +\n ')\\\\]' +\n '|' +\n // Or match \"\" as the space between consecutive dots or empty brackets.\n '(?=(?:\\\\.|\\\\[\\\\])(?:\\\\.|\\\\[\\\\]|$))',\n 'g'\n );\n\n const result: string[] = [];\n\n if (deepKey[0] === '.') {\n result.push('');\n }\n\n let match: RegExpExecArray | null;\n let lastIndex = 0;\n\n while ((match = PROPERTY_REGEXP.exec(deepKey)) !== null) {\n let key = match[0];\n const expr = match[1];\n const quote = match[2];\n const substr = match[3];\n\n if (quote) {\n key = substr.replace(ESCAPE_REGEXP, '$1');\n } else if (expr) {\n key = expr;\n }\n\n result.push(key);\n\n if (PROPERTY_REGEXP.lastIndex === lastIndex) {\n PROPERTY_REGEXP.lastIndex++;\n } else {\n lastIndex = PROPERTY_REGEXP.lastIndex;\n }\n }\n\n return result;\n}\n","import { isIndex } from \"../_internal/isIndex.ts\";\nimport { toPath } from \"../_internal/toPath.ts\";\n\n/**\n * Sets the value at the specified path of the given object. If any part of the path does not exist, it will be created.\n *\n * @template T - The type of the object.\n * @param {Settable} obj - The object to modify.\n * @param {Path} path - The path of the property to set.\n * @param {any} value - The value to set.\n * @returns {T} - The modified object.\n *\n * @example\n * // Set a value in a nested object\n * const obj = { a: { b: { c: 3 } } };\n * set(obj, 'a.b.c', 4);\n * console.log(obj.a.b.c); // 4\n *\n * @example\n * // Set a value in an array\n * const arr = [1, 2, 3];\n * set(arr, 1, 4);\n * console.log(arr[1]); // 4\n *\n * @example\n * // Create non-existent path and set value\n * const obj = {};\n * set(obj, 'a.b.c', 4);\n * console.log(obj); // { a: { b: { c: 4 } } }\n */\nexport function set<T>(obj: object, path: PropertyKey | readonly PropertyKey[], value: unknown): T;\nexport function set<T extends object>(obj: T, path: PropertyKey | readonly PropertyKey[], value: unknown): T {\n const resolvedPath = Array.isArray(path)\n ? path\n : typeof path === 'string'\n ? toPath(path)\n : [path];\n\n let current: any = obj;\n\n for (let i = 0; i < resolvedPath.length - 1; i++) {\n const key = resolvedPath[i];\n const nextKey = resolvedPath[i + 1];\n\n if (current[key] == null) {\n current[key] = isIndex(nextKey) ? [] : {};\n }\n\n current = current[key];\n }\n\n const lastKey = resolvedPath[resolvedPath.length - 1];\n current[lastKey] = value;\n\n return obj;\n}\n","import { zip } from \"../../array/zip.ts\";\nimport { set } from \"../object/set.ts\";\n\n/**\n * Creates a deeply nested object given arrays of paths and values.\n *\n * This function takes two arrays: one containing arrays of property paths, and the other containing corresponding values.\n * It returns a new object where paths from the first array are used as key paths to set values, with corresponding elements from the second array as values.\n * Paths can be dot-separated strings or arrays of property names.\n * \n * If the `keys` array is longer than the `values` array, the remaining keys will have `undefined` as their values.\n *\n * @template V - The type of elements in the array.\n * @param {P[] | P[][]} keys - An array of property paths, each path can be a dot-separated string or an array of property names.\n * @param {V[]} values - An array of values corresponding to the property paths.\n * @returns {object} A new object composed of the given property paths and values.\n *\n * @example\n * const paths = ['a.b.c', 'd.e.f'];\n * const values = [1, 2];\n * const result = zipObjectDeep(paths, values);\n * // result will be { a: { b: { c: 1 } }, d: { e: { f: 2 } } }\n *\n * @example\n * const paths = [['a', 'b', 'c'], ['d', 'e', 'f']];\n * const values = [1, 2];\n * const result = zipObjectDeep(paths, values);\n * // result will be { a: { b: { c: 1 } }, d: { e: { f: 2 } } }\n * \n * @example\n * const paths = ['a.b[0].c', 'a.b[1].d'];\n * const values = [1, 2];\n * const result = zipObjectDeep(paths, values);\n * // result will be { 'a': { 'b': [{ 'c': 1 }, { 'd': 2 }] } }\n */\nexport function zipObjectDeep<P extends PropertyKey, V>(keys: P[] | P[][], values: V[]): { [K in P]: V } {\n const result = {} as { [K in P]: V };\n const zipped = zip<P | P[], V>(keys, values);\n\n for (let i = 0; i < zipped.length; i++) {\n const [key, value] = zipped[i];\n\n if (key != null) {\n set(result, key, value);\n }\n }\n\n return result;\n}\n","const IS_PLAIN = /^\\w*$/;\nconst IS_DEEP = /\\.|\\[(?:[^[\\]]*|([\"'])(?:(?!\\1)[^\\\\]|\\\\.)*?\\1)\\]/;\n\n/**\n * Checks if a given key is a deep key.\n *\n * A deep key is a string that contains a dot (.) or square brackets with a property accessor.\n *\n * @param {PropertyKey} key - The key to check.\n * @returns {boolean} - Returns true if the key is a deep key, otherwise false.\n *\n * Examples:\n *\n * isDeepKey('a.b') // true\n * isDeepKey('a[b]') // true\n * isDeepKey('a') // false\n * isDeepKey(123) // false\n * isDeepKey('a.b.c') // true\n * isDeepKey('a[b][c]') // true\n */\nexport function isDeepKey(key: PropertyKey): boolean {\n switch (typeof key) {\n case 'number':\n case 'symbol': {\n return false;\n }\n case 'string': {\n return !IS_PLAIN.test(key) && IS_DEEP.test(key);\n }\n }\n}\n","import { isDeepKey } from \"../_internal/isDeepKey.ts\";\nimport { toPath } from \"../_internal/toPath.ts\";\nimport type { Get } from \"./get.types.ts\";\n\n/**\n * Retrieves the value at a given path from an object. If the resolved value is undefined, the defaultValue is returned instead.\n * \n * @template T - The type of the object.\n * @template K - The type of the key in the object.\n * @template D - The type of the default value.\n * \n * @param {T} object - The object to query.\n * @param {K | [K]} path - The path of the property to get.\n * @returns {T[K]} - Returns the resolved value.\n */\nexport function get<T extends object, K extends keyof T>(object: T, path: K | [K]): T[K];\n/**\n * Retrieves the value at a given path from an object. If the resolved value is undefined, the defaultValue is returned instead.\n * \n * @template T - The type of the object.\n * @template K - The type of the key in the object.\n * \n * @param {T | null | undefined} object - The object to query.\n * @param {K | [K]} path - The path of the property to get.\n * @returns {T[K] | undefined} - Returns the resolved value.\n */\nexport function get<T extends object, K extends keyof T>(object: T | null | undefined, path: K | [K]): T[K] | undefined;\n/**\n * Retrieves the value at a given path from an object. If the resolved value is undefined, the defaultValue is returned instead.\n * \n * @template T - The type of the object.\n * @template K - The type of the key in the object.\n * @template D - The type of the default value.\n * \n * @param {T | null | undefined} object - The object to query.\n * @param {K | [K]} path - The path of the property to get.\n * @param {D} defaultValue - The value returned if the resolved value is undefined.\n * @returns {Exclude<T[K], undefined> | D} - Returns the resolved value.\n */\nexport function get<T extends object, K extends keyof T, D>(object: T | null | undefined, path: K | [K], defaultValue: D): Exclude<T[K], undefined> | D;\n/**\n * Retrieves the value at a given path from an object. If the resolved value is undefined, the defaultValue is returned instead.\n * \n * @template T - The type of the object.\n * @template K1 - The type of the first key in the object.\n * @template K2 - The type of the second key in the object.\n * \n * @param {T} object - The object to query.\n * @param {[K1, K2]} path - The path of the property to get.\n * @returns {T[K1][K2]} - Returns the resolved value.\n */\nexport function get<T extends object, K1 extends keyof T, K2 extends keyof T[K1]>(object: T, path: [K1, K2]): T[K1][K2];\n/**\n * Retrieves the value at a given path from an object. If the resolved value is undefined, the defaultValue is returned instead.\n * \n * @template T - The type of the object.\n * @template K1 - The type of the first key in the object.\n * @template K2 - The type of the second key in the object.\n * \n * @param {T | null | undefined} object - The object to query.\n * @param {[K1, K2]} path - The path of the property to get.\n * @returns {T[K1][K2] | undefined} - Returns the resolved value.\n */\nexport function get<T extends object, K1 extends keyof T, K2 extends keyof T[K1]>(object: T | null | undefined, path: [K1, K2]): T[K1][K2] | undefined;\n/**\n * Retrieves the value at a given path from an object. If the resolved value is undefined, the defaultValue is returned instead.\n * \n * @template T - The type of the object.\n * @template K1 - The type of the first key in the object.\n * @template K2 - The type of the second key in the object.\n * @template D - The type of the default value.\n * \n * @param {T | null | undefined} object - The object to query.\n * @param {[K1, K2]} path - The path of the property to get.\n * @param {D} defaultValue - The value returned if the resolved value is undefined.\n * @returns {Exclude<T[K1][K2], undefined> | D} - Returns the resolved value.\n */\nexport function get<T extends object, K1 extends keyof T, K2 extends keyof T[K1], D>(object: T | null | undefined, path: [K1, K2], defaultValue: D): Exclude<T[K1][K2], undefined> | D;\n/**\n * Retrieves the value at a given path from an object. If the resolved value is undefined, the defaultValue is returned instead.\n * \n * @template T - The type of the object.\n * @template K1 - The type of the first key in the object.\n * @template K2 - The type of the second key in the object.\n * @template K3 - The type of the third key in the object.\n * \n * @param {T} object - The object to query.\n * @param {[K1, K2, K3]} path - The path of the property to get.\n * @returns {T[K1][K2][K3]} - Returns the resolved value.\n */\nexport function get<T extends object, K1 extends keyof T, K2 extends keyof T[K1], K3 extends keyof T[K1][K2]>(object: T, path: [K1, K2, K3]): T[K1][K2][K3];\n/**\n * Retrieves the value at a given path from an object. If the resolved value is undefined, the defaultValue is returned instead.\n * \n * @template T - The type of the object.\n * @template K1 - The type of the first key in the object.\n * @template K2 - The type of the second key in the object.\n * @template K3 - The type of the third key in the object.\n * \n * @param {T | null | undefined} object - The object to query.\n * @param {[K1, K2, K3]} path - The path of the property to get.\n * @returns {T[K1][K2][K3] | undefined} - Returns the resolved value.\n */\nexport function get<T extends object, K1 extends keyof T, K2 extends keyof T[K1], K3 extends keyof T[K1][K2]>(object: T | null | undefined, path: [K1, K2, K3]): T[K1][K2][K3] | undefined;\n/**\n * Retrieves the value at a given path from an object. If the resolved value is undefined, the defaultValue is returned instead.\n * \n * @template T - The type of the object.\n * @template K1 - The type of the first key in the object.\n * @template K2 - The type of the second key in the object.\n * @template K3 - The type of the third key in the object.\n * @template D - The type of the default value.\n * \n * @param {T | null | undefined} object - The object to query.\n * @param {[K1, K2, K3]} path - The path of the property to get.\n * @param {D} defaultValue - The value returned if the resolved value is undefined.\n * @returns {Exclude<T[K1][K2][K3], undefined> | D} - Returns the resolved value.\n */\nexport function get<T extends object, K1 extends keyof T, K2 extends keyof T[K1], K3 extends keyof T[K1][K2], D>(object: T | null | undefined, path: [K1, K2, K3], defaultValue: D): Exclude<T[K1][K2][K3], undefined> | D;\n/**\n * Retrieves the value at a given path from an object. If the resolved value is undefined, the defaultValue is returned instead.\n * \n * @template T - The type of the object.\n * @template K1 - The type of the first key in the object.\n * @template K2 - The type of the second key in the object.\n * @template K3 - The type of the third key in the object.\n * @template K4 - The type of the fourth key in the object.\n * \n * @param {T} object - The object to query.\n * @param {[K1, K2, K3, K4]} path - The path of the property to get.\n * @returns {T[K1][K2][K3][K4]} - Returns the resolved value.\n */\nexport function get<T extends object, K1 extends keyof T, K2 extends keyof T[K1], K3 extends keyof T[K1][K2], K4 extends keyof T[K1][K2][K3]>(object: T, path: [K1, K2, K3, K4]): T[K1][K2][K3][K4];\n/**\n * Retrieves the value at a given path from an object. If the resolved value is undefined, the defaultValue is returned instead.\n * \n * @template T - The type of the object.\n * @template K1 - The type of the first key in the object.\n * @template K2 - The type of the second key in the object.\n * @template K3 - The type of the third key in the object.\n * @template K4 - The type of the fourth key in the object.\n * \n * @param {T | null | undefined} object - The object to query.\n * @param {[K1, K2, K3, K4]} path - The path of the property to get.\n * @returns {T[K1][K2][K3][K4] | undefined} - Returns the resolved value.\n */\nexport function get<T extends object, K1 extends keyof T, K2 extends keyof T[K1], K3 extends keyof T[K1][K2], K4 extends keyof T[K1][K2][K3]>(object: T | null | undefined, path: [K1, K2, K3, K4]): T[K1][K2][K3][K4] | undefined;\n/**\n * Retrieves the value at a given path from an object. If the resolved value is undefined, the defaultValue is returned instead.\n * \n * @template T - The type of the object.\n * @template K1 - The type of the first key in the object.\n * @template K2 - The type of the second key in the object.\n * @template K3 - The type of the third key in the object.\n * @template K4 - The type of the fourth key in the object.\n * @template D - The type of the default value.\n * \n * @param {T | null | undefined} object - The object to query.\n * @param {[K1, K2, K3, K4]} path - The path of the property to get.\n * @param {D} defaultValue - The value returned if the resolved value is undefined.\n * @returns {Exclude<T[K1][K2][K3][K4], undefined> | D} - Returns the resolved value.\n */\nexport function get<T extends object, K1 extends keyof T, K2 extends keyof T[K1], K3 extends keyof T[K1][K2], K4 extends keyof T[K1][K2][K3], D>(object: T | null | undefined, path: [K1, K2, K3, K4], defaultValue: D): Exclude<T[K1][K2][K3][K4], undefined> | D;\n/**\n * Retrieves the value at a given path from an object with numeric keys. If the resolved value is undefined, the defaultValue is returned instead.\n * \n * @template T - The type of the value.\n * \n * @param {Record<number, T>} object - The object to query.\n * @param {number} path - The path of the property to get.\n * @returns {T} - Returns the resolved value.\n */\nexport function get<T>(object: Record<number, T>, path: number): T;\n/**\n * Retrieves the value at a given path from an object with numeric keys. If the resolved value is undefined, the defaultValue is returned instead.\n * \n * @template T - The type of the value.\n * \n * @param {Record<number, T> | null | undefined} object - The object to query.\n * @param {number} path - The path of the property to get.\n * @returns {T | undefined} - Returns the resolved value.\n */\nexport function get<T>(object: Record<number, T> | null | undefined, path: number): T | undefined;\n/**\n * Retrieves the value at a given path from an object with numeric keys. If the resolved value is undefined, the defaultValue is returned instead.\n * \n * @template T - The type of the value.\n * @template D - The type of the default value.\n * \n * @param {Record<number, T> | null | undefined} object - The object to query.\n * @param {number} path - The path of the property to get.\n * @param {D} defaultValue - The value returned if the resolved value is undefined.\n * @returns {T | D} - Returns the resolved value.\n */\nexport function get<T, D>(object: Record<number, T> | null | undefined, path: number, defaultValue: D): T | D;\n/**\n * Retrieves the value at a given path from a null or undefined object, returning the default value.\n * \n * @template D - The type of the default value.\n * \n * @param {null | undefined} object - The object to query.\n * @param {PropertyKey} path - The path of the property to get.\n * @param {D} defaultValue - The value returned if the resolved value is undefined.\n * @returns {D} - Returns the default value.\n */\nexport function get<D>(object: null | undefined, path: PropertyKey, defaultValue: D): D;\n/**\n * Retrieves the value at a given path from a null or undefined object, returning undefined.\n * \n * @param {null | undefined} object - The object to query.\n * @param {PropertyKey} path - The path of the property to get.\n * @returns {undefined} - Returns undefined.\n */\nexport function get(object: null | undefined, path: PropertyKey): undefined;\n/**\n * Retrieves the value at a given path from a string-keyed object. If the resolved value is undefined, the defaultValue is returned instead.\n * \n * @template T - The type of the object.\n * @template P - The type of the path.\n * \n * @param {T} data - The object to query.\n * @param {P} path - The path of the property to get.\n * @returns {string extends P ? any : Get<T, P>} - Returns the resolved value.\n */\nexport function get<T, P extends string>(data: T, path: P): string extends P ? any : Get<T, P>;\n/**\n * Retrieves the value at a given path from a string-keyed object. If the resolved value is undefined, the defaultValue is returned instead.\n * \n * @template T - The type of the object.\n * @template P - The type of the path.\n * @template D - The type of the default value.\n * \n * @param {T} data - The object to query.\n * @param {P} path - The path of the property to get.\n * @param {D} defaultValue - The value returned if the resolved value is undefined.\n * @returns {Exclude<Get<T, P>, null | undefined> | D} - Returns the resolved value.\n */\nexport function get<T, P extends string, D = Get<T, P>>(data: T, path: P, defaultValue: D): Exclude<Get<T, P>, null | undefined> | D;\n/**\n * Retrieves the value at a given path from an object. If the resolved value is undefined, the defaultValue is returned instead.\n * \n * @param {unknown} object - The object to query.\n * @param {PropertyKey | readonly PropertyKey[]} path - The path of the property to get.\n * @param {unknown} [defaultValue] - The value returned if the resolved value is undefined.\n * @returns {any} - Returns the resolved value.\n */\nexport function get(object: unknown, path: PropertyKey | readonly PropertyKey[], defaultValue?: unknown): any;\nexport function get(object: any, path: PropertyKey | readonly PropertyKey[], defaultValue?: any): any {\n let resolvedPath;\n\n if (Array.isArray(path)) {\n resolvedPath = path;\n } else if (typeof path === 'string' && isDeepKey(path) && object?.[path] == null) {\n resolvedPath = toPath(path);\n } else {\n resolvedPath = [path];\n }\n\n if (resolvedPath.length === 0) {\n return defaultValue;\n }\n\n let current = object;\n let index;\n\n for (index = 0; index < resolvedPath.length && current != null; index++) {\n let key = resolvedPath[index];\n\n if (Object.is(key.valueOf(), -0)) {\n key = '-0';\n }\n\n current = current[key];\n }\n\n if (current === null && index === resolvedPath.length) {\n return current;\n }\n\n return current ?? defaultValue;\n}","/**\n * Checks if a given value is a plain object.\n *\n * A plain object is an object created by the `{}` literal, `new Object()`, or\n * `Object.create(null)`.\n *\n * This function also handles objects with custom\n * `Symbol.toStringTag` properties.\n *\n * `Symbol.toStringTag` is a built-in symbol that a constructor can use to customize the\n * default string description of objects.\n *\n * @param {unknown} [object] - The value to check.\n * @returns {boolean} - True if the value is a plain object, otherwise false.\n *\n * @example\n * console.log(isPlainObject({})); // true\n * console.log(isPlainObject([])); // false\n * console.log(isPlainObject(null)); // false\n * console.log(isPlainObject(Object.create(null))); // true\n * console.log(isPlainObject(new Map())); // false\n */\nexport function isPlainObject(object?: unknown): boolean {\n if (typeof object !== 'object') {\n return false;\n }\n\n if (object == null) {\n return false;\n }\n\n if (Object.getPrototypeOf(object) === null) {\n return true;\n }\n\n if (object.toString() !== '[object Object]') {\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n const tag = object[Symbol.toStringTag];\n\n if (tag == null) {\n return false;\n }\n\n const isTagReadonly = !Object.getOwnPropertyDescriptor(object, Symbol.toStringTag)?.writable;\n\n if (isTagReadonly) {\n return false;\n }\n\n return object.toString() === `[object ${tag}]`;\n }\n\n let proto = object;\n\n while (Object.getPrototypeOf(proto) !== null) {\n proto = Object.getPrototypeOf(proto);\n }\n\n return Object.getPrototypeOf(object) === proto;\n}\n","/**\n * Checks if the given value is an array.\n *\n * This function tests whether the provided value is an array or not.\n * It returns `true` if the value is an array, and `false` otherwise.\n *\n * This function can also serve as a type predicate in TypeScript, narrowing the type of the argument to an array.\n *\n * @template T - The type of value.\n * @param {T} value - The value to test if it is an array.\n * @returns {value is Extract<T, unknown[]>} `true` if the value is an array, `false` otherwise.\n *\n * @example\n * const value1 = [1, 2, 3];\n * const value2 = 'abc';\n * const value3 = () => {};\n *\n * console.log(isArray(value1)); // true\n * console.log(isArray(value2)); // false\n * console.log(isArray(value3)); // false\n */\nexport function isArray<T>(value?: T): value is Extract<T, readonly unknown[]> {\n return Array.isArray(value);\n}\n","import { isTypedArray as isTypedArrayToolkit } from '../../predicate/isTypedArray.ts';\n\n/**\n * Checks if a value is a TypedArray.\n * @param {unknown} x The value to check.\n * @returns {x is\n * | Uint8Array\n * | Uint8ClampedArray\n * | Uint16Array\n * | Uint32Array\n * | BigUint64Array\n * | Int8Array\n * | Int16Array\n * | Int32Array\n * | BigInt64Array\n * | Float32Array\n * | Float64Array} Returns true if `x` is a TypedArray, false otherwise.\n */\nexport function isTypedArray(\n x?: unknown\n): x is\n | Uint8Array\n | Uint8ClampedArray\n | Uint16Array\n | Uint32Array\n | BigUint64Array\n | Int8Array\n | Int16Array\n | Int32Array\n | BigInt64Array\n | Float32Array\n | Float64Array {\n return isTypedArrayToolkit(x);\n}\n","import { isMatch } from '../predicate/isMatch.ts';\n\nexport function isArrayMatch(target: unknown, source: readonly unknown[]) {\n if (source.length === 0) {\n return true;\n }\n\n if (!Array.isArray(target)) {\n return false;\n }\n\n const countedIndex = new Set<number>();\n\n for (let i = 0; i < source.length; i++) {\n const sourceItem = source[i];\n const index = target.findIndex((targetItem, index) => {\n return isMatch(targetItem, sourceItem) && !countedIndex.has(index);\n });\n\n if (index === -1) {\n return false;\n }\n\n countedIndex.add(index);\n }\n\n return true;\n}\n","import { isMatch } from '../predicate/isMatch.ts';\n\nexport function isMapMatch(target: unknown, source: Map<any, any>) {\n if (source.size === 0) {\n return true;\n }\n\n if (!(target instanceof Map)) {\n return false;\n }\n\n for (const [key, value] of source.entries()) {\n if (!isMatch(target.get(key), value)) {\n return false;\n }\n }\n\n return true;\n}\n","import { isArrayMatch } from './isArrayMatch.ts';\n\nexport function isSetMatch(target: unknown, source: Set<any>) {\n if (source.size === 0) {\n return true;\n }\n\n if (!(target instanceof Set)) {\n return false;\n }\n\n return isArrayMatch([...target], [...source]);\n}\n","import { isPrimitive } from '../../predicate/isPrimitive.ts';\nimport { isArrayMatch } from '../_internal/isArrayMatch.ts';\nimport { isMapMatch } from '../_internal/isMapMatch.ts';\nimport { isSetMatch } from '../_internal/isSetMatch.ts';\n\n/**\n * Checks if the target matches the source by comparing their structures and values.\n * This function supports deep comparison for objects, arrays, maps, and sets.\n * \n * @param {unknown} target - The target value to match against.\n * @param {unknown} source - The source value to match with.\n * @returns {boolean} - Returns `true` if the target matches the source, otherwise `false`.\n *\n * @example\n * // Basic usage\n * isMatch({ a: 1, b: 2 }, { a: 1 }); // true\n *\n * @example\n * // Matching arrays\n * isMatch([1, 2, 3], [1, 2, 3]); // true\n *\n * @example\n * // Matching maps\n * const targetMap = new Map([['key1', 'value1'], ['key2', 'value2']]);\n * const sourceMap = new Map([['key1', 'value1']]);\n * isMatch(targetMap, sourceMap); // true\n *\n * @example\n * // Matching sets\n * const targetSet = new Set([1, 2, 3]);\n * const sourceSet = new Set([1, 2]);\n * isMatch(targetSet, sourceSet); // true\n */\nexport function isMatch(target: unknown, source: unknown): boolean;\nexport function isMatch(target: any, source: any): boolean {\n if (source === target) {\n return true;\n }\n\n switch (typeof source) {\n case 'object': {\n if (source == null) {\n return true;\n }\n\n source = source ?? {};\n\n const keys = Object.keys(source as any);\n\n if (target == null) {\n if (keys.length === 0) {\n return true;\n }\n\n return false;\n }\n\n if (Array.isArray(source)) {\n return isArrayMatch(target, source);\n }\n\n if (source instanceof Map) {\n return isMapMatch(target, source);\n }\n\n if (source instanceof Set) {\n return isSetMatch(target, source);\n }\n\n for (let i = 0; i < keys.length; i++) {\n const key = keys[i];\n\n if (!isPrimitive(target) && !(key in target)) {\n return false;\n }\n\n if (source[key] === undefined && target[key] !== undefined) {\n return false;\n }\n\n if (!isMatch(target[key], source[key])) {\n return false;\n }\n }\n\n return true;\n }\n case 'function': {\n if (Object.keys(source).length > 0) {\n return isMatch(target, { ...source });\n }\n\n return false;\n }\n default: {\n return !source;\n }\n }\n}\n","import { cloneDeep } from '../../object/cloneDeep.ts';\nimport { isMatch } from './isMatch.ts';\n\n/**\n * Creates a function that performs a deep comparison between a given target and the source object.\n * \n * @param {unknown} source - The source object to create the matcher from.\n * @returns {(target: unknown) => boolean} - Returns a function that takes a target object and returns `true` if the target matches the source, otherwise `false`.\n *\n * @example\n * // Basic usage\n * const matcher = matches({ a: 1, b: 2 });\n * matcher({ a: 1, b: 2, c: 3 }); // true\n * matcher({ a: 1, c: 3 }); // false\n *\n * @example\n * // Matching arrays\n * const arrayMatcher = matches([1, 2, 3]);\n * arrayMatcher([1, 2, 3, 4]); // true\n * arrayMatcher([4, 5, 6]); // false\n *\n * @example\n * // Matching objects with nested structures\n * const nestedMatcher = matches({ a: { b: 2 } });\n * nestedMatcher({ a: { b: 2, c: 3 } }); // true\n * nestedMatcher({ a: { c: 3 } }); // false\n */\nexport function matches(source: unknown): (target: unknown) => boolean {\n source = cloneDeep(source);\n\n return (target?: unknown): boolean => {\n return isMatch(target, source);\n };\n}\n","/**\n * Checks if a string contains another string at the beginning of the string.\n *\n * Checks if one string startsWith another string. Optional position parameter to start searching from a certain index.\n *\n * @param {string} str - The string that might contain the target string.\n * @param {string} target - The string to search for.\n * @param {number} position - An optional offset to start searching in the str string\n * @returns {boolean} - True if the str string starts with the target string.\n *\n * @example\n * const isPrefix = startsWith('fooBar', 'foo') // returns true\n * const isPrefix = startsWith('fooBar', 'bar') // returns false\n * const isPrefix = startsWith('fooBar', 'abc') // returns false\n * const isPrefix = startsWith('fooBar', 'Bar', 2) // returns true\n * const isPrefix = startsWith('fooBar', 'Bar', 5) // returns false\n */\nexport const startsWith = (str: string, target: string, position = 0): boolean => {\n return str.startsWith(target, position);\n};\n","/**\n * Checks if a string contains another string at the end of the string.\n *\n * Checks if one string endsWith another string. Optional position parameter to offset searching before a certain index.\n *\n * @param {string} str - The string that might contain the target string.\n * @param {string} target - The string to search for.\n * @param {number} position - An optional position from the start to search up to this index\n * @returns {boolean} - True if the str string ends with the target string.\n *\n * @example\n * const isPrefix = endsWith('fooBar', 'foo') // returns true\n * const isPrefix = endsWith('fooBar', 'bar') // returns false\n * const isPrefix = endsWith('fooBar', 'abc') // returns false\n * const isPrefix = endsWith('fooBar', 'foo', 3) // returns true\n * const isPrefix = endsWith('fooBar', 'abc', 5) // returns false\n */\nexport const endsWith = (str: string, target: string, position: number = str.length): boolean => {\n return str.endsWith(target, position);\n};\n","/**\n * Finds the element in an array that has the maximum value.\n *\n * @template T - The type of elements in the array.\n * @param {T[]} items The array of elements to search.\n * @returns {T | undefined} The element with the maximum value.\n * @example\n * // Returns 9\n * max([3, 1, 4, 1, 5, 9])\n *\n * @example\n * // Returns 8\n * max([0, -3, 2, 8, 7])\n */\nexport function max<T>(items: readonly [T, ...T[]]): T;\nexport function max(): undefined;\nexport function max<T>(items?: readonly T[]): T | undefined;\nexport function max<T>(items: readonly T[] = []): T | undefined {\n let maxElement = items[0];\n let max = undefined;\n\n for (const element of items) {\n if (max == null || element > max) {\n max = element;\n maxElement = element;\n }\n }\n\n return maxElement;\n}\n","/**\n * Finds the element in an array that has the minimum value.\n *\n * @template T - The type of elements in the array.\n * @param {T[]} items The array of elements to search.\n * @returns {T | undefined} The element with the minimum value.\n * @example\n * // Returns 1\n * min([3, 1, 4, 1, 5, 9])\n *\n * @example\n * // Returns -3\n * min([0, -3, 2, 8, 7])\n */\nexport function min<T>(items: readonly [T, ...T[]]): T;\nexport function min(): undefined;\nexport function min<T>(items?: readonly T[]): T | undefined;\nexport function min<T>(items: readonly T[] = []): T {\n let minElement = items[0];\n let min = undefined;\n\n for (const element of items) {\n if (min == null || element < min) {\n min = element;\n minElement = element;\n }\n }\n\n return minElement;\n}\n"],"names":["chunkToolkit","flatten","differenceToolkit","fillToolkit","zip","isTypedArrayToolkit","isPrimitive","cloneDeep"],"mappings":";;;;;;;;;;;;;;SAyBgB,KAAK,CAAI,GAAiB,EAAE,IAAI,GAAG,CAAC,EAAA;AAClD,IAAA,IAAI,GAAG,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC;AAErC,IAAA,IAAI,IAAI,KAAK,CAAC,EAAE;AACd,QAAA,OAAO,EAAE,CAAC;KACX;AAED,IAAA,OAAOA,iBAAY,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC;AACjC;;ACJgB,SAAA,MAAM,CAAI,GAAG,MAA+B,EAAA;AAC1D,IAAA,OAAOC,mBAAO,CAAC,MAAM,CAAQ,CAAC;AAChC;;SC5BgB,UAAU,CAAI,GAAiB,EAAE,GAAG,MAA2B,EAAA;IAC7E,MAAM,IAAI,GAAG,GAAG,CAAC;AACj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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
@@ -48,6 +48,7 @@ export { last } from '../array/last.mjs';
48
48
  export { initial } from '../array/initial.mjs';
49
49
  export { AbortError } from '../error/AbortError.mjs';
50
50
  export { TimeoutError } from '../error/TimeoutError.mjs';
51
+ export { before } from '../function/before.mjs';
51
52
  export { after } from '../function/after.mjs';
52
53
  export { debounce } from '../function/debounce.mjs';
53
54
  export { noop } from '../function/noop.mjs';
@@ -70,8 +71,10 @@ export { pick } from '../object/pick.mjs';
70
71
  export { pickBy } from '../object/pickBy.mjs';
71
72
  export { invert } from '../object/invert.mjs';
72
73
  export { clone } from '../object/clone.mjs';
73
- export { cloneDeep } from '../object/cloneDeep.mjs';
74
74
  export { flattenObject } from '../object/flattenObject.mjs';
75
+ export { mapKeys } from '../object/mapKeys.mjs';
76
+ export { mapValues } from '../object/mapValues.mjs';
77
+ export { cloneDeep } from '../object/cloneDeep.mjs';
75
78
  export { isEqual } from '../predicate/isEqual.mjs';
76
79
  export { isNil } from '../predicate/isNil.mjs';
77
80
  export { isNotNil } from '../predicate/isNotNil.mjs';
@@ -1 +1 @@
1
- {"version":3,"file":"index.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"index.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
@@ -0,0 +1,31 @@
1
+ /**
2
+ * Creates a function that limits the number of times the given function (`func`) can be called.
3
+ *
4
+ * @template F - The type of the function to be invoked.
5
+ * @param {number} n - The number of times the returned function is allowed to call `func` before stopping.
6
+ * - If `n` is 0, `func` will never be called.
7
+ * - If `n` is a positive integer, `func` will be called up to `n-1` times.
8
+ * @param {F} func - The function to be called with the limit applied.
9
+ * @returns {F} - A new function that:
10
+ * - Tracks the number of calls.
11
+ * - Invokes `func` until the `n-1`-th call.
12
+ * - Returns `undefined` if the number of calls reaches or exceeds `n`, stopping further calls.
13
+ * @throws {Error} - Throw an error if `n` is negative.
14
+ * @example
15
+ *
16
+ * const beforeFn = before(3, () => {
17
+ * console.log("called");
18
+ * })
19
+ *
20
+ * // Will log 'called'.
21
+ * beforeFn();
22
+ *
23
+ * // Will log 'called'.
24
+ * beforeFn();
25
+ *
26
+ * // Will not log anything.
27
+ * beforeFn();
28
+ */
29
+ declare const before: <F extends (...args: any[]) => any>(n: number, func: F) => F;
30
+
31
+ export { before };
@@ -0,0 +1,31 @@
1
+ /**
2
+ * Creates a function that limits the number of times the given function (`func`) can be called.
3
+ *
4
+ * @template F - The type of the function to be invoked.
5
+ * @param {number} n - The number of times the returned function is allowed to call `func` before stopping.
6
+ * - If `n` is 0, `func` will never be called.
7
+ * - If `n` is a positive integer, `func` will be called up to `n-1` times.
8
+ * @param {F} func - The function to be called with the limit applied.
9
+ * @returns {F} - A new function that:
10
+ * - Tracks the number of calls.
11
+ * - Invokes `func` until the `n-1`-th call.
12
+ * - Returns `undefined` if the number of calls reaches or exceeds `n`, stopping further calls.
13
+ * @throws {Error} - Throw an error if `n` is negative.
14
+ * @example
15
+ *
16
+ * const beforeFn = before(3, () => {
17
+ * console.log("called");
18
+ * })
19
+ *
20
+ * // Will log 'called'.
21
+ * beforeFn();
22
+ *
23
+ * // Will log 'called'.
24
+ * beforeFn();
25
+ *
26
+ * // Will not log anything.
27
+ * beforeFn();
28
+ */
29
+ declare const before: <F extends (...args: any[]) => any>(n: number, func: F) => F;
30
+
31
+ export { before };
@@ -0,0 +1,15 @@
1
+ const before = (n, func) => {
2
+ if (!Number.isInteger(n) || n < 0) {
3
+ throw new Error('n must be a non-negative integer.');
4
+ }
5
+ let counter = 0;
6
+ return ((...args) => {
7
+ if (++counter < n) {
8
+ return func(...args);
9
+ }
10
+ return undefined;
11
+ });
12
+ };
13
+
14
+ export { before };
15
+ //# sourceMappingURL=before.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"before.mjs","sources":["../../src/function/before.ts"],"sourcesContent":["/**\n * Creates a function that limits the number of times the given function (`func`) can be called.\n *\n * @template F - The type of the function to be invoked.\n * @param {number} n - The number of times the returned function is allowed to call `func` before stopping.\n * - If `n` is 0, `func` will never be called.\n * - If `n` is a positive integer, `func` will be called up to `n-1` times.\n * @param {F} func - The function to be called with the limit applied.\n * @returns {F} - A new function that:\n * - Tracks the number of calls.\n * - Invokes `func` until the `n-1`-th call.\n * - Returns `undefined` if the number of calls reaches or exceeds `n`, stopping further calls.\n * @throws {Error} - Throw an error if `n` is negative.\n * @example\n *\n * const beforeFn = before(3, () => {\n * console.log(\"called\");\n * })\n *\n * // Will log 'called'.\n * beforeFn();\n *\n * // Will log 'called'.\n * beforeFn();\n *\n * // Will not log anything.\n * beforeFn();\n */\n\nexport const before = <F extends (...args: any[]) => any>(n: number, func: F): F => {\n if (!Number.isInteger(n) || n < 0) {\n throw new Error('n must be a non-negative integer.');\n }\n\n let counter = 0;\n return ((...args: Parameters<F>) => {\n if (++counter < n) {\n return func(...args);\n }\n return undefined;\n }) as F;\n};\n"],"names":[],"mappings":"MA6Ba,MAAM,GAAG,CAAoC,CAAS,EAAE,IAAO,KAAO;AACjF,IAAA,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE;AACjC,QAAA,MAAM,IAAI,KAAK,CAAC,mCAAmC,CAAC,CAAC;KACtD;IAED,IAAI,OAAO,GAAG,CAAC,CAAC;AAChB,IAAA,QAAQ,CAAC,GAAG,IAAmB,KAAI;AACjC,QAAA,IAAI,EAAE,OAAO,GAAG,CAAC,EAAE;AACjB,YAAA,OAAO,IAAI,CAAC,GAAG,IAAI,CAAC,CAAC;SACtB;AACD,QAAA,OAAO,SAAS,CAAC;AACnB,KAAC,EAAO;AACV;;;;"}
@@ -1,3 +1,4 @@
1
+ export { before } from './before.mjs';
1
2
  export { after } from './after.mjs';
2
3
  export { debounce } from './debounce.mjs';
3
4
  export { noop } from './noop.mjs';
@@ -1,3 +1,4 @@
1
+ export { before } from './before.js';
1
2
  export { after } from './after.js';
2
3
  export { debounce } from './debounce.js';
3
4
  export { noop } from './noop.js';
@@ -2,6 +2,19 @@
2
2
 
3
3
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
4
4
 
5
+ const before = (n, func) => {
6
+ if (!Number.isInteger(n) || n < 0) {
7
+ throw new Error('n must be a non-negative integer.');
8
+ }
9
+ let counter = 0;
10
+ return ((...args) => {
11
+ if (++counter < n) {
12
+ return func(...args);
13
+ }
14
+ return undefined;
15
+ });
16
+ };
17
+
5
18
  const after = (n, func) => {
6
19
  if (!Number.isInteger(n) || n < 0) {
7
20
  throw new Error(`n must be a non-negative integer.`);
@@ -75,6 +88,7 @@ function negate(func) {
75
88
  }
76
89
 
77
90
  exports.after = after;
91
+ exports.before = before;
78
92
  exports.debounce = debounce;
79
93
  exports.negate = negate;
80
94
  exports.noop = noop;
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../../src/function/after.ts","../../src/function/debounce.ts","../../src/function/noop.ts","../../src/function/once.ts","../../src/function/throttle.ts","../../src/function/negate.ts"],"sourcesContent":["/**\n * Creates a function that only executes starting from the `n`-th call.\n * The provided function will be invoked starting from the `n`-th call.\n *\n * This is particularly useful for scenarios involving events or asynchronous operations\n * where an action should occur only after a certain number of invocations.\n *\n * @template F - The type of the function to be invoked.\n * @param {number} n - The number of calls required for `func` to execute.\n * @param {F} func - The function to be invoked.\n * @returns {F} - A new function that:\n * - Tracks the number of calls.\n * - Invokes `func` starting from the `n`-th call.\n * - Returns `undefined` if fewer than `n` calls have been made.\n * @throws {Error} - Throws an error if `n` is negative.\n * @example\n *\n * const afterFn = after(3, () => {\n * console.log(\"called\")\n * });\n *\n * // Will not log anything.\n * afterFn()\n * // Will not log anything.\n * afterFn()\n * // Will log 'called'.\n * afterFn()\n */\n\nexport const after = <F extends (...args: any[]) => any>(n: number, func: F): F => {\n if (!Number.isInteger(n) || n < 0) {\n throw new Error(`n must be a non-negative integer.`);\n }\n\n let counter = 0;\n return ((...args: Parameters<F>) => {\n if (++counter >= n) {\n return func(...args);\n }\n return undefined;\n }) as F;\n};\n","interface DebounceOptions {\n signal?: AbortSignal;\n}\n\n/**\n * Creates a debounced function that delays invoking the provided function until after `debounceMs` milliseconds\n * have elapsed since the last time the debounced function was invoked. The debounced function also has a `cancel`\n * method to cancel any pending execution.\n *\n * @template F - The type of function.\n * @param {F} func - The function to debounce.\n * @param {number} debounceMs - The number of milliseconds to delay.\n * @param {DebounceOptions} options - The options object.\n * @param {AbortSignal} options.signal - An optional AbortSignal to cancel the debounced function.\n * @returns {F & { cancel: () => void }} A new debounced function with a `cancel` method.\n *\n * @example\n * const debouncedFunction = debounce(() => {\n * console.log('Function executed');\n * }, 1000);\n *\n * // Will log 'Function executed' after 1 second if not called again in that time\n * debouncedFunction();\n *\n * // Will not log anything as the previous call is canceled\n * debouncedFunction.cancel();\n *\n * // With AbortSignal\n * const controller = new AbortController();\n * const signal = controller.signal;\n * const debouncedWithSignal = debounce(() => {\n * console.log('Function executed');\n * }, 1000, { signal });\n *\n * debouncedWithSignal();\n *\n * // Will cancel the debounced function call\n * controller.abort();\n */\nexport function debounce<F extends (...args: any[]) => void>(\n func: F,\n debounceMs: number,\n { signal }: DebounceOptions = {}\n): F & { cancel: () => void } {\n let timeoutId: ReturnType<typeof setTimeout> | null = null;\n\n const debounced = function (...args: Parameters<F>) {\n if (timeoutId !== null) {\n clearTimeout(timeoutId);\n }\n\n if (signal?.aborted) {\n return;\n }\n\n timeoutId = setTimeout(() => {\n func(...args);\n timeoutId = null;\n }, debounceMs) ;\n } as F & { cancel: () => void };\n\n const onAbort = function () {\n debounced.cancel();\n };\n\n debounced.cancel = function () {\n if (timeoutId !== null) {\n clearTimeout(timeoutId);\n timeoutId = null;\n }\n };\n\n signal?.addEventListener('abort', onAbort, { once: true });\n\n return debounced;\n}\n","/**\n * A no-operation function that does nothing.\n * This can be used as a placeholder or default function.\n *\n * @example\n * noop(); // Does nothing\n *\n * @returns {void} This function does not return anything.\n */\nexport function noop(): void {}\n","/**\n * Creates a function that is restricted to invoking the provided function `func` once.\n * Repeated calls to the function will return the value from the first invocation.\n *\n * @template F - The type of function.\n * @param {F} func - The function to restrict.\n * @returns {F} A new function that invokes `func` once and caches the result.\n *\n * @example\n * const initialize = once(() => {\n * console.log('Initialized!');\n * return true;\n * });\n *\n * initialize(); // Logs: 'Initialized!' and returns true\n * initialize(); // Returns true without logging\n */\nexport function once<F extends () => any>(func: F): F {\n let called = false;\n let cache: ReturnType<F> | undefined;\n\n return function () {\n if (called) {\n return cache;\n }\n\n const result = func();\n\n called = true;\n cache = result;\n\n return result;\n } as F;\n}\n","/**\n * Creates a throttled function that only invokes the provided function at most once\n * per every `throttleMs` milliseconds. Subsequent calls to the throttled function\n * within the wait time will not trigger the execution of the original function.\n *\n * @template F - The type of function.\n * @param {F} func - The function to throttle.\n * @param {number} throttleMs - The number of milliseconds to throttle executions to.\n * @returns {F} A new throttled function that accepts the same parameters as the original function.\n *\n * @example\n * const throttledFunction = throttle(() => {\n * console.log('Function executed');\n * }, 1000);\n *\n * // Will log 'Function executed' immediately\n * throttledFunction();\n *\n * // Will not log anything as it is within the throttle time\n * throttledFunction();\n *\n * // After 1 second\n * setTimeout(() => {\n * throttledFunction(); // Will log 'Function executed'\n * }, 1000);\n */\nexport function throttle<F extends (...args: any[]) => void>(func: F, throttleMs: number): F {\n let lastCallTime: number | null;\n\n const throttledFunction = function (...args: Parameters<F>) {\n const now = Date.now();\n\n if (lastCallTime == null || now - lastCallTime >= throttleMs) {\n lastCallTime = now;\n func(...args);\n }\n } as F;\n\n return throttledFunction;\n}\n","/**\n * Creates a function that negates the result of the predicate function.\n *\n * @template F - The type of the function to negate.\n * @param {F} func - The function to negate.\n * @returns {F} The new negated function, which negates the boolean result of `func`.\n */\nexport function negate<F extends (...args: unknown[]) => boolean>(func: F): F {\n return ((...args: any[]) => !func(...args)) as F;\n}\n"],"names":[],"mappings":";;;;MA6Ba,KAAK,GAAG,CAAoC,CAAS,EAAE,IAAO,KAAO;AAChF,IAAA,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE;AACjC,QAAA,MAAM,IAAI,KAAK,CAAC,CAAA,iCAAA,CAAmC,CAAC,CAAC;KACtD;IAED,IAAI,OAAO,GAAG,CAAC,CAAC;AAChB,IAAA,QAAQ,CAAC,GAAG,IAAmB,KAAI;AACjC,QAAA,IAAI,EAAE,OAAO,IAAI,CAAC,EAAE;AAClB,YAAA,OAAO,IAAI,CAAC,GAAG,IAAI,CAAC,CAAC;SACtB;AACD,QAAA,OAAO,SAAS,CAAC;AACnB,KAAC,EAAO;AACV;;ACFM,SAAU,QAAQ,CACtB,IAAO,EACP,UAAkB,EAClB,EAAE,MAAM,EAAA,GAAsB,EAAE,EAAA;IAEhC,IAAI,SAAS,GAAyC,IAAI,CAAC;AAE3D,IAAA,MAAM,SAAS,GAAG,UAAU,GAAG,IAAmB,EAAA;AAChD,QAAA,IAAI,SAAS,KAAK,IAAI,EAAE;YACtB,YAAY,CAAC,SAAS,CAAC,CAAC;SACzB;AAED,QAAA,IAAI,MAAM,EAAE,OAAO,EAAE;YACnB,OAAO;SACR;AAED,QAAA,SAAS,GAAG,UAAU,CAAC,MAAK;AAC1B,YAAA,IAAI,CAAC,GAAG,IAAI,CAAC,CAAC;YACd,SAAS,GAAG,IAAI,CAAC;SAClB,EAAE,UAAU,CAAC,CAAE;AAClB,KAA+B,CAAC;AAEhC,IAAA,MAAM,OAAO,GAAG,YAAA;QAC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,IAAI,CAAC,GAAG,IAAI,CAAC,EAAO;AACrD;;;;;;;;;"}
1
+ {"version":3,"file":"index.js","sources":["../../src/function/before.ts","../../src/function/after.ts","../../src/function/debounce.ts","../../src/function/noop.ts","../../src/function/once.ts","../../src/function/throttle.ts","../../src/function/negate.ts"],"sourcesContent":["/**\n * Creates a function that limits the number of times the given function (`func`) can be called.\n *\n * @template F - The type of the function to be invoked.\n * @param {number} n - The number of times the returned function is allowed to call `func` before stopping.\n * - If `n` is 0, `func` will never be called.\n * - If `n` is a positive integer, `func` will be called up to `n-1` times.\n * @param {F} func - The function to be called with the limit applied.\n * @returns {F} - A new function that:\n * - Tracks the number of calls.\n * - Invokes `func` until the `n-1`-th call.\n * - Returns `undefined` if the number of calls reaches or exceeds `n`, stopping further calls.\n * @throws {Error} - Throw an error if `n` is negative.\n * @example\n *\n * const beforeFn = before(3, () => {\n * console.log(\"called\");\n * })\n *\n * // Will log 'called'.\n * beforeFn();\n *\n * // Will log 'called'.\n * beforeFn();\n *\n * // Will not log anything.\n * beforeFn();\n */\n\nexport const before = <F extends (...args: any[]) => any>(n: number, func: F): F => {\n if (!Number.isInteger(n) || n < 0) {\n throw new Error('n must be a non-negative integer.');\n }\n\n let counter = 0;\n return ((...args: Parameters<F>) => {\n if (++counter < n) {\n return func(...args);\n }\n return undefined;\n }) as F;\n};\n","/**\n * Creates a function that only executes starting from the `n`-th call.\n * The provided function will be invoked starting from the `n`-th call.\n *\n * This is particularly useful for scenarios involving events or asynchronous operations\n * where an action should occur only after a certain number of invocations.\n *\n * @template F - The type of the function to be invoked.\n * @param {number} n - The number of calls required for `func` to execute.\n * @param {F} func - The function to be invoked.\n * @returns {F} - A new function that:\n * - Tracks the number of calls.\n * - Invokes `func` starting from the `n`-th call.\n * - Returns `undefined` if fewer than `n` calls have been made.\n * @throws {Error} - Throws an error if `n` is negative.\n * @example\n *\n * const afterFn = after(3, () => {\n * console.log(\"called\")\n * });\n *\n * // Will not log anything.\n * afterFn()\n * // Will not log anything.\n * afterFn()\n * // Will log 'called'.\n * afterFn()\n */\n\nexport const after = <F extends (...args: any[]) => any>(n: number, func: F): F => {\n if (!Number.isInteger(n) || n < 0) {\n throw new Error(`n must be a non-negative integer.`);\n }\n\n let counter = 0;\n return ((...args: Parameters<F>) => {\n if (++counter >= n) {\n return func(...args);\n }\n return undefined;\n }) as F;\n};\n","interface DebounceOptions {\n signal?: AbortSignal;\n}\n\n/**\n * Creates a debounced function that delays invoking the provided function until after `debounceMs` milliseconds\n * have elapsed since the last time the debounced function was invoked. The debounced function also has a `cancel`\n * method to cancel any pending execution.\n *\n * @template F - The type of function.\n * @param {F} func - The function to debounce.\n * @param {number} debounceMs - The number of milliseconds to delay.\n * @param {DebounceOptions} options - The options object.\n * @param {AbortSignal} options.signal - An optional AbortSignal to cancel the debounced function.\n * @returns {F & { cancel: () => void }} A new debounced function with a `cancel` method.\n *\n * @example\n * const debouncedFunction = debounce(() => {\n * console.log('Function executed');\n * }, 1000);\n *\n * // Will log 'Function executed' after 1 second if not called again in that time\n * debouncedFunction();\n *\n * // Will not log anything as the previous call is canceled\n * debouncedFunction.cancel();\n *\n * // With AbortSignal\n * const controller = new AbortController();\n * const signal = controller.signal;\n * const debouncedWithSignal = debounce(() => {\n * console.log('Function executed');\n * }, 1000, { signal });\n *\n * debouncedWithSignal();\n *\n * // Will cancel the debounced function call\n * controller.abort();\n */\nexport function debounce<F extends (...args: any[]) => void>(\n func: F,\n debounceMs: number,\n { signal }: DebounceOptions = {}\n): F & { cancel: () => void } {\n let timeoutId: ReturnType<typeof setTimeout> | null = null;\n\n const debounced = function (...args: Parameters<F>) {\n if (timeoutId !== null) {\n clearTimeout(timeoutId);\n }\n\n if (signal?.aborted) {\n return;\n }\n\n timeoutId = setTimeout(() => {\n func(...args);\n timeoutId = null;\n }, debounceMs) ;\n } as F & { cancel: () => void };\n\n const onAbort = function () {\n debounced.cancel();\n };\n\n debounced.cancel = function () {\n if (timeoutId !== null) {\n clearTimeout(timeoutId);\n timeoutId = null;\n }\n };\n\n signal?.addEventListener('abort', onAbort, { once: true });\n\n return debounced;\n}\n","/**\n * A no-operation function that does nothing.\n * This can be used as a placeholder or default function.\n *\n * @example\n * noop(); // Does nothing\n *\n * @returns {void} This function does not return anything.\n */\nexport function noop(): void {}\n","/**\n * Creates a function that is restricted to invoking the provided function `func` once.\n * Repeated calls to the function will return the value from the first invocation.\n *\n * @template F - The type of function.\n * @param {F} func - The function to restrict.\n * @returns {F} A new function that invokes `func` once and caches the result.\n *\n * @example\n * const initialize = once(() => {\n * console.log('Initialized!');\n * return true;\n * });\n *\n * initialize(); // Logs: 'Initialized!' and returns true\n * initialize(); // Returns true without logging\n */\nexport function once<F extends () => any>(func: F): F {\n let called = false;\n let cache: ReturnType<F> | undefined;\n\n return function () {\n if (called) {\n return cache;\n }\n\n const result = func();\n\n called = true;\n cache = result;\n\n return result;\n } as F;\n}\n","/**\n * Creates a throttled function that only invokes the provided function at most once\n * per every `throttleMs` milliseconds. Subsequent calls to the throttled function\n * within the wait time will not trigger the execution of the original function.\n *\n * @template F - The type of function.\n * @param {F} func - The function to throttle.\n * @param {number} throttleMs - The number of milliseconds to throttle executions to.\n * @returns {F} A new throttled function that accepts the same parameters as the original function.\n *\n * @example\n * const throttledFunction = throttle(() => {\n * console.log('Function executed');\n * }, 1000);\n *\n * // Will log 'Function executed' immediately\n * throttledFunction();\n *\n * // Will not log anything as it is within the throttle time\n * throttledFunction();\n *\n * // After 1 second\n * setTimeout(() => {\n * throttledFunction(); // Will log 'Function executed'\n * }, 1000);\n */\nexport function throttle<F extends (...args: any[]) => void>(func: F, throttleMs: number): F {\n let lastCallTime: number | null;\n\n const throttledFunction = function (...args: Parameters<F>) {\n const now = Date.now();\n\n if (lastCallTime == null || now - lastCallTime >= throttleMs) {\n lastCallTime = now;\n func(...args);\n }\n } as F;\n\n return throttledFunction;\n}\n","/**\n * Creates a function that negates the result of the predicate function.\n *\n * @template F - The type of the function to negate.\n * @param {F} func - The function to negate.\n * @returns {F} The new negated function, which negates the boolean result of `func`.\n */\nexport function negate<F extends (...args: unknown[]) => boolean>(func: F): F {\n return ((...args: any[]) => !func(...args)) as F;\n}\n"],"names":[],"mappings":";;;;MA6Ba,MAAM,GAAG,CAAoC,CAAS,EAAE,IAAO,KAAO;AACjF,IAAA,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE;AACjC,QAAA,MAAM,IAAI,KAAK,CAAC,mCAAmC,CAAC,CAAC;KACtD;IAED,IAAI,OAAO,GAAG,CAAC,CAAC;AAChB,IAAA,QAAQ,CAAC,GAAG,IAAmB,KAAI;AACjC,QAAA,IAAI,EAAE,OAAO,GAAG,CAAC,EAAE;AACjB,YAAA,OAAO,IAAI,CAAC,GAAG,IAAI,CAAC,CAAC;SACtB;AACD,QAAA,OAAO,SAAS,CAAC;AACnB,KAAC,EAAO;AACV;;MCZa,KAAK,GAAG,CAAoC,CAAS,EAAE,IAAO,KAAO;AAChF,IAAA,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE;AACjC,QAAA,MAAM,IAAI,KAAK,CAAC,CAAA,iCAAA,CAAmC,CAAC,CAAC;KACtD;IAED,IAAI,OAAO,GAAG,CAAC,CAAC;AAChB,IAAA,QAAQ,CAAC,GAAG,IAAmB,KAAI;AACjC,QAAA,IAAI,EAAE,OAAO,IAAI,CAAC,EAAE;AAClB,YAAA,OAAO,IAAI,CAAC,GAAG,IAAI,CAAC,CAAC;SACtB;AACD,QAAA,OAAO,SAAS,CAAC;AACnB,KAAC,EAAO;AACV;;ACFM,SAAU,QAAQ,CACtB,IAAO,EACP,UAAkB,EAClB,EAAE,MAAM,EAAA,GAAsB,EAAE,EAAA;IAEhC,IAAI,SAAS,GAAyC,IAAI,CAAC;AAE3D,IAAA,MAAM,SAAS,GAAG,UAAU,GAAG,IAAmB,EAAA;AAChD,QAAA,IAAI,SAAS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I,CAAC,GAAG,EAAE,CAAC;QAEvB,IAAI,YAAY,IAAI,IAAI,IAAI,GAAG,GAAG,YAAY,IAAI,UAAU,EAAE;YAC5D,YAAY,GAAG,GAAG,CAAC;AACnB,YAAA,IAAI,CAAC,GAAG,IAAI,CAAC,CAAC;SACf;AACH,KAAM,CAAC;AAEP,IAAA,OAAO,iBAAiB,CAAC;AAC3B;;AChCM,SAAU,MAAM,CAA4C,IAAO,EAAA;AACrE,IAAA,QAAQ,CAAC,GAAG,IAAW,KAAK,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC,EAAO;AACrD;;;;;;;;;;"}
@@ -1,3 +1,4 @@
1
+ export { before } from './before.mjs';
1
2
  export { after } from './after.mjs';
2
3
  export { debounce } from './debounce.mjs';
3
4
  export { noop } from './noop.mjs';
@@ -1 +1 @@
1
- {"version":3,"file":"index.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;"}
1
+ {"version":3,"file":"index.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;"}
package/dist/index.d.mts CHANGED
@@ -51,6 +51,7 @@ export { last } from './array/last.mjs';
51
51
  export { initial } from './array/initial.mjs';
52
52
  export { AbortError } from './error/AbortError.mjs';
53
53
  export { TimeoutError } from './error/TimeoutError.mjs';
54
+ export { before } from './function/before.mjs';
54
55
  export { after } from './function/after.mjs';
55
56
  export { debounce } from './function/debounce.mjs';
56
57
  export { noop } from './function/noop.mjs';
@@ -73,8 +74,10 @@ export { pick } from './object/pick.mjs';
73
74
  export { pickBy } from './object/pickBy.mjs';
74
75
  export { invert } from './object/invert.mjs';
75
76
  export { clone } from './object/clone.mjs';
76
- export { cloneDeep } from './object/cloneDeep.mjs';
77
77
  export { flattenObject } from './object/flattenObject.mjs';
78
+ export { mapKeys } from './object/mapKeys.mjs';
79
+ export { mapValues } from './object/mapValues.mjs';
80
+ export { cloneDeep } from './object/cloneDeep.mjs';
78
81
  export { isEqual } from './predicate/isEqual.mjs';
79
82
  export { isNil } from './predicate/isNil.mjs';
80
83
  export { isNotNil } from './predicate/isNotNil.mjs';
package/dist/index.d.ts CHANGED
@@ -51,6 +51,7 @@ export { last } from './array/last.js';
51
51
  export { initial } from './array/initial.js';
52
52
  export { AbortError } from './error/AbortError.js';
53
53
  export { TimeoutError } from './error/TimeoutError.js';
54
+ export { before } from './function/before.js';
54
55
  export { after } from './function/after.js';
55
56
  export { debounce } from './function/debounce.js';
56
57
  export { noop } from './function/noop.js';
@@ -73,8 +74,10 @@ export { pick } from './object/pick.js';
73
74
  export { pickBy } from './object/pickBy.js';
74
75
  export { invert } from './object/invert.js';
75
76
  export { clone } from './object/clone.js';
76
- export { cloneDeep } from './object/cloneDeep.js';
77
77
  export { flattenObject } from './object/flattenObject.js';
78
+ export { mapKeys } from './object/mapKeys.js';
79
+ export { mapValues } from './object/mapValues.js';
80
+ export { cloneDeep } from './object/cloneDeep.js';
78
81
  export { isEqual } from './predicate/isEqual.js';
79
82
  export { isNil } from './predicate/isNil.js';
80
83
  export { isNotNil } from './predicate/isNotNil.js';
package/dist/index.js CHANGED
@@ -71,6 +71,7 @@ exports.TimeoutError = promise_index.TimeoutError;
71
71
  exports.delay = promise_index.delay;
72
72
  exports.withTimeout = promise_index.withTimeout;
73
73
  exports.after = function_index.after;
74
+ exports.before = function_index.before;
74
75
  exports.debounce = function_index.debounce;
75
76
  exports.negate = function_index.negate;
76
77
  exports.noop = function_index.noop;
@@ -90,6 +91,8 @@ exports.clone = object_index.clone;
90
91
  exports.cloneDeep = object_index.cloneDeep;
91
92
  exports.flattenObject = object_index.flattenObject;
92
93
  exports.invert = object_index.invert;
94
+ exports.mapKeys = object_index.mapKeys;
95
+ exports.mapValues = object_index.mapValues;
93
96
  exports.omit = object_index.omit;
94
97
  exports.omitBy = object_index.omitBy;
95
98
  exports.pick = object_index.pick;
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
package/dist/index.mjs CHANGED
@@ -51,6 +51,7 @@ export { last } from './array/last.mjs';
51
51
  export { initial } from './array/initial.mjs';
52
52
  export { AbortError } from './error/AbortError.mjs';
53
53
  export { TimeoutError } from './error/TimeoutError.mjs';
54
+ export { before } from './function/before.mjs';
54
55
  export { after } from './function/after.mjs';
55
56
  export { debounce } from './function/debounce.mjs';
56
57
  export { noop } from './function/noop.mjs';
@@ -73,8 +74,10 @@ export { pick } from './object/pick.mjs';
73
74
  export { pickBy } from './object/pickBy.mjs';
74
75
  export { invert } from './object/invert.mjs';
75
76
  export { clone } from './object/clone.mjs';
76
- export { cloneDeep } from './object/cloneDeep.mjs';
77
77
  export { flattenObject } from './object/flattenObject.mjs';
78
+ export { mapKeys } from './object/mapKeys.mjs';
79
+ export { mapValues } from './object/mapValues.mjs';
80
+ export { cloneDeep } from './object/cloneDeep.mjs';
78
81
  export { isEqual } from './predicate/isEqual.mjs';
79
82
  export { isNil } from './predicate/isNil.mjs';
80
83
  export { isNotNil } from './predicate/isNotNil.mjs';
@@ -1 +1 @@
1
- {"version":3,"file":"index.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"index.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}