Created
February 4, 2016 01:13
-
-
Save smithamax/fa890c7dd108effcd916 to your computer and use it in GitHub Desktop.
universalMapper
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 universalMapper(obj, fn) { | |
if (!obj) return obj; | |
if (Array.isArray(obj)) return obj.map(fn); | |
return fn(obj); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment