es-toolkit 1.27.0 → 1.28.0-dev.910

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 (119) hide show
  1. package/CHANGELOG.md +14 -0
  2. package/dist/_chunk/{isWeakSet-D8h8bS.js → isWeakSet-CvIdTA.js} +5 -0
  3. package/dist/_chunk/{toMerged-CPY8Ug.js → toMerged-AV73JV.js} +77 -65
  4. package/dist/_chunk/{upperFirst-DK_rTF.js → upperFirst-CorAVn.js} +1 -0
  5. package/dist/array/differenceBy.d.mts +10 -3
  6. package/dist/array/differenceBy.d.ts +10 -3
  7. package/dist/array/differenceWith.d.mts +11 -4
  8. package/dist/array/differenceWith.d.ts +11 -4
  9. package/dist/array/flatMap.d.mts +1 -1
  10. package/dist/array/flatMap.d.ts +1 -1
  11. package/dist/array/intersectionBy.d.mts +16 -5
  12. package/dist/array/intersectionBy.d.ts +16 -5
  13. package/dist/array/intersectionWith.d.mts +16 -4
  14. package/dist/array/intersectionWith.d.ts +16 -4
  15. package/dist/browser.global.js +1 -1
  16. package/dist/browser.global.js.map +1 -1
  17. package/dist/compat/array/dropRightWhile.d.mts +2 -2
  18. package/dist/compat/array/dropRightWhile.d.ts +2 -2
  19. package/dist/compat/array/dropRightWhile.mjs +2 -0
  20. package/dist/compat/array/dropWhile.d.mts +2 -2
  21. package/dist/compat/array/dropWhile.d.ts +2 -2
  22. package/dist/compat/array/dropWhile.mjs +2 -0
  23. package/dist/compat/array/every.d.mts +6 -6
  24. package/dist/compat/array/every.d.ts +6 -6
  25. package/dist/compat/array/every.mjs +2 -0
  26. package/dist/compat/array/filter.d.mts +4 -4
  27. package/dist/compat/array/filter.d.ts +4 -4
  28. package/dist/compat/array/filter.mjs +2 -0
  29. package/dist/compat/array/find.d.mts +6 -6
  30. package/dist/compat/array/find.d.ts +6 -6
  31. package/dist/compat/array/find.mjs +2 -0
  32. package/dist/compat/array/findIndex.d.mts +3 -3
  33. package/dist/compat/array/findIndex.d.ts +3 -3
  34. package/dist/compat/array/findIndex.mjs +2 -0
  35. package/dist/compat/array/findLastIndex.d.mts +3 -3
  36. package/dist/compat/array/findLastIndex.d.ts +3 -3
  37. package/dist/compat/array/findLastIndex.mjs +2 -0
  38. package/dist/compat/array/some.d.mts +5 -5
  39. package/dist/compat/array/some.d.ts +5 -5
  40. package/dist/compat/array/some.mjs +2 -0
  41. package/dist/compat/array/uniqBy.d.mts +34 -13
  42. package/dist/compat/array/uniqBy.d.ts +34 -13
  43. package/dist/compat/array/uniqBy.mjs +3 -16
  44. package/dist/compat/function/debounce.d.mts +7 -5
  45. package/dist/compat/function/debounce.d.ts +7 -5
  46. package/dist/compat/function/throttle.d.mts +3 -4
  47. package/dist/compat/function/throttle.d.ts +3 -4
  48. package/dist/compat/function/throttle.mjs +6 -1
  49. package/dist/compat/index.d.mts +13 -2
  50. package/dist/compat/index.d.ts +13 -2
  51. package/dist/compat/index.js +211 -69
  52. package/dist/compat/index.mjs +11 -1
  53. package/dist/compat/math/add.d.mts +18 -0
  54. package/dist/compat/math/add.d.ts +18 -0
  55. package/dist/compat/math/add.mjs +5 -0
  56. package/dist/compat/object/assignIn.d.mts +103 -0
  57. package/dist/compat/object/assignIn.d.ts +103 -0
  58. package/dist/compat/object/assignIn.mjs +20 -0
  59. package/dist/compat/object/cloneDeep.mjs +2 -24
  60. package/dist/compat/object/cloneDeepWith.d.mts +38 -0
  61. package/dist/compat/object/cloneDeepWith.d.ts +38 -0
  62. package/dist/compat/object/cloneDeepWith.mjs +35 -0
  63. package/dist/compat/object/keysIn.d.mts +26 -0
  64. package/dist/compat/object/keysIn.d.ts +26 -0
  65. package/dist/compat/object/keysIn.mjs +53 -0
  66. package/dist/compat/predicate/isElement.d.mts +13 -0
  67. package/dist/compat/predicate/isElement.d.ts +13 -0
  68. package/dist/compat/predicate/isElement.mjs +8 -0
  69. package/dist/compat/string/toUpper.d.mts +20 -0
  70. package/dist/compat/string/toUpper.d.ts +20 -0
  71. package/dist/compat/string/toUpper.mjs +7 -0
  72. package/dist/compat/string/trim.mjs +1 -1
  73. package/dist/compat/string/trimEnd.mjs +1 -1
  74. package/dist/compat/string/trimStart.mjs +1 -1
  75. package/dist/compat/string/words.d.mts +15 -0
  76. package/dist/compat/string/words.d.ts +15 -0
  77. package/dist/compat/string/words.mjs +10 -0
  78. package/dist/compat/util/gt.d.mts +15 -0
  79. package/dist/compat/util/gt.d.ts +15 -0
  80. package/dist/compat/util/gt.mjs +10 -0
  81. package/dist/compat/util/gte.d.mts +15 -0
  82. package/dist/compat/util/gte.d.ts +15 -0
  83. package/dist/compat/util/gte.mjs +10 -0
  84. package/dist/compat/util/iteratee.d.mts +1 -1
  85. package/dist/compat/util/iteratee.d.ts +1 -1
  86. package/dist/compat/util/toArray.d.mts +15 -0
  87. package/dist/compat/util/toArray.d.ts +15 -0
  88. package/dist/compat/util/toArray.mjs +20 -0
  89. package/dist/function/debounce.d.mts +24 -22
  90. package/dist/function/debounce.d.ts +24 -22
  91. package/dist/function/index.d.mts +2 -2
  92. package/dist/function/index.d.ts +2 -2
  93. package/dist/function/partial.d.mts +533 -15
  94. package/dist/function/partial.d.ts +533 -15
  95. package/dist/function/partialRight.d.mts +610 -15
  96. package/dist/function/partialRight.d.ts +610 -15
  97. package/dist/function/throttle.d.mts +7 -5
  98. package/dist/function/throttle.d.ts +7 -5
  99. package/dist/index.d.mts +4 -2
  100. package/dist/index.d.ts +4 -2
  101. package/dist/index.js +5 -3
  102. package/dist/index.mjs +2 -0
  103. package/dist/object/cloneDeep.mjs +3 -110
  104. package/dist/object/cloneDeepWith.d.mts +38 -0
  105. package/dist/object/cloneDeepWith.d.ts +38 -0
  106. package/dist/object/cloneDeepWith.mjs +121 -0
  107. package/dist/object/index.d.mts +1 -0
  108. package/dist/object/index.d.ts +1 -0
  109. package/dist/object/index.js +2 -1
  110. package/dist/object/index.mjs +1 -0
  111. package/dist/predicate/index.d.mts +1 -0
  112. package/dist/predicate/index.d.ts +1 -0
  113. package/dist/predicate/index.js +2 -1
  114. package/dist/predicate/index.mjs +1 -0
  115. package/dist/predicate/isBuffer.d.mts +21 -0
  116. package/dist/predicate/isBuffer.d.ts +21 -0
  117. package/dist/predicate/isBuffer.mjs +5 -0
  118. package/dist/string/index.js +1 -1
  119. package/package.json +1 -1
