Created
September 25, 2015 15:35
-
-
Save Suor/4acccceb57e38bdb6589 to your computer and use it in GitHub Desktop.
Deep floats 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
function parseStrings(obj) { | |
if (_.isString(obj)) { | |
var f = parseFloat(obj); | |
return Number.isName(f) ? obj : f; | |
} else if (_.isArray(obj)) { | |
obj.forEach(function (v, i) { | |
obj[i] = parseStrings(v); | |
}) | |
} else if (_.isObject(obj)) { | |
_.forOwn(obj, function (v, k) { | |
obj[k] = parseStrings(v) | |
}) | |
} | |
return obj; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment