es-toolkit 1.28.0-dev.908 → 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.
@@ -150,6 +150,7 @@ export { sum } from './math/sum.mjs';
150
150
  export { sumBy } from './math/sumBy.mjs';
151
151
  export { assignIn, assignIn as extend } from './object/assignIn.mjs';
152
152
  export { cloneDeep } from './object/cloneDeep.mjs';
153
+ export { cloneDeepWith } from './object/cloneDeepWith.mjs';
153
154
  export { defaults } from './object/defaults.mjs';
154
155
  export { fromPairs } from './object/fromPairs.mjs';
155
156
  export { get } from './object/get.mjs';
@@ -150,6 +150,7 @@ export { sum } from './math/sum.js';
150
150
  export { sumBy } from './math/sumBy.js';
151
151
  export { assignIn, assignIn as extend } from './object/assignIn.js';
152
152
  export { cloneDeep } from './object/cloneDeep.js';
153
+ export { cloneDeepWith } from './object/cloneDeepWith.js';
153
154
  export { defaults } from './object/defaults.js';
154
155
  export { fromPairs } from './object/fromPairs.js';
155
156
  export { get } from './object/get.js';
@@ -8,7 +8,7 @@ const unary = require('../_chunk/unary-CcTNuC.js');
8
8
  const noop = require('../_chunk/noop-2IwLUk.js');
9
9
  const rangeRight = require('../_chunk/rangeRight-w3WrXN.js');
10
10
  const randomInt = require('../_chunk/randomInt-CF7bZK.js');
11
- const toMerged = require('../_chunk/toMerged-CPY8Ug.js');
11
+ const toMerged = require('../_chunk/toMerged-AV73JV.js');
12
12
  const isPlainObject$1 = require('../_chunk/isPlainObject-octpoD.js');
13
13
  const isWeakSet$1 = require('../_chunk/isWeakSet-CvIdTA.js');
14
14
  const upperFirst = require('../_chunk/upperFirst-CorAVn.js');
@@ -354,29 +354,39 @@ function matches(source) {
354
354
  };
355
355
  }
356
356
 
