es-toolkit 1.50.0-dev.2057 → 1.50.0-dev.2059

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 (58) hide show
  1. package/dist/browser.global.js +3 -3
  2. package/dist/compat/array/drop.d.mts +1 -1
  3. package/dist/compat/array/drop.d.ts +1 -1
  4. package/dist/compat/array/pull.js +1 -1
  5. package/dist/compat/array/pull.mjs +1 -1
  6. package/dist/compat/array/remove.js +8 -4
  7. package/dist/compat/array/remove.mjs +8 -4
  8. package/dist/compat/array/unzipWith.js +1 -1
  9. package/dist/compat/array/unzipWith.mjs +1 -1
  10. package/dist/compat/function/curry.d.mts +1 -1
  11. package/dist/compat/function/curry.d.ts +1 -1
  12. package/dist/compat/function/flowRight.d.mts +1 -1
  13. package/dist/compat/function/flowRight.d.ts +1 -1
  14. package/dist/compat/function/partial.d.mts +1 -1
  15. package/dist/compat/function/partial.d.ts +1 -1
  16. package/dist/compat/function/rest.d.mts +1 -1
  17. package/dist/compat/function/rest.d.ts +1 -1
  18. package/dist/compat/function/rest.js +1 -1
  19. package/dist/compat/function/rest.mjs +1 -1
  20. package/dist/compat/object/cloneDeep.d.mts +5 -5
  21. package/dist/compat/object/cloneDeep.d.ts +5 -5
  22. package/dist/compat/object/cloneDeep.js +5 -5
  23. package/dist/compat/object/cloneDeep.mjs +5 -5
  24. package/dist/compat/object/cloneDeepWith.js +3 -1
  25. package/dist/compat/object/cloneDeepWith.mjs +3 -1
  26. package/dist/compat/object/cloneWith.d.mts +1 -1
  27. package/dist/compat/object/cloneWith.d.ts +1 -1
  28. package/dist/compat/object/cloneWith.js +1 -1
  29. package/dist/compat/object/cloneWith.mjs +1 -1
  30. package/dist/compat/object/transform.js +1 -1
  31. package/dist/compat/object/transform.mjs +1 -1
  32. package/dist/compat/string/words.js +17 -13
  33. package/dist/compat/string/words.mjs +17 -13
  34. package/dist/compat/util/toArray.d.mts +5 -5
  35. package/dist/compat/util/toArray.d.ts +5 -5
  36. package/dist/compat/util/toArray.js +4 -4
  37. package/dist/compat/util/toArray.mjs +4 -4
  38. package/dist/function/memoize.d.mts +3 -2
  39. package/dist/function/memoize.d.ts +3 -2
  40. package/dist/function/memoize.js +3 -2
  41. package/dist/function/memoize.mjs +3 -2
  42. package/dist/function/partial.d.mts +2 -2
  43. package/dist/function/partial.d.ts +2 -2
  44. package/dist/function/partialRight.d.mts +5 -5
  45. package/dist/function/partialRight.d.ts +5 -5
  46. package/dist/function/rest.d.mts +1 -1
  47. package/dist/function/rest.d.ts +1 -1
  48. package/dist/function/rest.js +1 -1
  49. package/dist/function/rest.mjs +1 -1
  50. package/dist/object/cloneDeepWith.d.mts +3 -1
  51. package/dist/object/cloneDeepWith.d.ts +3 -1
  52. package/dist/object/cloneDeepWith.js +3 -1
  53. package/dist/object/cloneDeepWith.mjs +3 -1
  54. package/dist/object/flattenObject.d.mts +16 -1
  55. package/dist/object/flattenObject.d.ts +16 -1
  56. package/dist/object/flattenObject.js +15 -6
  57. package/dist/object/flattenObject.mjs +15 -6
  58. package/package.json +5 -2
@@ -24,7 +24,7 @@ const require_rest = require("../../function/rest.js");
24
24
  *
25
25
  * // Using start index 1
26
26
  * const transformedFnWithStart = rest(fn, 1);
27
- * console.log(transformedFnWithStart(1, 2, 3, 4)); // [1, [2, 3, 4]]
27
+ * console.log(transformedFnWithStart(1, 2, 3, 4)); // [1, [2, 3, 4], undefined]
28
28
  *
29
29
  * // With fewer arguments than the start index
30
30
  * console.log(transformedFn(1)); // [1, undefined, []]
@@ -24,7 +24,7 @@ import { rest as rest$1 } from "../../function/rest.mjs";
24
24
  *
25
25
  * // Using start index 1
26
26
  * const transformedFnWithStart = rest(fn, 1);
27
- * console.log(transformedFnWithStart(1, 2, 3, 4)); // [1, [2, 3, 4]]
27
+ * console.log(transformedFnWithStart(1, 2, 3, 4)); // [1, [2, 3, 4], undefined]
28
28
  *
29
29
  * // With fewer arguments than the start index
30
30
  * console.log(transformedFn(1)); // [1, undefined, []]
@@ -16,30 +16,30 @@
16
16
  * @example
17
17
  * // Clone an array
18
18
  * const arr = [1, 2, 3];
19
- * const clonedArr = clone(arr);
19
+ * const clonedArr = cloneDeep(arr);
20
20
  * console.log(clonedArr); // [1, 2, 3]
21
21
  * console.log(clonedArr === arr); // false
