From 7d9db70be36df90f131e27446d0d418f16e79b24 Mon Sep 17 00:00:00 2001 From: Efremov Alexey Date: Mon, 13 Sep 2021 10:20:07 +0300 Subject: [PATCH] Add: typings --- index.d.ts | 26 ++++++++++++++++++++++++++ package.json | 1 + 2 files changed, 27 insertions(+) create mode 100644 index.d.ts diff --git a/index.d.ts b/index.d.ts new file mode 100644 index 0000000..a1c8dc8 --- /dev/null +++ b/index.d.ts @@ -0,0 +1,26 @@ +declare module '@discoveryjs/json-ext' { + import { Readable } from 'stream'; + + type TReplacer = null | string[] | number[] | ((this: any, key: string, value: any) => any); + type TSpace = string | number | null; + + + export function parseChunked(input: Readable | Generator | AsyncGenerator | (() => (Iterable | AsyncIterable))): Promise; + + export function stringifyStream(value: any, replacer?: TReplacer, space?: TSpace): Readable; + + export function stringifyInfo( + value: any, + replacer?: TReplacer, + space?: TSpace, + options?: { + async?: boolean; + continueOnCircular?: boolean; + } + ): { + minLength: number; + circular: any[]; + duplicate: any[]; + async: any[]; + }; + } diff --git a/package.json b/package.json index a0be8c3..890da27 100644 --- a/package.json +++ b/package.json @@ -19,6 +19,7 @@ "./src/stringify-stream.js": "./src/stringify-stream-browser.js", "./src/text-decoder.js": "./src/text-decoder-browser.js" }, + "types": "./index.d.ts", "scripts": { "test": "mocha --reporter progress", "lint": "eslint src test",