Created
November 30, 2016 23:05
-
-
Save etoxin/656d65308621eee8ae7afb1cb4831d5a to your computer and use it in GitHub Desktop.
JSON Parse
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /** | |
| * Lodash JSON Parse with error handling. | |
| * The _.attempt prevents JSON.parse from throwing an application error. Instead, it return an Error object. | |
| * @requires _ | |
| * @param str | |
| * @returns {*} | |
| */ | |
| function lodashJSONParse (str) { | |
| return _.attempt(JSON.parse.bind(null, str)); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment