From d748301c79d0bfb8c2b63d442bf0eca1fad64681 Mon Sep 17 00:00:00 2001 From: Leon Song Date: Sun, 3 Jan 2021 10:12:35 +0800 Subject: [PATCH] Improve comparator function typing --- index.d.ts | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/index.d.ts b/index.d.ts index 23e46ca..953b398 100644 --- a/index.d.ts +++ b/index.d.ts @@ -1,4 +1,20 @@ -declare module 'fast-json-stable-stringify' { - function stringify(obj: any): string; +declare module "fast-json-stable-stringify" { + interface KeyValue { + key: string; + value: any; + } + + type ComparatorFunction = (a: KeyValue, b: KeyValue) => number; + + function stringify( + obj: any, + opts?: + | { + cmp?: ComparatorFunction; + cycles?: boolean; + } + | ComparatorFunction + ): string; + export = stringify; }