357
- function cloneDeep(obj) {
358
- if (typeof obj !== 'object') {
359
- return toMerged.cloneDeep(obj);
360
- }
361
- switch (Object.prototype.toString.call(obj)) {
362
- case isWeakSet$1.numberTag:
363
- case isWeakSet$1.stringTag:
364
- case isWeakSet$1.booleanTag: {
365
- const result = new obj.constructor(obj?.valueOf());
366
- toMerged.copyProperties(result, obj);
367
- return result;
357
+ function cloneDeepWith(obj, cloneValue) {
358
+ return toMerged.cloneDeepWith(obj, (value, key, object, stack) => {
359
+ const cloned = cloneValue?.(value, key, object, stack);
360
+ if (cloned != null) {
361
+ return cloned;
368
362
  }
369
- case isWeakSet$1.argumentsTag: {
370
- const result = {};
371
- toMerged.copyProperties(result, obj);
372
- result.length = obj.length;
373
- result[Symbol.iterator] = obj[Symbol.iterator];
374
- return result;
363
+ if (typeof obj !== 'object') {
364
+ return undefined;
375
365
  }
376
- default: {
377
- return toMerged.cloneDeep(obj);
366
+ switch (Object.prototype.toString.call(obj)) {
367
+ case isWeakSet$1.numberTag:
368
+ case isWeakSet$1.stringTag:
369
+ case isWeakSet$1.booleanTag: {
370
+ const result = new obj.constructor(obj?.valueOf());
371
+ toMerged.copyProperties(result, obj);
372
+ return result;
373
+ }
374
+ case isWeakSet$1.argumentsTag: {
375
+ const result = {};
376
+ toMerged.copyProperties(result, obj);
377
+ result.length = obj.length;
378
+ result[Symbol.iterator] = obj[Symbol.iterator];
379
+ return result;
380
+ }
381
+ default: {
382
+ return undefined;
383
+ }
378
384
  }
379
- }
385
+ });
386
+ }
387
+
388
+ function cloneDeep(obj) {
389
+ return cloneDeepWith(obj);
380
390
  }
381
391
 
382
392
  const IS_UNSIGNED_INTEGER = /^(?:0|[1-9]\d*)$/;
@@ -2778,6 +2788,7 @@ exports.ceil = ceil;
2778
2788
  exports.chunk = chunk;
2779
2789
  exports.clamp = clamp;
2780
2790
  exports.cloneDeep = cloneDeep;
2791
+ exports.cloneDeepWith = cloneDeepWith;
2781
2792
  exports.compact = compact;
2782
2793
  exports.concat = concat;
2783
2794
  exports.conforms = conforms;
@@ -151,6 +151,7 @@ export { sum } from './math/sum.mjs';
151
151
  export { sumBy } from './math/sumBy.mjs';
152
152
  export { assignIn, assignIn as extend } from './object/assignIn.mjs';
153
153
  export { cloneDeep } from './object/cloneDeep.mjs';
154
+ export { cloneDeepWith } from './object/cloneDeepWith.mjs';
154
155
  export { defaults } from './object/defaults.mjs';
155
156
  export { fromPairs } from './object/fromPairs.mjs';
156
157
  export { get } from './object/get.mjs';
@@ -1,29 +1,7 @@
1
- import { cloneDeep as cloneDeep$1, copyProperties } from '../../object/cloneDeep.mjs';
2
- import { argumentsTag, booleanTag, stringTag, numberTag } from '../_internal/tags.mjs';
1
+ import { cloneDeepWith } from './cloneDeepWith.mjs';
3
2
 
4
3
  function cloneDeep(obj) {
5
- if (typeof obj !== 'object') {
6
- return cloneDeep$1(obj);
7
- }
8
- switch (Object.prototype.toString.call(obj)) {
9
- case numberTag:
10
- case stringTag:
11
- case booleanTag: {
12
- const result = new obj.constructor(obj?.valueOf());
13
- copyProperties(result, obj);
14
- return result;
15
- }
16
- case argumentsTag: {
17
- const result = {};
18
- copyProperties(result, obj);
19
- result.length = obj.length;
20
- result[Symbol.iterator] = obj[Symbol.iterator];
21
- return result;
22
- }
23
- default: {
24
- return cloneDeep$1(obj);
25
- }
26
- }
4
+ return cloneDeepWith(obj);
27
5
  }
28
6
 
29
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,35 @@
1
+ import { cloneDeepWith as cloneDeepWith$1, copyProperties } from '../../object/cloneDeepWith.mjs';
2
+ import { argumentsTag, booleanTag, stringTag, numberTag } from '../_internal/tags.mjs';
3
+
4
+ function cloneDeepWith(obj, cloneValue) {
5
+ return cloneDeepWith$1(obj, (value, key, object, stack) => {
6
+ const cloned = cloneValue?.(value, key, object, stack);
7
+ if (cloned != null) {
8
+ return cloned;
9
+ }
10
+ if (typeof obj !== 'object') {
11
+ return undefined;
12
+ }
13
+ switch (Object.prototype.toString.call(obj)) {
14
+ case numberTag:
15
+ case stringTag:
16
+ case booleanTag: {
17
+ const result = new obj.constructor(obj?.valueOf());
18
+ copyProperties(result, obj);
19
+ return result;
20
+ }
21
+ case argumentsTag: {
22
+ const result = {};
23
+ copyProperties(result, obj);
24
+ result.length = obj.length;
25
+ result[Symbol.iterator] = obj[Symbol.iterator];
26
+ return result;
27
+ }
28
+ default: {
29
+ return undefined;
30
+ }
31
+ }
32
+ });
33
+ }
34
+
35
+ export { cloneDeepWith };
package/dist/index.d.mts 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';
package/dist/index.d.ts CHANGED
@@ -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';
package/dist/index.js CHANGED
@@ -11,7 +11,7 @@ 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
16
  const isWeakSet = require('./_chunk/isWeakSet-CvIdTA.js');
17
17
  const predicate_index = require('./predicate/index.js');
@@ -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;
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';
@@ -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';
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.28.0-dev.908+e1c05f28",
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": {