@@ -12,6 +12,11 @@ interface ThrottleOptions {
12
12
  */
13
13
  edges?: Array<'leading' | 'trailing'>;
14
14
  }
15
+ interface ThrottledFunction<F extends (...args: any[]) => void> {
16
+ (...args: Parameters<F>): void;
17
+ cancel: () => void;
18
+ flush: () => void;
19
+ }
15
20
  /**
16
21
  * Creates a throttled function that only invokes the provided function at most once
17
22
  * per every `throttleMs` milliseconds. Subsequent calls to the throttled function
@@ -38,9 +43,6 @@ interface ThrottleOptions {
38
43
  * throttledFunction(); // Will log 'Function executed'
39
44
  * }, 1000);
40
45
  */
41
- declare function throttle<F extends (...args: any[]) => void>(func: F, throttleMs: number, { signal, edges }?: ThrottleOptions): ((...args: Parameters<F>) => void) & {
42
- cancel: () => void;
43
- flush: () => void;
44
- };
46
+ declare function throttle<F extends (...args: any[]) => void>(func: F, throttleMs: number, { signal, edges }?: ThrottleOptions): ThrottledFunction<F>;
45
47
 
46
- export { throttle };
48
+ export { type ThrottledFunction, throttle };
package/dist/index.d.mts CHANGED
@@ -62,7 +62,7 @@ export { ary } from './function/ary.mjs';
62
62
  export { before } from './function/before.mjs';
63
63
  export { curry } from './function/curry.mjs';
64
64
  export { curryRight } from './function/curryRight.mjs';
65
- export { debounce } from './function/debounce.mjs';
65
+ export { DebouncedFunction, debounce } from './function/debounce.mjs';
66
66
  export { flow } from './function/flow.mjs';
