Skip to content
Merged
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: 1 addition & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ function safeParse (text, reviver) {
try {
return _parse(text, reviver, { safe: true })
} catch (_e) {
return null
return undefined
} finally {
Error.stackTraceLimit = stackTraceLimit
}
Expand Down
4 changes: 2 additions & 2 deletions test/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -432,10 +432,10 @@ test('safeParse', t => {
t.end()
})

t.test('returns null on invalid object string', t => {
t.test('returns undefined on invalid object string', t => {
t.strictEqual(
j.safeParse('{"a": 5, "b": 6'),
null
undefined
)
t.end()
})
Expand Down
2 changes: 1 addition & 1 deletion types/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ declare namespace parse {
*
* @param text The JSON text string.
* @param reviver The `JSON.parse()` optional `reviver` argument.
* @returns The parsed object, or `null` if there was an error or if the JSON contained possibly insecure properties.
* @returns The parsed object, or `undefined` if there was an error or if the JSON contained possibly insecure properties.
*/
export function safeParse (text: string | Buffer, reviver?: Reviver | null): any

Expand Down