source: node_modules/es-toolkit/dist/object/clone.d.ts@ a762898

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

Added visualizations

  • Property mode set to 100644
File size: 846 bytes
Line 
1/**
2 * Creates a shallow 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 shallow 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 object
24 * const obj = { a: 1, b: 'es-toolkit', c: [1, 2, 3] };
25 * const clonedObj = clone(obj);
26 * console.log(clonedObj); // { a: 1, b: 'es-toolkit', c: [1, 2, 3] }
27 * console.log(clonedObj === obj); // false
28 */
29declare function clone<T>(obj: T): T;
30
31export { clone };
Note: See TracBrowser for help on using the repository browser.