67
67
  export { flowRight } from './function/flowRight.mjs';
68
68
  export { identity } from './function/identity.mjs';
@@ -74,7 +74,7 @@ export { partial } from './function/partial.mjs';
74
74
  export { partialRight } from './function/partialRight.mjs';
75
75
  export { rest } from './function/rest.mjs';
76
76
  export { spread } from './function/spread.mjs';
77
- export { throttle } from './function/throttle.mjs';
77
+ export { ThrottledFunction, throttle } from './function/throttle.mjs';
78
78
  export { unary } from './function/unary.mjs';
79
79
  export { clamp } from './math/clamp.mjs';
80
80
  export { inRange } from './math/inRange.mjs';
@@ -91,6 +91,7 @@ export { sum } from './math/sum.mjs';
91
91
  export { sumBy } from './math/sumBy.mjs';
92
92
  export { clone } from './object/clone.mjs';
93
93
  export { cloneDeep } from './object/cloneDeep.mjs';
94
+ export { cloneDeepWith } from './object/cloneDeepWith.mjs';
94
95
  export { findKey } from './object/findKey.mjs';
95
96
  export { flattenObject } from './object/flattenObject.mjs';
96
97
  export { invert } from './object/invert.mjs';
@@ -106,6 +107,7 @@ export { toMerged } from './object/toMerged.mjs';
106
107
  export { isArrayBuffer } from './predicate/isArrayBuffer.mjs';
107
108
  export { isBlob } from './predicate/isBlob.mjs';
108
109
  export { isBoolean } from './predicate/isBoolean.mjs';
110
+ export { isBuffer } from './predicate/isBuffer.mjs';
109
111
  export { isDate } from './predicate/isDate.mjs';
110
112
  export { isEqual } from './predicate/isEqual.mjs';
111
113
  export { isEqualWith } from './predicate/isEqualWith.mjs';
package/dist/index.d.ts CHANGED
@@ -62,7 +62,7 @@ export { ary } from './function/ary.js';
62
62
  export { before } from './function/before.js';
63
63
  export { curry } from './function/curry.js';
64
64
  export { curryRight } from './function/curryRight.js';
65
- export { debounce } from './function/debounce.js';
65
+ export { DebouncedFunction, debounce } from './function/debounce.js';
66
66
  export { flow } from './function/flow.js';
67
67
  export { flowRight } from './function/flowRight.js';
68
68
  export { identity } from './function/identity.js';
@@ -74,7 +74,7 @@ export { partial } from './function/partial.js';
74
74
  export { partialRight } from './function/partialRight.js';
75
75
  export { rest } from './function/rest.js';
76
76
  export { spread } from './function/spread.js';
77
- export { throttle } from './function/throttle.js';
77
+ export { ThrottledFunction, throttle } from './function/throttle.js';
78
78
  export { unary } from './function/unary.js';
79
79
  export { clamp } from './math/clamp.js';
80
80
  export { inRange } from './math/inRange.js';
@@ -91,6 +91,7 @@ export { sum } from './math/sum.js';
91
91
  export { sumBy } from './math/sumBy.js';
92
92
  export { clone } from './object/clone.js';
93
93
  export { cloneDeep } from './object/cloneDeep.js';
94
+ export { cloneDeepWith } from './object/cloneDeepWith.js';
94
95
  export { findKey } from './object/findKey.js';
95
96
  export { flattenObject } from './object/flattenObject.js';
96
97
  export { invert } from './object/invert.js';
@@ -106,6 +107,7 @@ export { toMerged } from './object/toMerged.js';
106
107
  export { isArrayBuffer } from './predicate/isArrayBuffer.js';
107
108
  export { isBlob } from './predicate/isBlob.js';
108
109
  export { isBoolean } from './predicate/isBoolean.js';
110
+ export { isBuffer } from './predicate/isBuffer.js';
109
111
  export { isDate } from './predicate/isDate.js';
110
112
  export { isEqual } from './predicate/isEqual.js';
111
113
  export { isEqualWith } from './predicate/isEqualWith.js';
package/dist/index.js CHANGED
@@ -11,12 +11,12 @@ const noop = require('./_chunk/noop-2IwLUk.js');
11
11
  const rangeRight = require('./_chunk/rangeRight-w3WrXN.js');
12
12
  const randomInt = require('./_chunk/randomInt-CF7bZK.js');
13
13
  const math_index = require('./math/index.js');
14
- const toMerged = require('./_chunk/toMerged-CPY8Ug.js');
14
+ const toMerged = require('./_chunk/toMerged-AV73JV.js');
15
15
  const object_index = require('./object/index.js');
16
- const isWeakSet = require('./_chunk/isWeakSet-D8h8bS.js');
16
+ const isWeakSet = require('./_chunk/isWeakSet-CvIdTA.js');
17
17
  const predicate_index = require('./predicate/index.js');
18
18
  const isPlainObject = require('./_chunk/isPlainObject-octpoD.js');
19
- const upperFirst = require('./_chunk/upperFirst-DK_rTF.js');
19
+ const upperFirst = require('./_chunk/upperFirst-CorAVn.js');
20
20
  const string_index = require('./string/index.js');
21
21
  const util_index = require('./util/index.js');
22
22
 
@@ -118,6 +118,7 @@ exports.round = math_index.round;
118
118
  exports.sumBy = math_index.sumBy;
119
119
  exports.clone = toMerged.clone;
120
120
  exports.cloneDeep = toMerged.cloneDeep;
121
+ exports.cloneDeepWith = toMerged.cloneDeepWith;
121
122
  exports.findKey = toMerged.findKey;
122
123
  exports.flattenObject = toMerged.flattenObject;
123
124
  exports.invert = toMerged.invert;
@@ -132,6 +133,7 @@ exports.omit = object_index.omit;
132
133
  exports.pick = object_index.pick;
133
134
  exports.isArrayBuffer = isWeakSet.isArrayBuffer;
134
135
  exports.isBlob = isWeakSet.isBlob;
136
+ exports.isBuffer = isWeakSet.isBuffer;
135
137
  exports.isDate = isWeakSet.isDate;
136
138
  exports.isEqual = isWeakSet.isEqual;
137
139
  exports.isEqualWith = isWeakSet.isEqualWith;
package/dist/index.mjs CHANGED
@@ -91,6 +91,7 @@ export { sum } from './math/sum.mjs';
91
91
  export { sumBy } from './math/sumBy.mjs';
92
92
  export { clone } from './object/clone.mjs';
93
93
  export { cloneDeep } from './object/cloneDeep.mjs';
94
+ export { cloneDeepWith } from './object/cloneDeepWith.mjs';
94
95
  export { findKey } from './object/findKey.mjs';
95
96
  export { flattenObject } from './object/flattenObject.mjs';
96
97
  export { invert } from './object/invert.mjs';
@@ -106,6 +107,7 @@ export { toMerged } from './object/toMerged.mjs';
106
107
  export { isArrayBuffer } from './predicate/isArrayBuffer.mjs';
107
108
  export { isBlob } from './predicate/isBlob.mjs';
108
109
  export { isBoolean } from './predicate/isBoolean.mjs';
110
+ export { isBuffer } from './predicate/isBuffer.mjs';
109
111
  export { isDate } from './predicate/isDate.mjs';
110
112
  export { isEqual } from './predicate/isEqual.mjs';
111
113
  export { isEqualWith } from './predicate/isEqualWith.mjs';
@@ -1,114 +1,7 @@
1
- import { getSymbols } from '../compat/_internal/getSymbols.mjs';
2
- import { isPrimitive } from '../predicate/isPrimitive.mjs';
3
- import { isTypedArray } from '../predicate/isTypedArray.mjs';
1
+ import { cloneDeepWithImpl } from './cloneDeepWith.mjs';
4
2
 