22
22
  *
23
23
  * @example
24
24
  * // Clone an array with nested objects
25
25
  * const arr = [1, { a: 1 }, [1, 2, 3]];
26
- * const clonedArr = clone(arr);
26
+ * const clonedArr = cloneDeep(arr);
27
27
  * arr[1].a = 2;
28
- * console.log(arr); // [2, { a: 2 }, [1, 2, 3]]
28
+ * console.log(arr); // [1, { a: 2 }, [1, 2, 3]]
29
29
  * console.log(clonedArr); // [1, { a: 1 }, [1, 2, 3]]
30
30
  * console.log(clonedArr === arr); // false
31
31
  *
32
32
  * @example
33
33
  * // Clone an object
34
34
  * const obj = { a: 1, b: 'es-toolkit', c: [1, 2, 3] };
35
- * const clonedObj = clone(obj);
35
+ * const clonedObj = cloneDeep(obj);
36
36
  * console.log(clonedObj); // { a: 1, b: 'es-toolkit', c: [1, 2, 3] }
37
37
  * console.log(clonedObj === obj); // false
38
38
  *
39
39
  * @example
40
40
  * // Clone an object with nested objects
41
41
  * const obj = { a: 1, b: { c: 1 } };
42
- * const clonedObj = clone(obj);
42
+ * const clonedObj = cloneDeep(obj);
43
43
  * obj.b.c = 2;
44
44
  * console.log(obj); // { a: 1, b: { c: 2 } }
45
45
  * console.log(clonedObj); // { a: 1, b: { c: 1 } }
@@ -16,30 +16,30 @@
16
16
  * @example
17
17
  * // Clone an array
18
18
  * const arr = [1, 2, 3];
19
- * const clonedArr = clone(arr);
19
+ * const clonedArr = cloneDeep(arr);
20
20
  * console.log(clonedArr); // [1, 2, 3]
21
21
  * console.log(clonedArr === arr); // false
22
22
  *
23
23
  * @example
24
24
  * // Clone an array with nested objects
25
25
  * const arr = [1, { a: 1 }, [1, 2, 3]];
26
- * const clonedArr = clone(arr);
26
+ * const clonedArr = cloneDeep(arr);
27
27
  * arr[1].a = 2;
28
- * console.log(arr); // [2, { a: 2 }, [1, 2, 3]]
28
+ * console.log(arr); // [1, { a: 2 }, [1, 2, 3]]
29
29
  * console.log(clonedArr); // [1, { a: 1 }, [1, 2, 3]]
30
30
  * console.log(clonedArr === arr); // false
31
31
  *
32
32
  * @example
33
33
  * // Clone an object
34
34
  * const obj = { a: 1, b: 'es-toolkit', c: [1, 2, 3] };
35
- * const clonedObj = clone(obj);
35
+ * const clonedObj = cloneDeep(obj);
36
36
  * console.log(clonedObj); // { a: 1, b: 'es-toolkit', c: [1, 2, 3] }
37
37
  * console.log(clonedObj === obj); // false
38
38
  *
39
39
  * @example
40
40
  * // Clone an object with nested objects
41
41
  * const obj = { a: 1, b: { c: 1 } };
42
- * const clonedObj = clone(obj);
42
+ * const clonedObj = cloneDeep(obj);
43
43
  * obj.b.c = 2;
44
44
  * console.log(obj); // { a: 1, b: { c: 2 } }
45
45
  * console.log(clonedObj); // { a: 1, b: { c: 1 } }
@@ -17,30 +17,30 @@ const require_cloneDeepWith = require("./cloneDeepWith.js");
17
17
  * @example
18
18
  * // Clone an array
19
19
  * const arr = [1, 2, 3];
20
- * const clonedArr = clone(arr);
20
+ * const clonedArr = cloneDeep(arr);
21
21
  * console.log(clonedArr); // [1, 2, 3]
22
22
  * console.log(clonedArr === arr); // false
23
23
  *
24
24
  * @example
25
25
  * // Clone an array with nested objects
26
26
  * const arr = [1, { a: 1 }, [1, 2, 3]];
27
- * const clonedArr = clone(arr);
27
+ * const clonedArr = cloneDeep(arr);
28
28
  * arr[1].a = 2;
29
- * console.log(arr); // [2, { a: 2 }, [1, 2, 3]]
29
+ * console.log(arr); // [1, { a: 2 }, [1, 2, 3]]
30
30
  * console.log(clonedArr); // [1, { a: 1 }, [1, 2, 3]]
31
31
  * console.log(clonedArr === arr); // false
32
32
  *
33
33
  * @example
34
34
  * // Clone an object
35
35
  * const obj = { a: 1, b: 'es-toolkit', c: [1, 2, 3] };
36
- * const clonedObj = clone(obj);
36
+ * const clonedObj = cloneDeep(obj);
37
37
  * console.log(clonedObj); // { a: 1, b: 'es-toolkit', c: [1, 2, 3] }
38
38
  * console.log(clonedObj === obj); // false
39
39
  *
40
40
  * @example
41
41
  * // Clone an object with nested objects
42
42
  * const obj = { a: 1, b: { c: 1 } };
43
- * const clonedObj = clone(obj);
43
+ * const clonedObj = cloneDeep(obj);
44
44
  * obj.b.c = 2;
