Skip to content

Instantly share code, notes, and snippets.

@janwirth
Created August 7, 2016 07:21
Show Gist options
  • Save janwirth/832c5acc1c4ee0613a4e7fc15e7ea2bb to your computer and use it in GitHub Desktop.
Save janwirth/832c5acc1c4ee0613a4e7fc15e7ea2bb to your computer and use it in GitHub Desktop.
# deep map obj with function in context
deepMap = (obj, f, ctx) ->
res = {}
for key of obj
val = obj[key]
if typeof val == 'object'
res[key] = deepMap(val, f, ctx)
else
res[key] = f.call(ctx, val, key)
res
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment