Created
January 9, 2018 12:14
-
-
Save dwickstrom/e224d49c1a0ce0bde2374fdf59f9c1cf to your computer and use it in GitHub Desktop.
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
const isThenable = val => | |
val | |
&& typeof val === 'object' | |
&& typeof val.then === 'function' | |
const map = fn => arg => | |
isThenable(arg) ? arg.then(fn) | |
: Array.isArray(arg) ? arg.map(fn) | |
: /* else */ ? fn(arg) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment