Skip to content

Instantly share code, notes, and snippets.

@michaelrhodes
Last active July 11, 2016 20:55
Show Gist options
  • Save michaelrhodes/9099f86d7899f628b05176e2942d0f74 to your computer and use it in GitHub Desktop.
Save michaelrhodes/9099f86d7899f628b05176e2942d0f74 to your computer and use it in GitHub Desktop.
function each (o, fn) {
Array.isArray(o) ? o.forEach(fn) :
Object.keys(o).forEach(function (key, i) {
fn.call(this, o[key], key, o)
})
}
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