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 | type HashName =
|
52 | | "md4"
|
53 | | "md4WithRSAEncryption"
|
54 | | "md5"
|
55 | | "md5WithRSAEncryption"
|
56 | | "ripemd"
|
57 | | "ripemd160"
|
58 | | "ripemd160WithRSA"
|
59 | | "rmd160"
|
60 | | "rsa-md4"
|
61 | | "rsa-md5"
|
62 | | "rsa-ripemd160"
|
63 | | "rsa-sha1"
|
64 | | "rsa-sha1-2"
|
65 | | "rsa-sha224"
|
66 | | "rsa-sha256"
|
67 | | "rsa-sha3-224"
|
68 | | "rsa-sha3-256"
|
69 | | "rsa-sha3-384"
|
70 | | "rsa-sha3-512"
|
71 | | "rsa-sha384"
|
72 | | "rsa-sha512"
|
73 | | "sha1"
|
74 | | "sha1WithRSAEncryption"
|
75 | | "sha224"
|
76 | | "sha224WithRSAEncryption"
|
77 | | "sha256"
|
78 | | "sha256WithRSAEncryption"
|
79 | | "sha3-224"
|
80 | | "sha3-256"
|
81 | | "sha3-384"
|
82 | | "sha3-512"
|
83 | | "sha384"
|
84 | | "sha384WithRSAEncryption"
|
85 | | "sha512"
|
86 | | "sha512WithRSAEncryption";
|
87 |
|
88 | interface BaseOptions {
|
89 | /**
|
90 | * @default 'sha1'
|
91 | */
|
92 | algorithm?: HashName | "passthrough" | undefined;
|
93 |
|
94 | excludeKeys?: ((key: string) => boolean) | undefined;
|
95 | /**
|
96 | * @default false
|
97 | */
|
98 | excludeValues?: boolean | undefined;
|
99 | /**
|
100 | * @default false
|
101 | */
|
102 | ignoreUnknown?: boolean | undefined;
|
103 |
|
104 | replacer?: ((value: any) => any) | undefined;
|
105 | /**
|
106 | * @default true
|
107 | */
|
108 | respectFunctionNames?: boolean | undefined;
|
109 | /**
|
110 | * @default true
|
111 | */
|
112 | respectFunctionProperties?: boolean | undefined;
|
113 | /**
|
114 | * @default true
|
115 | */
|
116 | respectType?: boolean | undefined;
|
117 | /**
|
118 | * @default false
|
119 | */
|
120 | unorderedArrays?: boolean | undefined;
|
121 | /**
|
122 | * @default true
|
123 | */
|
124 | unorderedObjects?: boolean | undefined;
|
125 | /**
|
126 | * @default true
|
127 | */
|
128 | unorderedSets?: boolean | undefined;
|
129 | }
|
130 |
|
131 | interface NormalOption extends BaseOptions {
|
132 | /**
|
133 | * @default 'hex'
|
134 | */
|
135 | encoding?: "hex" | "binary" | "base64" | undefined;
|
136 | }
|
137 |
|
138 | interface WithBufferOption extends BaseOptions {
|
139 | encoding: "buffer";
|
140 | }
|
141 |
|
142 | type Options = NormalOption | WithBufferOption;
|
143 | }
|
144 |
|
145 | /**
|
146 | * @see https://github.com/puleos/object-hash#hashvalue-options
|
147 | */
|
148 | declare function objectHash(object: objectHash.NotUndefined, options?: objectHash.NormalOption): string;
|
149 | declare function objectHash(object: objectHash.NotUndefined, options?: objectHash.WithBufferOption): Buffer;
|
150 |
|
151 | export = objectHash;
|
152 |
|
\ | No newline at end of file |