45
45
  * console.log(obj); // { a: 1, b: { c: 2 } }
46
46
  * console.log(clonedObj); // { a: 1, b: { c: 1 } }
@@ -17,30 +17,30 @@ import { cloneDeepWith } from "./cloneDeepWith.mjs";
17
17
  * @example
18
18
  * // Clone an array
19
19
  * const arr = [1, 2, 3];
20
- * const clonedArr = clone(arr);
20
+ * const clonedArr = cloneDeep(arr);
21
21
  * console.log(clonedArr); // [1, 2, 3]
22
22
  * console.log(clonedArr === arr); // false
23
23
  *
24
24
  * @example
25
25
  * // Clone an array with nested objects
26
26
  * const arr = [1, { a: 1 }, [1, 2, 3]];
27
- * const clonedArr = clone(arr);
27
+ * const clonedArr = cloneDeep(arr);
28
28
  * arr[1].a = 2;
29
- * console.log(arr); // [2, { a: 2 }, [1, 2, 3]]
29
+ * console.log(arr); // [1, { a: 2 }, [1, 2, 3]]
30
30
  * console.log(clonedArr); // [1, { a: 1 }, [1, 2, 3]]
31
31
  * console.log(clonedArr === arr); // false
32
32
  *
33
33
  * @example
34
34
  * // Clone an object
35
35
  * const obj = { a: 1, b: 'es-toolkit', c: [1, 2, 3] };
36
- * const clonedObj = clone(obj);
36
+ * const clonedObj = cloneDeep(obj);
37
37
  * console.log(clonedObj); // { a: 1, b: 'es-toolkit', c: [1, 2, 3] }
38
38
  * console.log(clonedObj === obj); // false
39
39
  *
40
40
  * @example
41
41
  * // Clone an object with nested objects
42
42
  * const obj = { a: 1, b: { c: 1 } };
43
- * const clonedObj = clone(obj);
43
+ * const clonedObj = cloneDeep(obj);
44
44
  * obj.b.c = 2;
45
45
  * console.log(obj); // { a: 1, b: { c: 2 } }
46
46
  * console.log(clonedObj); // { a: 1, b: { c: 1 } }
@@ -32,7 +32,9 @@ const require_cloneDeepWith = require("../../object/cloneDeepWith.js");
32
32
  * // Clone an array with a customizer
33
33
  * const arr = [1, 2, 3];
34
34
  * const clonedArr = cloneDeepWith(arr, (value) => {
35
- * return value + 1; // Increment each value
35
+ * if (typeof value === 'number') {
36
+ * return value + 1; // Increment each number
37
+ * }
36
38
  * });
37
39
  * console.log(clonedArr); // [2, 3, 4]
38
40
  * console.log(clonedArr === arr); // false
@@ -32,7 +32,9 @@ import { cloneDeepWith as cloneDeepWith$1, copyProperties } from "../../object/c
32
32
  * // Clone an array with a customizer
33
33
  * const arr = [1, 2, 3];
34
34
  * const clonedArr = cloneDeepWith(arr, (value) => {
35
- * return value + 1; // Increment each value
35
+ * if (typeof value === 'number') {
36
+ * return value + 1; // Increment each number
37
+ * }
36
38
  * });
37
39
  * console.log(clonedArr); // [2, 3, 4]
38
40
  * console.log(clonedArr === arr); // false
@@ -35,7 +35,7 @@ declare function cloneWith<T, R extends object | string | number | boolean | nul
35
35
  * return value * 2;
36
36
  * }
37
37
  * });
38
- * // => { a: 2, b: 4 }
38
+ * // => { a: 1, b: 2 } (customizer returns undefined for objects, so the default shallow clone is used)
39
39
  */
40
40
  declare function cloneWith<T, R>(value: T, customizer: CloneWithCustomizer<T, R | undefined>): R | T;
41
41
  /**
@@ -35,7 +35,7 @@ declare function cloneWith<T, R extends object | string | number | boolean | nul
35
35
  * return value * 2;
36
36
  * }
37
37
  * });
38
- * // => { a: 2, b: 4 }
38
+ * // => { a: 1, b: 2 } (customizer returns undefined for objects, so the default shallow clone is used)
39
39
  */
40
40
  declare function cloneWith<T, R>(value: T, customizer: CloneWithCustomizer<T, R | undefined>): R | T;
41
41
  /**
@@ -43,7 +43,7 @@ const require_clone = require("./clone.js");
43
43
  * }
44
44
  * // Returning undefined uses the default cloning
45
45
  * });
46
- * console.log(clonedObj); // { a: 2, b: 4 }
46
+ * console.log(clonedObj); // { a: 1, b: 2 } (customizer returns undefined for objects, so the default shallow clone is used)
47
47
  */
48
48
  function cloneWith(value, customizer) {
49
49
  if (!customizer) return require_clone.clone(value);
@@ -43,7 +43,7 @@ import { clone } from "./clone.mjs";
43
43
  * }
44
44
  * // Returning undefined uses the default cloning
45
45
  * });
46
- * console.log(clonedObj); // { a: 2, b: 4 }
46
+ * console.log(clonedObj); // { a: 1, b: 2 } (customizer returns undefined for objects, so the default shallow clone is used)
47
47
  */
