Skip to content

Commit 97e3fd1

Browse files
authored
feat: add an overload function to parse (#95)
1 parent deeeeb3 commit 97e3fd1

File tree

2 files changed

+5
-0
lines changed

2 files changed

+5
-0
lines changed

types/index.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,5 +53,6 @@ declare namespace parse {
5353
export { parse as default}
5454
}
5555

56+
declare function parse(text: string | Buffer, options?: parse.ParseOptions): any
5657
declare function parse(text: string | Buffer, reviver?: parse.Reviver | null, options?: parse.ParseOptions): any
5758
export = parse

types/index.test-d.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@ sjson.parse('"test"', null, { protoAction: 'remove' })
88
expectError(sjson.parse('"test"', null, { protoAction: 'incorrect' }))
99
sjson.parse('"test"', null, { constructorAction: 'ignore' })
1010
expectError(sjson.parse('"test"', null, { constructorAction: 'incorrect' }))
11+
expectError(sjson.parse('"test"', { constructorAction: 'incorrect' }))
12+
sjson.parse('test', { constructorAction: 'remove' })
13+
sjson.parse('test', { protoAction: 'ignore' })
14+
sjson.parse('test', () => {}, { protoAction: 'ignore', constructorAction: 'remove' })
1115

1216
sjson.safeParse('"test"', null)
1317
sjson.safeParse('"test"')

0 commit comments

Comments
 (0)