diff --git a/.gitignore b/.gitignore index 4bd2f9d..47a9477 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,5 @@ +/package-lock.json + # Logs logs *.log diff --git a/index.d.ts b/index.d.ts new file mode 100644 index 0000000..3005163 --- /dev/null +++ b/index.d.ts @@ -0,0 +1,44 @@ +declare namespace JsonSourceMap { + export interface ParseOptions { + bigint?: boolean; + } + + export type PointerProp = "value" | "valueEnd" | "key" | "keyEnd"; + + export interface Location { + line: number; + column: number; + pos: number; + } + + export type Pointers = Record>; + + export interface ParseResult { + data: any; + pointers: Pointers; + } + + export function parse( + source: string, + _reviver?: any, + options?: ParseOptions + ): ParseResult; + + export interface StringifyOptions { + space?: string | number; + es6?: boolean; + } + + export interface StringifyResult { + json: string; + pointers: Pointers; + } + + export function stringify( + data: any, + _replacer?: any, + options?: string | number | StringifyOptions + ): StringifyResult; +} + +export = JsonSourceMap; diff --git a/package.json b/package.json index 8ba2a8e..a5234dd 100644 --- a/package.json +++ b/package.json @@ -3,6 +3,7 @@ "version": "0.6.1", "description": "Parse/stringify JSON and provide source-map for JSON-pointers to all nodes", "main": "index.js", + "types": "index.d.ts", "scripts": { "eslint": "eslint index.js spec", "test-spec": "mocha spec -R spec",