rezult
v1.1.0
Published
A value or error object
Downloads
56
Readme
A JavaScript value or error object.
var Result = require("rezult");
function safeJsonParse(string) {
try {
return new Result(null, JSON.parse(string));
} catch (err) {
return new Result(err);
}
};
safeJsonParse("{}").toCallback(cb); // cb(null, {})
safeJsonParse("wat").toValue(); // throw SyntaxError
MIT License