Skip to content

Instantly share code, notes, and snippets.

@Suor
Created September 25, 2015 15:35
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Suor/4acccceb57e38bdb6589 to your computer and use it in GitHub Desktop.
Save Suor/4acccceb57e38bdb6589 to your computer and use it in GitHub Desktop.
Deep floats parse
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