source: node_modules/es-toolkit/dist/compat/object/cloneDeep.d.mts

Last change on this file was a762898, checked in by istevanoska <ilinastevanoska@…>, 5 months ago

Added visualizations

  • Property mode set to 100644
File size: 1.4 KB
Line 
1/**
2 * Creates a deep clone of the given object.
3 *
4 * @template T - The type of the object.
5 * @param {T} obj - The object to clone.
6 * @returns {T} - A deep clone of the given object.
7 *
8 * @example
9 * // Clone a primitive values
10 * const num = 29;
11 * const clonedNum = clone(num);
12 * console.log(clonedNum); // 29
13 * console.log(clonedNum === num); // true
14 *
15 * @example
16 * // Clone an array
17 * const arr = [1, 2, 3];
18 * const clonedArr = clone(arr);
19 * console.log(clonedArr); // [1, 2, 3]
20 * console.log(clonedArr === arr); // false
21 *
22 * @example
23 * // Clone an array with nested objects
24 * const arr = [1, { a: 1 }, [1, 2, 3]];
25 * const clonedArr = clone(arr);
26 * arr[1].a = 2;
27 * console.log(arr); // [2, { a: 2 }, [1, 2, 3]]
28 * console.log(clonedArr); // [1, { a: 1 }, [1, 2, 3]]
29 * console.log(clonedArr === arr); // false
30 *
31 * @example
32 * // Clone an object
33 * const obj = { a: 1, b: 'es-toolkit', c: [1, 2, 3] };
34 * const clonedObj = clone(obj);
35 * console.log(clonedObj); // { a: 1, b: 'es-toolkit', c: [1, 2, 3] }
36 * console.log(clonedObj === obj); // false
37 *
38 * @example
39 * // Clone an object with nested objects
40 * const obj = { a: 1, b: { c: 1 } };
41 * const clonedObj = clone(obj);
42 * obj.b.c = 2;
43 * console.log(obj); // { a: 1, b: { c: 2 } }
44 * console.log(clonedObj); // { a: 1, b: { c: 1 } }
45 * console.log(clonedObj === obj); // false
46 */
47declare function cloneDeep<T>(obj: T): T;
48
49export { cloneDeep };
Note: See TracBrowser for help on using the repository browser.