-
-
Notifications
You must be signed in to change notification settings - Fork 53
/
index.d.ts
41 lines (32 loc) · 910 Bytes
/
index.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
export type Options = {
/**
Strip trailing commas in addition to comments.
@default false
*/
readonly trailingCommas?: boolean;
/**
Replace comments and trailing commas with whitespace instead of stripping them entirely.
@default true
*/
readonly whitespace?: boolean;
};
/**
Strip comments from JSON. Lets you use comments in your JSON files!
It will replace single-line comments `//` and multi-line comments `/**\/` with whitespace. This allows JSON error positions to remain as close as possible to the original source.
@param jsonString - Accepts a string with JSON.
@returns A JSON string without comments.
@example
```
import stripJsonComments from 'strip-json-comments';
const json = `{
// Rainbows
"unicorn": "cake"
}`;
JSON.parse(stripJsonComments(json));
//=> {unicorn: 'cake'}
```
*/
export default function stripJsonComments(
jsonString: string,
options?: Options
): string;