Skip to content

add TypeScript definitions #7

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
/package-lock.json

# Logs
logs
*.log
Expand Down
44 changes: 44 additions & 0 deletions index.d.ts
Original file line number Diff line number Diff line change
@@ -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<string, Record<PointerProp, Location>>;

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;
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down