UNPKG

1.93 kBTypeScriptView Raw
1/**
2 * See clone JS source for API docs
3 */
4
5/**
6 * @param val the value that you want to clone, any type allowed
7 * @param circular Call clone with circular set to false if you are certain that obj contains no circular references. This will give better performance if needed. There is no error if undefined or null is passed as obj.
8 * @param depth to which the object is to be cloned (optional, defaults to infinity)
9 * @param prototype Sets the prototype to be used when cloning an Object (optional, defaults to __proto__)
10 * @param includeNonEnumerable Set to true if the non-enumerable properties should be cloned as well (optional, defaults to false)
11 */
12declare function clone<T>(
13 val: T,
14 circular?: boolean,
15 depth?: number,
16 prototype?: any,
17 includeNonEnumerable?: boolean,
18): T;
19
20/**
21 * @param val the value that you want to clone, any type allowed
22 * @param opts a single object that specifies circular, depth, prototype and includeNonEnumerable.
23 * @param opts.circular Call clone with circular set to false if you are certain that obj contains no circular references. This will give better performance if needed. There is no error if undefined or null is passed as obj.
24 * @param opts.depth Sets depth to which the object is to be cloned (optional, defaults to infinity)
25 * @param opts.prototype Sets the prototype to be used when cloning an Object (optional, defaults to __proto__)
26 * @param opts.includeNonEnumerable Set to true if the non-enumerable properties should be cloned as well (optional, defaults to false)
27 */
28declare function clone<T>(val: T, opts: CloneOpts): T;
29
30interface CloneOpts {
31 circular?: boolean | undefined;
32 depth?: number | undefined;
33 prototype?: any;
34 includeNonEnumerable?: boolean | undefined;
35}
36
37declare namespace clone {
38 /**
39 * @param obj the object that you want to clone
40 */
41 function clonePrototype<T>(obj: T): T;
42}
43
44export = clone;