-
Notifications
You must be signed in to change notification settings - Fork 31
/
index.d.ts
55 lines (48 loc) · 1.51 KB
/
index.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
interface Cache {
_keys?: any[];
_values?: any[];
has: (value: any) => boolean;
set: (key: any, value: any) => void;
get: (key: any) => any;
}
export interface CreateCopierOptions {
array?: InternalCopier<any[]>;
arrayBuffer?: InternalCopier<ArrayBuffer>;
blob?: InternalCopier<Blob>;
dataView?: InternalCopier<DataView>;
date?: InternalCopier<Date>;
map?: InternalCopier<Map<any, any>>;
object?: InternalCopier<Record<string, any>>;
regExp?: InternalCopier<RegExp>;
set?: InternalCopier<Set<any>>;
}
type InternalCopier<Value> = (value: Value, state: State) => Value;
export interface State {
Constructor: any;
cache: Cache;
copier: InternalCopier<any>;
prototype: any;
}
/**
* Copy an value deeply as much as possible.
*/
export default function copy<Value>(value: Value): Value;
/**
* Copy an value deeply as much as possible, where strict recreation of object properties
* are maintained. All properties (including non-enumerable ones) are copied with their
* original property descriptors on both objects and arrays.
*/
export function copyStrict<Value>(value: Value): Value;
/**
* Create a custom copier based on the object-specific copy methods passed.
*/
export function createCopier(
options: CreateCopierOptions
): <Value>(value: Value) => Value;
/**
* Create a custom copier based on the object-specific copy methods passed, defaulting to the
* same internals as `copyStrict`.
*/
export function createStrictCopier(
options: CreateCopierOptions
): <Value>(value: Value) => Value;