5
3
  function cloneDeep(obj) {
6
- return cloneDeepImpl(obj);
7
- }
8
- function cloneDeepImpl(obj, stack = new Map()) {
9
- if (isPrimitive(obj)) {
10
- return obj;
11
- }
12
- if (stack.has(obj)) {
13
- return stack.get(obj);
14
- }
15
- if (Array.isArray(obj)) {
16
- const result = new Array(obj.length);
17
- stack.set(obj, result);
18
- for (let i = 0; i < obj.length; i++) {
19
- result[i] = cloneDeepImpl(obj[i], stack);
20
- }
21
- if (Object.hasOwn(obj, 'index')) {
22
- result.index = obj.index;
23
- }
24
- if (Object.hasOwn(obj, 'input')) {
25
- result.input = obj.input;
26
- }
27
- return result;
28
- }
29
- if (obj instanceof Date) {
30
- return new Date(obj.getTime());
31
- }
32
- if (obj instanceof RegExp) {
33
- const result = new RegExp(obj.source, obj.flags);
34
- result.lastIndex = obj.lastIndex;
35
- return result;
36
- }
37
- if (obj instanceof Map) {
38
- const result = new Map();
39
- stack.set(obj, result);
40
- for (const [key, value] of obj) {
41
- result.set(key, cloneDeepImpl(value, stack));
42
- }
43
- return result;
44
- }
45
- if (obj instanceof Set) {
46
- const result = new Set();
47
- stack.set(obj, result);
48
- for (const value of obj) {
49
- result.add(cloneDeepImpl(value, stack));
50
- }
51
- return result;
52
- }
53
- if (typeof Buffer !== 'undefined' && Buffer.isBuffer(obj)) {
54
- return obj.subarray();
55
- }
56
- if (isTypedArray(obj)) {
57
- const result = new (Object.getPrototypeOf(obj).constructor)(obj.length);
58
- stack.set(obj, result);
59
- for (let i = 0; i < obj.length; i++) {
60
- result[i] = cloneDeepImpl(obj[i], stack);
61
- }
62
- return result;
63
- }
64
- if (obj instanceof ArrayBuffer || (typeof SharedArrayBuffer !== 'undefined' && obj instanceof SharedArrayBuffer)) {
65
- return obj.slice(0);
66
- }
67
- if (obj instanceof DataView) {
68
- const result = new DataView(obj.buffer.slice(0), obj.byteOffset, obj.byteLength);
69
- stack.set(obj, result);
70
- copyProperties(result, obj, stack);
71
- return result;
72
- }
73
- if (typeof File !== 'undefined' && obj instanceof File) {
74
- const result = new File([obj], obj.name, { type: obj.type });
75
- stack.set(obj, result);
76
- copyProperties(result, obj, stack);
77
- return result;
78
- }
79
- if (obj instanceof Blob) {
80
- const result = new Blob([obj], { type: obj.type });
81
- stack.set(obj, result);
82
- copyProperties(result, obj, stack);
83
- return result;
84
- }
85
- if (obj instanceof Error) {
86
- const result = new obj.constructor();
87
- stack.set(obj, result);
88
- result.message = obj.message;
89
- result.name = obj.name;
90
- result.stack = obj.stack;
91
- result.cause = obj.cause;
92
- copyProperties(result, obj, stack);
93
- return result;
94
- }
95
- if (typeof obj === 'object' && obj !== null) {
96
- const result = Object.create(Object.getPrototypeOf(obj));
97
- stack.set(obj, result);
98
- copyProperties(result, obj, stack);
99
- return result;
100
- }
101
- return obj;
102
- }
103
- function copyProperties(target, source, stack) {
104
- const keys = [...Object.keys(source), ...getSymbols(source)];
105
- for (let i = 0; i < keys.length; i++) {
106
- const key = keys[i];
107
- const descriptor = Object.getOwnPropertyDescriptor(target, key);
108
- if (descriptor == null || descriptor.writable) {
109
- target[key] = cloneDeepImpl(source[key], stack);
110
- }
111
- }
4
+ return cloneDeepWithImpl(obj, undefined, obj, new Map(), undefined);
112
5
  }
113
6
 
