1 |
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
8 | declare namespace objectHash {
|
9 | |
10 |
|
11 |
|
12 | function sha1(object: {} | null): string;
|
13 | |
14 |
|
15 |
|
16 | function keys(object: {} | null): string;
|
17 | |
18 |
|
19 |
|
20 | function MD5(object: {} | null): string;
|
21 | |
22 |
|
23 |
|
24 | function keysMD5(object: {} | null): string;
|
25 | |
26 |
|
27 |
|
28 | function writeToStream(value: any, stream: Stream): void;
|
29 | function writeToStream(value: any, options: Options, stream: Stream): void;
|
30 |
|
31 | type BufferEncoding =
|
32 | | 'ascii'
|
33 | | 'base64'
|
34 | | 'binary'
|
35 | | 'hex'
|
36 | | 'latin1'
|
37 | | 'ucs-2'
|
38 | | 'ucs2'
|
39 | | 'utf-8'
|
40 | | 'utf16le'
|
41 | | 'utf8';
|
42 |
|
43 | interface Stream {
|
44 | update?(chunk: any, encoding: BufferEncoding, callback: (error?: Error | null) => void): void;
|
45 | write?(chunk: any, encoding: BufferEncoding, callback: (error?: Error | null) => void): void;
|
46 | }
|
47 |
|
48 | interface BaseOptions {
|
49 | /**
|
50 | * @default 'sha1'
|
51 | */
|
52 | algorithm?: 'sha1' | 'md5' | 'passthrough' | undefined;
|
53 |
|
54 | excludeKeys?: ((key: string) => boolean) | undefined;
|
55 | /**
|
56 | * @default false
|
57 | */
|
58 | excludeValues?: boolean | undefined;
|
59 | /**
|
60 | * @default false
|
61 | */
|
62 | ignoreUnknown?: boolean | undefined;
|
63 |
|
64 | replacer?: ((value: any) => any) | undefined;
|
65 | /**
|
66 | * @default true
|
67 | */
|
68 | respectFunctionNames?: boolean | undefined;
|
69 | /**
|
70 | * @default true
|
71 | */
|
72 | respectFunctionProperties?: boolean | undefined;
|
73 | /**
|
74 | * @default true
|
75 | */
|
76 | respectType?: boolean | undefined;
|
77 | /**
|
78 | * @default false
|
79 | */
|
80 | unorderedArrays?: boolean | undefined;
|
81 | /**
|
82 | * @default true
|
83 | */
|
84 | unorderedObjects?: boolean | undefined;
|
85 | /**
|
86 | * @default true
|
87 | */
|
88 | unorderedSets?: boolean | undefined;
|
89 | }
|
90 |
|
91 | interface NormalOption extends BaseOptions {
|
92 | /**
|
93 | * @default 'hex'
|
94 | */
|
95 | encoding?: 'hex' | 'binary' | 'base64' | undefined;
|
96 | }
|
97 |
|
98 | interface WithBufferOption extends BaseOptions {
|
99 | encoding: 'buffer';
|
100 | }
|
101 |
|
102 | type Options = NormalOption | WithBufferOption;
|
103 | }
|
104 |
|
105 | /**
|
106 | * @see https://github.com/puleos/object-hash#hashvalue-options
|
107 | */
|
108 | declare function objectHash(object: {} | null, options?: objectHash.NormalOption): string;
|
109 | declare function objectHash(object: {} | null, options?: objectHash.WithBufferOption): Buffer;
|
110 |
|
111 | export = objectHash;
|
112 |
|
\ | No newline at end of file |