48
48
  function cloneWith(value, customizer) {
49
49
  if (!customizer) return clone(value);
@@ -23,7 +23,7 @@ The traversal is interrupted when the `iteratee` function returns `false`.
23
23
  * @example
24
24
  * // Transform an array
25
25
  * const array = [2, 3, 4];
26
- * transform(array, (acc, value) => { acc += value; return value % 2 === 0; }, 0) // => 5
26
+ * transform(array, (acc, value) => { acc.sum += value; return value % 2 === 0; }, { sum: 0 }) // => { sum: 5 }
27
27
  *
28
28
  * @example
29
29
  * // Transform an object
@@ -23,7 +23,7 @@ The traversal is interrupted when the `iteratee` function returns `false`.
23
23
  * @example
24
24
  * // Transform an array
25
25
  * const array = [2, 3, 4];
26
- * transform(array, (acc, value) => { acc += value; return value % 2 === 0; }, 0) // => 5
26
+ * transform(array, (acc, value) => { acc.sum += value; return value % 2 === 0; }, { sum: 0 }) // => { sum: 5 }
27
27
  *
28
28
  * @example
29
29
  * // Transform an object
@@ -10,17 +10,21 @@ const rUnicodeOptContrUpper = "(?:['’](?:D|LL|M|RE|S|T|VE))?";
10
10
  const rUnicodeBreak = `[\\p{Z}\\p{P}${rNonCharLatin}]`;
11
11
  const rUnicodeMiscUpper = `(?:${rUnicodeUpper}|${rMisc})`;
12
12
  const rUnicodeMiscLower = `(?:${rUnicodeLower}|${rMisc})`;
13
- const rUnicodeWord = RegExp([
14
- `${rUnicodeUpper}?${rUnicodeLower}+${rUnicodeOptContrLower}(?=${rUnicodeBreak}|${rUnicodeUpper}|$)`,
15
- `${rUnicodeMiscUpper}+${rUnicodeOptContrUpper}(?=${rUnicodeBreak}|${rUnicodeUpper}${rUnicodeMiscLower}|$)`,
16
- `${rUnicodeUpper}?${rUnicodeMiscLower}+${rUnicodeOptContrLower}`,
17
- `${rUnicodeUpper}+${rUnicodeOptContrUpper}`,
18
- `${rNumber}*(?:1ST|2ND|3RD|(?![123])${rNumber}TH)(?=\\b|[a-z_])`,
19
- `${rNumber}*(?:1st|2nd|3rd|(?![123])${rNumber}th)(?=\\b|[A-Z_])`,
20
- `${rNumber}+`,
21
- "\\p{Emoji_Presentation}",
22
- "\\p{Extended_Pictographic}"
23
- ].join("|"), "gu");
13
+ let rUnicodeWord;
14
+ function getUnicodeWordPattern() {
15
+ if (rUnicodeWord == null) rUnicodeWord = RegExp([
16
+ `${rUnicodeUpper}?${rUnicodeLower}+${rUnicodeOptContrLower}(?=${rUnicodeBreak}|${rUnicodeUpper}|$)`,
17
+ `${rUnicodeMiscUpper}+${rUnicodeOptContrUpper}(?=${rUnicodeBreak}|${rUnicodeUpper}${rUnicodeMiscLower}|$)`,
18
+ `${rUnicodeUpper}?${rUnicodeMiscLower}+${rUnicodeOptContrLower}`,
19
+ `${rUnicodeUpper}+${rUnicodeOptContrUpper}`,
20
+ `${rNumber}*(?:1ST|2ND|3RD|(?![123])${rNumber}TH)(?=\\b|[a-z_])`,
21
+ `${rNumber}*(?:1st|2nd|3rd|(?![123])${rNumber}th)(?=\\b|[A-Z_])`,
22
+ `${rNumber}+`,
23
+ "\\p{Emoji_Presentation}",
24
+ "\\p{Extended_Pictographic}"
25
+ ].join("|"), "gu");
26
+ return rUnicodeWord;
27
+ }
24
28
  /**
25
29
  * Splits `string` into an array of its words.
26
30
  *
@@ -32,9 +36,9 @@ const rUnicodeWord = RegExp([
32
36
  * const wordsArray1 = words('fred, barney, & pebbles');
33
37
  * // => ['fred', 'barney', 'pebbles']
34
38
  */
35
- function words(str, pattern = rUnicodeWord, guard) {
39
+ function words(str, pattern, guard) {
36
40
  const input = require_toString.toString(str);
37
- if (guard) pattern = rUnicodeWord;
41
+ if (guard || pattern === void 0) pattern = getUnicodeWordPattern();
38
42
  if (typeof pattern === "number") pattern = pattern.toString();
39
43
  return Array.from(input.match(pattern) ?? []).filter((x) => x !== "");
40
44
  }
@@ -10,17 +10,21 @@ const rUnicodeOptContrUpper = "(?:['’](?:D|LL|M|RE|S|T|VE))?";
10
10
  const rUnicodeBreak = `[\\p{Z}\\p{P}${rNonCharLatin}]`;
11
11
  const rUnicodeMiscUpper = `(?:${rUnicodeUpper}|${rMisc})`;
12
12
  const rUnicodeMiscLower = `(?:${rUnicodeLower}|${rMisc})`;
13
- const rUnicodeWord = RegExp([
14
- `${rUnicodeUpper}?${rUnicodeLower}+${rUnicodeOptContrLower}(?=${rUnicodeBreak}|${rUnicodeUpper}|$)`,
15
- `${rUnicodeMiscUpper}+${rUnicodeOptContrUpper}(?=${rUnicodeBreak}|${rUnicodeUpper}${rUnicodeMiscLower}|$)`,
16
- `${rUnicodeUpper}?${rUnicodeMiscLower}+${rUnicodeOptContrLower}`,
17
- `${rUnicodeUpper}+${rUnicodeOptContrUpper}`,
18
- `${rNumber}*(?:1ST|2ND|3RD|(?![123])${rNumber}TH)(?=\\b|[a-z_])`,
19
- `${rNumber}*(?:1st|2nd|3rd|(?![123])${rNumber}th)(?=\\b|[A-Z_])`,
20
- `${rNumber}+`,
21
- "\\p{Emoji_Presentation}",
22
- "\\p{Extended_Pictographic}"
23
- ].join("|"), "gu");
13
+ let rUnicodeWord;
14
+ function getUnicodeWordPattern() {
15
+ if (rUnicodeWord == null) rUnicodeWord = RegExp([
16
+ `${rUnicodeUpper}?${rUnicodeLower}+${rUnicodeOptContrLower}(?=${rUnicodeBreak}|${rUnicodeUpper}|$)`,
17
+ `${rUnicodeMiscUpper}+${rUnicodeOptContrUpper}(?=${rUnicodeBreak}|${rUnicodeUpper}${rUnicodeMiscLower}|$)`,
18
+ `${rUnicodeUpper}?${rUnicodeMiscLower}+${rUnicodeOptContrLower}`,
19
+ `${rUnicodeUpper}+${rUnicodeOptContrUpper}`,
20
+ `${rNumber}*(?:1ST|2ND|3RD|(?![123])${rNumber}TH)(?=\\b|[a-z_])`,
21
+ `${rNumber}*(?:1st|2nd|3rd|(?![123])${rNumber}th)(?=\\b|[A-Z_])`,
22
+ `${rNumber}+`,
23
+ "\\p{Emoji_Presentation}",
24
+ "\\p{Extended_Pictographic}"
25
+ ].join("|"), "gu");
26
+ return rUnicodeWord;
27
+ }
24
28
  /**
25
29
  * Splits `string` into an array of its words.
26
30
  *
@@ -32,9 +36,9 @@ const rUnicodeWord = RegExp([
32
36
  * const wordsArray1 = words('fred, barney, & pebbles');
33
37
  * // => ['fred', 'barney', 'pebbles']
34
38
  */
35
- function words(str, pattern = rUnicodeWord, guard) {
39
+ function words(str, pattern, guard) {
36
40
  const input = toString(str);
37
- if (guard) pattern = rUnicodeWord;
41
+ if (guard || pattern === void 0) pattern = getUnicodeWordPattern();
38
42
  if (typeof pattern === "number") pattern = pattern.toString();
39
43
  return Array.from(input.match(pattern) ?? []).filter((x) => x !== "");
40
44
  }
@@ -7,8 +7,8 @@
7
7
  * @returns Returns an array of the record's values or an empty array if null/undefined.
8
8
  *
9
9
  * @example
10
- * toArray({ 'a': 1, 'b': 2 }) // => returns [1, 2]
11
- * toArray(null) // => returns []
10
+ * toArray({ 'a': 1, 'b': 2 }) // => [1, 2]
11
+ * toArray(null) // => []
12
12
  */
13
13
  declare function toArray<T>(value: Record<string, T> | Record<number, T> | null | undefined): T[];
14
14
  /**
@@ -19,8 +19,8 @@ declare function toArray<T>(value: Record<string, T> | Record<number, T> | null
19
19
  * @returns Returns an array of the value's values.
20
20
  *
21
21
  * @example
22
- * toArray({ x: 10, y: 20 }) // => returns [10, 20]
23
- * toArray('abc') // => returns ['a', 'b', 'c']
22
+ * toArray({ x: 10, y: 20 }) // => [10, 20]
23
+ * toArray('abc') // => ['a', 'b', 'c']
24
24
  */
25
25
  declare function toArray<T>(value: T): Array<T[keyof T]>;
26
26
  /**
@@ -29,7 +29,7 @@ declare function toArray<T>(value: T): Array<T[keyof T]>;
29
29
  * @returns Returns an empty array.
30
30
  *
31
31
  * @example
32
- * toArray() // => returns []
32
+ * toArray() // => []
33
33
  */
34
34
  declare function toArray(): any[];
35
35
  //#endregion
@@ -7,8 +7,8 @@
7
7
  * @returns Returns an array of the record's values or an empty array if null/undefined.
8
8
  *
9
9
  * @example
10
- * toArray({ 'a': 1, 'b': 2 }) // => returns [1, 2]
11
- * toArray(null) // => returns []
10
+ * toArray({ 'a': 1, 'b': 2 }) // => [1, 2]
11
+ * toArray(null) // => []
12
12
  */
13
13
  declare function toArray<T>(value: Record<string, T> | Record<number, T> | null | undefined): T[];
14
14
  /**
@@ -19,8 +19,8 @@ declare function toArray<T>(value: Record<string, T> | Record<number, T> | null
19
19
  * @returns Returns an array of the value's values.
20
20
  *
21
21
  * @example
22
- * toArray({ x: 10, y: 20 }) // => returns [10, 20]
23
- * toArray('abc') // => returns ['a', 'b', 'c']
22
+ * toArray({ x: 10, y: 20 }) // => [10, 20]
23
+ * toArray('abc') // => ['a', 'b', 'c']
24
24
  */
25
25
  declare function toArray<T>(value: T): Array<T[keyof T]>;
26
26
  /**
@@ -29,7 +29,7 @@ declare function toArray<T>(value: T): Array<T[keyof T]>;
29
29
  * @returns Returns an empty array.
30
30
  *
31
31
  * @example
32
- * toArray() // => returns []
32
+ * toArray() // => []
33
33
  */
34
34
  declare function toArray(): any[];
35
35
  //#endregion
@@ -10,10 +10,10 @@ const require_isSet = require("../predicate/isSet.js");
10
10
  * @returns Returns the converted array.
11
11
  *
12
12
  * @example
13
- * toArray({ 'a': 1, 'b': 2 }) // => returns [1,2]
14
- * toArray('abc') // => returns ['a', 'b', 'c']
15
- * toArray(1) // => returns []
16
- * toArray(null) // => returns []
13
+ * toArray({ 'a': 1, 'b': 2 }) // => [1,2]
14
+ * toArray('abc') // => ['a', 'b', 'c']
15
+ * toArray(1) // => []
16
+ * toArray(null) // => []
17
17
  */
18
18
  function toArray(value) {
19
19
  if (value == null) return [];
@@ -10,10 +10,10 @@ import { isSet } from "../predicate/isSet.mjs";
10
10
  * @returns Returns the converted array.
11
11
  *
12
12
  * @example
13
- * toArray({ 'a': 1, 'b': 2 }) // => returns [1,2]
14
- * toArray('abc') // => returns ['a', 'b', 'c']
15
- * toArray(1) // => returns []
16
- * toArray(null) // => returns []
13
+ * toArray({ 'a': 1, 'b': 2 }) // => [1,2]
14
+ * toArray('abc') // => ['a', 'b', 'c']
15
+ * toArray(1) // => []
16
+ * toArray(null) // => []
17
17
  */
18
18
  function toArray(value) {
19
19
  if (value == null) return [];
@@ -67,8 +67,9 @@
67
67
  * }
68
68
  * const customCache = new CustomCache<string, number>();
69
69
  * const memoizedSumWithCustomCache = memoize(sum, { cache: customCache });
70
- * console.log(memoizedSumWithCustomCache([1, 2])); // 3
71
- * console.log(memoizedSumWithCustomCache([1, 2])); // 3 (cached result)
70
+ * const arr = [1, 2];
71
+ * console.log(memoizedSumWithCustomCache(arr)); // 3
72
+ * console.log(memoizedSumWithCustomCache(arr)); // 3 (cached result)
72
73
  * console.log(memoizedSumWithCustomCache.cache.size); // 1
73
74
  */
74
75
  declare function memoize<F extends (...args: any) => any>(fn: F, options?: {
@@ -67,8 +67,9 @@
67
67
  * }
68
68
  * const customCache = new CustomCache<string, number>();
69
69
  * const memoizedSumWithCustomCache = memoize(sum, { cache: customCache });
70
- * console.log(memoizedSumWithCustomCache([1, 2])); // 3
71
- * console.log(memoizedSumWithCustomCache([1, 2])); // 3 (cached result)
70
+ * const arr = [1, 2];
71
+ * console.log(memoizedSumWithCustomCache(arr)); // 3
72
+ * console.log(memoizedSumWithCustomCache(arr)); // 3 (cached result)
72
73
  * console.log(memoizedSumWithCustomCache.cache.size); // 1
73
74
  */
74
75
  declare function memoize<F extends (...args: any) => any>(fn: F, options?: {
@@ -67,8 +67,9 @@
67
67
  * }
68
68
  * const customCache = new CustomCache<string, number>();
69
69
  * const memoizedSumWithCustomCache = memoize(sum, { cache: customCache });
70
- * console.log(memoizedSumWithCustomCache([1, 2])); // 3
71
- * console.log(memoizedSumWithCustomCache([1, 2])); // 3 (cached result)
70
+ * const arr = [1, 2];
71
+ * console.log(memoizedSumWithCustomCache(arr)); // 3
72
+ * console.log(memoizedSumWithCustomCache(arr)); // 3 (cached result)
72
73
  * console.log(memoizedSumWithCustomCache.cache.size); // 1
73
74
  */
74
75
  function memoize(fn, options = {}) {
@@ -67,8 +67,9 @@
67
67
  * }
68
68
  * const customCache = new CustomCache<string, number>();
69
69
  * const memoizedSumWithCustomCache = memoize(sum, { cache: customCache });
70
- * console.log(memoizedSumWithCustomCache([1, 2])); // 3
71
- * console.log(memoizedSumWithCustomCache([1, 2])); // 3 (cached result)
70
+ * const arr = [1, 2];
71
+ * console.log(memoizedSumWithCustomCache(arr)); // 3
72
+ * console.log(memoizedSumWithCustomCache(arr)); // 3 (cached result)
72
73
  * console.log(memoizedSumWithCustomCache.cache.size); // 1
73
74
  */
74
75
  function memoize(fn, options = {}) {
@@ -330,7 +330,7 @@ declare function partial<T1, T2, T3, T4, R>(func: (arg1: T1, arg2: T2, arg3: T3,
330
330
  * @returns A new function that takes the first and third arguments and returns the result of the original function.
331
331
  *
332
332
  * @example
333
- * const multiply = (x: number, y: number, z: number, w: number) => x * y * z * w;
333
+ * const multiply = (x: number, y: number, z: number) => x * y * z;
334
334
  * const multiplyWithPlaceholder = partial(multiply, partial.placeholder, 2, 3);
335
335
  * console.log(multiplyWithPlaceholder(4)); // => 24
336
336
  */
@@ -540,7 +540,7 @@ declare function partial<TS extends any[], T1, R>(func: (arg1: T1, ...args: TS)
540
540
  *
541
541
  * @example
542
542
  * const greet = (greeting: string, name: string, punctuation: string) => `${greeting}, ${name}${punctuation}`;
543
- * const greetWithHello = partial(greet, 'Hello', '!');
543
+ * const greetWithHello = partial(greet, 'Hello', partial.placeholder, '!');
544
544
  * console.log(greetWithHello('John')); // => 'Hello, John!'
545
545
  */
546
546
  declare function partial<TS extends any[], T1, T2, R>(func: (arg1: T1, arg2: T2, ...args: TS) => R, t1: T1, arg2: T2): (...args: TS) => R;
@@ -330,7 +330,7 @@ declare function partial<T1, T2, T3, T4, R>(func: (arg1: T1, arg2: T2, arg3: T3,
330
330
  * @returns A new function that takes the first and third arguments and returns the result of the original function.
331
331
  *
332
332
  * @example
333
- * const multiply = (x: number, y: number, z: number, w: number) => x * y * z * w;
333
+ * const multiply = (x: number, y: number, z: number) => x * y * z;
334
334
  * const multiplyWithPlaceholder = partial(multiply, partial.placeholder, 2, 3);
335
335
  * console.log(multiplyWithPlaceholder(4)); // => 24
336
336
  */
@@ -540,7 +540,7 @@ declare function partial<TS extends any[], T1, R>(func: (arg1: T1, ...args: TS)
540
540
  *
541
541
  * @example
542
542
  * const greet = (greeting: string, name: string, punctuation: string) => `${greeting}, ${name}${punctuation}`;
543
- * const greetWithHello = partial(greet, 'Hello', '!');
543
+ * const greetWithHello = partial(greet, 'Hello', partial.placeholder, '!');
544
544
  * console.log(greetWithHello('John')); // => 'Hello, John!'
545
545
  */
546
546
  declare function partial<TS extends any[], T1, T2, R>(func: (arg1: T1, arg2: T2, ...args: TS) => R, t1: T1, arg2: T2): (...args: TS) => R;
@@ -203,7 +203,7 @@ declare function partialRight<T1, T2, T3, R>(func: (arg1: T1, arg2: T2, arg3: T3
203
203
  * @returns Returns the new partially applied function.
204
204
  * @example
205
205
  * const createUser = (name: string, age: number, country: string) => `${name}, ${age} years old from ${country}`;
206
- * const createUserFromUSA = partialRight(createUser, 'USA', partialRight.placeholder);
206
+ * const createUserFromUSA = partialRight(createUser, 'USA');
207
207
  * console.log(createUserFromUSA('John', 30)); // => 'John, 30 years old from USA'
208
208
  */
209
209
  declare function partialRight<T1, T2, T3, R>(func: (arg1: T1, arg2: T2, arg3: T3) => R, arg2: T2, arg3: Placeholder): (arg1: T1, arg3: T3) => R;
@@ -225,7 +225,7 @@ declare function partialRight<T1, T2, T3, R>(func: (arg1: T1, arg2: T2, arg3: T3
225
225
  * @returns Returns the new partially applied function.
226
226
  * @example
227
227
  * const logMessage = (level: string, message: string, timestamp: string) => `[${level}] ${message} at ${timestamp}`;
228
- * const logError = partialRight(logMessage, 'ERROR', '2023-10-01');
228
+ * const logError = partialRight(logMessage, 'ERROR', partialRight.placeholder, '2023-10-01');
229
229
  * console.log(logError('Something went wrong!')); // => '[ERROR] Something went wrong! at 2023-10-01'
230
230
  */
231
231
  declare function partialRight<T1, T2, T3, R>(func: (arg1: T1, arg2: T2, arg3: T3) => R, arg1: T1, arg2: T2, arg3: Placeholder): (arg3: T3) => R;
@@ -288,7 +288,7 @@ declare function partialRight<T1, T2, T3, R>(func: (arg1: T1, arg2: T2, arg3: T3
288
288
  * @returns Returns the new partially applied function.
289
289
  * @example
290
290
  * const createProfile = (name: string, age: number, country: string) => `${name}, ${age} from ${country}`;
291
- * const createProfileFromCanada = partialRight(createProfile, 'Canada', 'John');
291
+ * const createProfileFromCanada = partialRight(createProfile, 'John', partialRight.placeholder, 'Canada');
292
292
  * console.log(createProfileFromCanada(30)); // => 'John, 30 from Canada'
293
293
  */
294
294
  declare function partialRight<T1, T2, T3, R>(func: (arg1: T1, arg2: T2, arg3: T3) => R, arg2: T2, arg3: T3): (arg1: T1) => R;
@@ -615,9 +615,9 @@ declare function partialRight<T1, T2, T3, T4, R>(func: (arg1: T1, arg2: T2, arg3
615
615
  * @param args The arguments to be partially applied.
616
616
  * @returns Returns the new partially applied function.
617
617
  * @example
618
- * const log = (...messages: string[]) => console.log(...messages);
618
+ * const log = (...messages: string[]) => messages.join(' ');
619
619
  * const logError = partialRight(log, 'Error:');
620
- * logError('Something went wrong!'); // => 'Error: Something went wrong!'
620
+ * logError('Something went wrong!'); // => 'Something went wrong! Error:'
621
621
  */
622
622
  declare function partialRight(func: (...args: any[]) => any, ...args: any[]): (...args: any[]) => any;
623
623
  declare namespace partialRight {
@@ -203,7 +203,7 @@ declare function partialRight<T1, T2, T3, R>(func: (arg1: T1, arg2: T2, arg3: T3
203
203
  * @returns Returns the new partially applied function.
204
204
  * @example
205
205
  * const createUser = (name: string, age: number, country: string) => `${name}, ${age} years old from ${country}`;
206
- * const createUserFromUSA = partialRight(createUser, 'USA', partialRight.placeholder);
206
+ * const createUserFromUSA = partialRight(createUser, 'USA');
207
207
  * console.log(createUserFromUSA('John', 30)); // => 'John, 30 years old from USA'
208
208
  */
209
209
  declare function partialRight<T1, T2, T3, R>(func: (arg1: T1, arg2: T2, arg3: T3) => R, arg2: T2, arg3: Placeholder): (arg1: T1, arg3: T3) => R;
@@ -225,7 +225,7 @@ declare function partialRight<T1, T2, T3, R>(func: (arg1: T1, arg2: T2, arg3: T3
225
225
  * @returns Returns the new partially applied function.
226
226
  * @example
227
227
  * const logMessage = (level: string, message: string, timestamp: string) => `[${level}] ${message} at ${timestamp}`;
228
- * const logError = partialRight(logMessage, 'ERROR', '2023-10-01');
228
+ * const logError = partialRight(logMessage, 'ERROR', partialRight.placeholder, '2023-10-01');
229
229
  * console.log(logError('Something went wrong!')); // => '[ERROR] Something went wrong! at 2023-10-01'
230
230
  */
231
231
  declare function partialRight<T1, T2, T3, R>(func: (arg1: T1, arg2: T2, arg3: T3) => R, arg1: T1, arg2: T2, arg3: Placeholder): (arg3: T3) => R;
@@ -288,7 +288,7 @@ declare function partialRight<T1, T2, T3, R>(func: (arg1: T1, arg2: T2, arg3: T3
288
288
  * @returns Returns the new partially applied function.
289
289
  * @example
290
290
  * const createProfile = (name: string, age: number, country: string) => `${name}, ${age} from ${country}`;
291
- * const createProfileFromCanada = partialRight(createProfile, 'Canada', 'John');
291
+ * const createProfileFromCanada = partialRight(createProfile, 'John', partialRight.placeholder, 'Canada');
292
292
  * console.log(createProfileFromCanada(30)); // => 'John, 30 from Canada'
293
293
  */
294
294
  declare function partialRight<T1, T2, T3, R>(func: (arg1: T1, arg2: T2, arg3: T3) => R, arg2: T2, arg3: T3): (arg1: T1) => R;
@@ -615,9 +615,9 @@ declare function partialRight<T1, T2, T3, T4, R>(func: (arg1: T1, arg2: T2, arg3
615
615
  * @param args The arguments to be partially applied.
616
616
  * @returns Returns the new partially applied function.
617
617
  * @example
618
- * const log = (...messages: string[]) => console.log(...messages);
618
+ * const log = (...messages: string[]) => messages.join(' ');
619
619
  * const logError = partialRight(log, 'Error:');
620
- * logError('Something went wrong!'); // => 'Error: Something went wrong!'
620
+ * logError('Something went wrong!'); // => 'Something went wrong! Error:'
621
621
  */
622
622
  declare function partialRight(func: (...args: any[]) => any, ...args: any[]): (...args: any[]) => any;
623
623
  declare namespace partialRight {
@@ -24,7 +24,7 @@
24
24
  *
25
25
  * // Using start index 1
26
26
  * const transformedFnWithStart = rest(fn, 1);
27
- * console.log(transformedFnWithStart(1, 2, 3, 4)); // [1, [2, 3, 4]]
27
+ * console.log(transformedFnWithStart(1, 2, 3, 4)); // [1, [2, 3, 4], undefined]
28
28
  *
29
29
  * // With fewer arguments than the start index
30
30
  * console.log(transformedFn(1)); // [1, undefined, []]
@@ -24,7 +24,7 @@
24
24
  *
25
25
  * // Using start index 1
26
26
  * const transformedFnWithStart = rest(fn, 1);
27
- * console.log(transformedFnWithStart(1, 2, 3, 4)); // [1, [2, 3, 4]]
27
+ * console.log(transformedFnWithStart(1, 2, 3, 4)); // [1, [2, 3, 4], undefined]
28
28
  *
29
29
  * // With fewer arguments than the start index
30
30
  * console.log(transformedFn(1)); // [1, undefined, []]