1 | /**
|
2 | * Deterministic version of JSON.stringify() so you can get a consistent hash from stringified results.
|
3 | *
|
4 | * @returns Deterministic json result.
|
5 | */
|
6 | declare function stringify(obj: any, opts?: stringify.Comparator | stringify.Options): string;
|
7 |
|
8 | declare namespace stringify {
|
9 | interface Element {
|
10 | key: string;
|
11 | value: any;
|
12 | }
|
13 |
|
14 | type Comparator = (a: Element, b: Element, opts?: { get(k: string): any }) => number;
|
15 |
|
16 | type Replacer = (key: string, value: any) => any;
|
17 |
|
18 | interface Options {
|
19 | /**
|
20 | * Custom comparator for key
|
21 | */
|
22 | cmp?: Comparator;
|
23 |
|
24 | /**
|
25 | * Indent the output for pretty-printing.
|
26 | *
|
27 | * Supported is either a string or a number of spaces.
|
28 | */
|
29 | space?: string | number;
|
30 |
|
31 | /**
|
32 | * Option to replace values to simpler values
|
33 | */
|
34 | replacer?: Replacer;
|
35 |
|
36 | /**
|
37 | * true to allow cycles, by marking the entries as __cycle__.
|
38 | */
|
39 | cycles?: boolean;
|
40 | }
|
41 | }
|
42 |
|
43 | export = stringify;
|