114
- export { cloneDeep, copyProperties };
7
+ export { cloneDeep };
@@ -0,0 +1,38 @@
1
+ /**
2
+ * Creates a deep clone of the given object using a customizer function.
3
+ *
4
+ * @template T - The type of the object.
5
+ * @param {T} obj - The object to clone.
6
+ * @param {Function} [cloneValue] - A function to customize the cloning process.
7
+ * @returns {T} - A deep clone of the given object.
8
+ *
9
+ * @example
10
+ * // Clone a primitive value
11
+ * const num = 29;
12
+ * const clonedNum = cloneDeepWith(num);
13
+ * console.log(clonedNum); // 29
14
+ * console.log(clonedNum === num); // true
15
+ *
16
+ * @example
17
+ * // Clone an object with a customizer
18
+ * const obj = { a: 1, b: 2 };
19
+ * const clonedObj = cloneDeepWith(obj, (value) => {
20
+ * if (typeof value === 'number') {
21
+ * return value * 2; // Double the number
22
+ * }
23
+ * });
24
+ * console.log(clonedObj); // { a: 2, b: 4 }
25
+ * console.log(clonedObj === obj); // false
26
+ *
27
+ * @example
28
+ * // Clone an array with a customizer
29
+ * const arr = [1, 2, 3];
30
+ * const clonedArr = cloneDeepWith(arr, (value) => {
31
+ * return value + 1; // Increment each value
32
+ * });
33
+ * console.log(clonedArr); // [2, 3, 4]
34
+ * console.log(clonedArr === arr); // false
35
+ */
36
+ declare function cloneDeepWith<T>(obj: T, cloneValue: (value: any, key: PropertyKey | undefined, object: T | undefined, stack: Map<any, any>) => any): T;
37
+
38
+ export { cloneDeepWith };
@@ -0,0 +1,38 @@
1
+ /**
2
+ * Creates a deep clone of the given object using a customizer function.
3
+ *
4
+ * @template T - The type of the object.
5
+ * @param {T} obj - The object to clone.
6
+ * @param {Function} [cloneValue] - A function to customize the cloning process.
7
+ * @returns {T} - A deep clone of the given object.
8
+ *
9
+ * @example
10
+ * // Clone a primitive value
11
+ * const num = 29;
12
+ * const clonedNum = cloneDeepWith(num);
13
+ * console.log(clonedNum); // 29
14
+ * console.log(clonedNum === num); // true
15
+ *
16
+ * @example
17
+ * // Clone an object with a customizer
18
+ * const obj = { a: 1, b: 2 };
19
+ * const clonedObj = cloneDeepWith(obj, (value) => {
20
+ * if (typeof value === 'number') {
21
+ * return value * 2; // Double the number
22
+ * }
23
+ * });
24
+ * console.log(clonedObj); // { a: 2, b: 4 }
25
+ * console.log(clonedObj === obj); // false
26
+ *
27
+ * @example
28
+ * // Clone an array with a customizer
29
+ * const arr = [1, 2, 3];
30
+ * const clonedArr = cloneDeepWith(arr, (value) => {
31
+ * return value + 1; // Increment each value
32
+ * });
33
+ * console.log(clonedArr); // [2, 3, 4]
34
+ * console.log(clonedArr === arr); // false
35
+ */
36
+ declare function cloneDeepWith<T>(obj: T, cloneValue: (value: any, key: PropertyKey | undefined, object: T | undefined, stack: Map<any, any>) => any): T;
37
+
38
+ export { cloneDeepWith };
@@ -0,0 +1,121 @@
1
+ import { getSymbols } from '../compat/_internal/getSymbols.mjs';
2
+ import { isPrimitive } from '../predicate/isPrimitive.mjs';
3
+ import { isTypedArray } from '../predicate/isTypedArray.mjs';
4
+
5
+ function cloneDeepWith(obj, cloneValue) {
6
+ return cloneDeepWithImpl(obj, undefined, obj, new Map(), cloneValue);
7
+ }
8
+ function cloneDeepWithImpl(valueToClone, keyToClone, objectToClone, stack = new Map(), cloneValue = undefined) {
9
+ const cloned = cloneValue?.(valueToClone, keyToClone, objectToClone, stack);
10
+ if (cloned != null) {
11
+ return cloned;
12
+ }
13
+ if (isPrimitive(valueToClone)) {
14
+ return valueToClone;
15
+ }
16
+ if (stack.has(valueToClone)) {
17
+ return stack.get(valueToClone);
18
+ }
19
+ if (Array.isArray(valueToClone)) {
20
+ const result = new Array(valueToClone.length);
21
+ stack.set(valueToClone, result);
22
+ for (let i = 0; i < valueToClone.length; i++) {
23
+ result[i] = cloneDeepWithImpl(valueToClone[i], i, objectToClone, stack, cloneValue);
24
+ }
25
+ if (Object.hasOwn(valueToClone, 'index')) {
26
+ result.index = valueToClone.index;
27
+ }
28
+ if (Object.hasOwn(valueToClone, 'input')) {
29
+ result.input = valueToClone.input;
30
+ }
31
+ return result;
32
+ }
33
+ if (valueToClone instanceof Date) {
34
+ return new Date(valueToClone.getTime());
35
+ }
36
+ if (valueToClone instanceof RegExp) {
37
+ const result = new RegExp(valueToClone.source, valueToClone.flags);
38
+ result.lastIndex = valueToClone.lastIndex;
39
+ return result;
40
+ }
41
+ if (valueToClone instanceof Map) {
42
+ const result = new Map();
43
+ stack.set(valueToClone, result);
44
+ for (const [key, value] of valueToClone) {
45
+ result.set(key, cloneDeepWithImpl(value, key, objectToClone, stack, cloneValue));
46
+ }
47
+ return result;
48
+ }
49
+ if (valueToClone instanceof Set) {
50
+ const result = new Set();
51
+ stack.set(valueToClone, result);
52
+ for (const value of valueToClone) {
53
+ result.add(cloneDeepWithImpl(value, undefined, objectToClone, stack, cloneValue));
54
+ }
55
+ return result;
56
+ }
57
+ if (typeof Buffer !== 'undefined' && Buffer.isBuffer(valueToClone)) {
58
+ return valueToClone.subarray();
59
+ }
60
+ if (isTypedArray(valueToClone)) {
61
+ const result = new (Object.getPrototypeOf(valueToClone).constructor)(valueToClone.length);
62
+ stack.set(valueToClone, result);
63
+ for (let i = 0; i < valueToClone.length; i++) {
64
+ result[i] = cloneDeepWithImpl(valueToClone[i], i, objectToClone, stack, cloneValue);
65
+ }
66
+ return result;
67
+ }
68
+ if (valueToClone instanceof ArrayBuffer ||
69
+ (typeof SharedArrayBuffer !== 'undefined' && valueToClone instanceof SharedArrayBuffer)) {
70
+ return valueToClone.slice(0);
71
+ }
72
+ if (valueToClone instanceof DataView) {
73
+ const result = new DataView(valueToClone.buffer.slice(0), valueToClone.byteOffset, valueToClone.byteLength);
74
+ stack.set(valueToClone, result);
75
+ copyProperties(result, valueToClone, objectToClone, stack, cloneValue);
76
+ return result;
77
+ }
78
+ if (typeof File !== 'undefined' && valueToClone instanceof File) {
79
+ const result = new File([valueToClone], valueToClone.name, {
80
+ type: valueToClone.type,
81
+ });
82
+ stack.set(valueToClone, result);
83
+ copyProperties(result, valueToClone, objectToClone, stack, cloneValue);
84
+ return result;
85
+ }
86
+ if (valueToClone instanceof Blob) {
87
+ const result = new Blob([valueToClone], { type: valueToClone.type });
88
+ stack.set(valueToClone, result);
89
+ copyProperties(result, valueToClone, objectToClone, stack, cloneValue);
90
+ return result;
91
+ }
92
+ if (valueToClone instanceof Error) {
93
+ const result = new valueToClone.constructor();
94
+ stack.set(valueToClone, result);
95
+ result.message = valueToClone.message;
96
+ result.name = valueToClone.name;
97
+ result.stack = valueToClone.stack;
98
+ result.cause = valueToClone.cause;
99
+ copyProperties(result, valueToClone, objectToClone, stack, cloneValue);
100
+ return result;
101
+ }
102
+ if (typeof valueToClone === 'object' && valueToClone !== null) {
103
+ const result = Object.create(Object.getPrototypeOf(valueToClone));
104
+ stack.set(valueToClone, result);
105
+ copyProperties(result, valueToClone, objectToClone, stack, cloneValue);
106
+ return result;
107
+ }
108
+ return valueToClone;
109
+ }
110
+ function copyProperties(target, source, objectToClone = target, stack, cloneValue) {
111
+ const keys = [...Object.keys(source), ...getSymbols(source)];
112
+ for (let i = 0; i < keys.length; i++) {
113
+ const key = keys[i];
114
+ const descriptor = Object.getOwnPropertyDescriptor(target, key);
115
+ if (descriptor == null || descriptor.writable) {
116
+ target[key] = cloneDeepWithImpl(source[key], key, objectToClone, stack, cloneValue);
117
+ }
118
+ }
119
+ }
120
+
121
+ export { cloneDeepWith, cloneDeepWithImpl, copyProperties };
@@ -1,5 +1,6 @@
1
1
  export { clone } from './clone.mjs';
