Opal-Estate-Pro/node_modules/safe-json-parse/index.js

19 lines
311 B
JavaScript
Raw Normal View History

2019-09-13 06:27:52 +02:00
module.exports = SafeParse
function SafeParse(obj, reviver, callback) {
if (arguments.length === 2) {
callback = reviver
reviver = null
}
var json
try {
json = JSON.parse(obj, reviver)
} catch (err) {
return callback(err)
}
callback(null, json)
}