Last active
July 11, 2016 20:55
-
-
Save michaelrhodes/9099f86d7899f628b05176e2942d0f74 to your computer and use it in GitHub Desktop.
use https://github.com/tjmehta/object-loops instead
This file contains 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 each (o, fn) { | |
Array.isArray(o) ? o.forEach(fn) : | |
Object.keys(o).forEach(function (key, i) { | |
fn.call(this, o[key], key, o) | |
}) | |
} |
This file contains 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 map (o, fn) { | |
if (Array.isArray(o)) return o.map(fn) | |
var oc = {} | |
Object.keys(oc).forEach(function (key) { | |
oc[key] = fn.call(this, o[key], key, o) | |
}) | |
return oc | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment