UNPKG

2.81 kBMarkdownView Raw
1# Installation
2> `npm install --save @types/clone`
3
4# Summary
5This package contains type definitions for clone (https://github.com/pvorb/node-clone).
6
7# Details
8Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/clone.
9## [index.d.ts](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/clone/index.d.ts)
10````ts
11// Type definitions for clone 2.1
12// Project: https://github.com/pvorb/node-clone
13// Definitions by: Kieran Simpson <https://github.com/kierans>
14// DG-za <https://github.com/DG-za>
15// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
16
17/**
18 * See clone JS source for API docs
19 */
20
21/**
22 * @param val the value that you want to clone, any type allowed
23 * @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.
24 * @param depth to which the object is to be cloned (optional, defaults to infinity)
25 * @param prototype Sets the prototype to be used when cloning an Object (optional, defaults to __proto__)
26 * @param 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, circular?: boolean, depth?: number, prototype?: any, includeNonEnumerable?: boolean): T;
29
30/**
31 * @param val the value that you want to clone, any type allowed
32 * @param opts a single object that specifies circular, depth, prototype and includeNonEnumerable.
33 * @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.
34 * @param opts.depth Sets depth to which the object is to be cloned (optional, defaults to infinity)
35 * @param opts.prototype Sets the prototype to be used when cloning an Object (optional, defaults to __proto__)
36 * @param opts.includeNonEnumerable Set to true if the non-enumerable properties should be cloned as well (optional, defaults to false)
37 */
38declare function clone<T>(val: T, opts: CloneOpts): T;
39
40interface CloneOpts {
41 circular?: boolean | undefined,
42 depth?: number | undefined,
43 prototype?: any,
44 includeNonEnumerable?: boolean | undefined
45}
46
47declare namespace clone {
48 /**
49 * @param obj the object that you want to clone
50 */
51 function clonePrototype<T>(obj: T): T;
52}
53
54export = clone
55
56````
57
58### Additional Details
59 * Last updated: Tue, 06 Jul 2021 18:05:53 GMT
60 * Dependencies: none
61 * Global values: none
62
63# Credits
64These definitions were written by [Kieran Simpson](https://github.com/kierans), and [DG-za](https://github.com/DG-za).
65
\No newline at end of file