UNPKG

756 BTypeScriptView Raw
1declare namespace stableStringify {
2 type Key = string | number;
3
4 type NonArrayNode = Record<Key, unknown>;
5 type Node = unknown[] | NonArrayNode;
6
7 type Getter = { get(key: Key): unknown };
8
9 type Comparator = (a: { key: string, value: unknown }, b: { key: string, value: unknown }, getter: Getter) => number;
10
11 type StableStringifyOptions = {
12 cmp?: Comparator;
13 cycles?: boolean;
14 replacer?: (this: Node, key: Key, value: unknown) => unknown;
15 space?: string | number;
16 };
17}
18
19declare function stableStringify(
20 obj: object,
21 options?: (stableStringify.Comparator & stableStringify.StableStringifyOptions) | stableStringify.StableStringifyOptions,
22): string | undefined;
23
24export = stableStringify;