2
2
  export { cloneDeep } from './cloneDeep.mjs';
3
+ export { cloneDeepWith } from './cloneDeepWith.mjs';
3
4
  export { findKey } from './findKey.mjs';
4
5
  export { flattenObject } from './flattenObject.mjs';
5
6
  export { invert } from './invert.mjs';
@@ -1,5 +1,6 @@
1
1
  export { clone } from './clone.js';
2
2
  export { cloneDeep } from './cloneDeep.js';
3
+ export { cloneDeepWith } from './cloneDeepWith.js';
3
4
  export { findKey } from './findKey.js';
4
5
  export { flattenObject } from './flattenObject.js';
5
6
  export { invert } from './invert.js';
@@ -2,7 +2,7 @@
2
2
 
3
3
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
4
4
 
5
- const toMerged = require('../_chunk/toMerged-CPY8Ug.js');
5
+ const toMerged = require('../_chunk/toMerged-AV73JV.js');
6
6
 
7
7
  function mergeWith(target, source, merge) {
8
8
  const sourceKeys = Object.keys(source);
@@ -49,6 +49,7 @@ function pick(obj, keys) {
49
49
 
50
50
  exports.clone = toMerged.clone;
51
51
  exports.cloneDeep = toMerged.cloneDeep;
52
+ exports.cloneDeepWith = toMerged.cloneDeepWith;
52
53
  exports.findKey = toMerged.findKey;
53
54
  exports.flattenObject = toMerged.flattenObject;
54
55
  exports.invert = toMerged.invert;
@@ -1,5 +1,6 @@
1
1
  export { clone } from './clone.mjs';
2
2
  export { cloneDeep } from './cloneDeep.mjs';
3
+ export { cloneDeepWith } from './cloneDeepWith.mjs';
3
4
  export { findKey } from './findKey.mjs';
4
5
  export { flattenObject } from './flattenObject.mjs';
5
6
  export { invert } from './invert.mjs';
@@ -1,6 +1,7 @@
1
1
  export { isArrayBuffer } from './isArrayBuffer.mjs';
2
2
  export { isBlob } from './isBlob.mjs';
3
3
  export { isBoolean } from './isBoolean.mjs';
4
+ export { isBuffer } from './isBuffer.mjs';
4
5
  export { isDate } from './isDate.mjs';
5
6
  export { isEqual } from './isEqual.mjs';
6
7
  export { isEqualWith } from './isEqualWith.mjs';
@@ -1,6 +1,7 @@
1
1
  export { isArrayBuffer } from './isArrayBuffer.js';
2
2
  export { isBlob } from './isBlob.js';
3
3
  export { isBoolean } from './isBoolean.js';
4
+ export { isBuffer } from './isBuffer.js';
4
5
  export { isDate } from './isDate.js';
5
6
  export { isEqual } from './isEqual.js';
6
7
  export { isEqualWith } from './isEqualWith.js';
@@ -2,7 +2,7 @@
2
2
 
3
3
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
4
4
 
5
- const isWeakSet = require('../_chunk/isWeakSet-D8h8bS.js');
5
+ const isWeakSet = require('../_chunk/isWeakSet-CvIdTA.js');
6
6
  const isPlainObject = require('../_chunk/isPlainObject-octpoD.js');
7
7
 
8
8
  function isBoolean(x) {
@@ -23,6 +23,7 @@ function isSymbol(value) {
23
23
 
24
24
  exports.isArrayBuffer = isWeakSet.isArrayBuffer;
25
25
  exports.isBlob = isWeakSet.isBlob;
26
+ exports.isBuffer = isWeakSet.isBuffer;
26
27
  exports.isDate = isWeakSet.isDate;
27
28
  exports.isEqual = isWeakSet.isEqual;
28
29
  exports.isEqualWith = isWeakSet.isEqualWith;
@@ -1,6 +1,7 @@
1
1
  export { isArrayBuffer } from './isArrayBuffer.mjs';
2
2
  export { isBlob } from './isBlob.mjs';
3
3
  export { isBoolean } from './isBoolean.mjs';
4
+ export { isBuffer } from './isBuffer.mjs';
4
5
  export { isDate } from './isDate.mjs';
5
6
  export { isEqual } from './isEqual.mjs';
6
7
  export { isEqualWith } from './isEqualWith.mjs';
@@ -0,0 +1,21 @@
1
+ /**
2
+ * Checks if the given value is a Buffer instance.
3
+ *
4
+ * This function tests whether the provided value is an instance of Buffer.
5
+ * It returns `true` if the value is a Buffer, and `false` otherwise.
6
+ *
7
+ * This function can also serve as a type predicate in TypeScript, narrowing the type of the argument to `Buffer`.
8
+ *
9
+ * @param {unknown} x - The value to check if it is a Buffer.
10
+ * @returns {boolean} Returns `true` if `x` is a Buffer, else `false`.
11
+ *
12
+ * @example
13
+ * const buffer = Buffer.from("test");
14
+ * console.log(isBuffer(buffer)); // true
15
+ *
16
+ * const notBuffer = "not a buffer";
17
+ * console.log(isBuffer(notBuffer)); // false
18
+ */
19
+ declare function isBuffer(x: unknown): boolean;
20
+
21
+ export { isBuffer };
@@ -0,0 +1,21 @@
1
+ /**
2
+ * Checks if the given value is a Buffer instance.
3
+ *
4
+ * This function tests whether the provided value is an instance of Buffer.
5
+ * It returns `true` if the value is a Buffer, and `false` otherwise.
6
+ *
7
+ * This function can also serve as a type predicate in TypeScript, narrowing the type of the argument to `Buffer`.
8
+ *
9
+ * @param {unknown} x - The value to check if it is a Buffer.
10
+ * @returns {boolean} Returns `true` if `x` is a Buffer, else `false`.
11
+ *
12
+ * @example
13
+ * const buffer = Buffer.from("test");
14
+ * console.log(isBuffer(buffer)); // true
15
+ *
16
+ * const notBuffer = "not a buffer";
17
+ * console.log(isBuffer(notBuffer)); // false
18
+ */
19
+ declare function isBuffer(x: unknown): boolean;
20
+
21
+ export { isBuffer };
@@ -0,0 +1,5 @@
1
+ function isBuffer(x) {
2
+ return typeof Buffer !== 'undefined' && Buffer.isBuffer(x);
3
+ }
4
+
5
+ export { isBuffer };
@@ -2,7 +2,7 @@
2
2
 
3
3
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
4
4
 
5
- const upperFirst = require('../_chunk/upperFirst-DK_rTF.js');
5
+ const upperFirst = require('../_chunk/upperFirst-CorAVn.js');
6
6
 
7
7
  function startCase(str) {
8
8
  const words = upperFirst.words(str.trim());
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "es-toolkit",
3
3
  "description": "A state-of-the-art, high-performance JavaScript utility library with a small bundle size and strong type annotations.",
4
- "version": "1.27.0",
4
+ "version": "1.28.0-dev.910+66539368",
5
5
  "homepage": "https://es-toolkit.slash.page",
6
6
  "bugs": "https://github.com/toss/es-toolkit/issues",
7
7
  "repository": {