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