Opal-Estate-Pro/node_modules/safe-json-parse/index.js
2019-09-13 11:27:52 +07:00

19 lines
311 B
JavaScript

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)
}