Skip to content

Instantly share code, notes, and snippets.

@dwickstrom
Created January 9, 2018 12:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dwickstrom/e224d49c1a0ce0bde2374fdf59f9c1cf to your computer and use it in GitHub Desktop.
Save dwickstrom/e224d49c1a0ce0bde2374fdf59f9c1cf to your computer and use it in GitHub Desktop.
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