Last active
October 23, 2019 19:53
-
-
Save tdreyno/873d58661361f8f02afa1ce088f62523 to your computer and use it in GitHub Desktop.
It's like map, but you get the whole list.
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
interface Array<T> { | |
andThen: <U>(this: T[], fn: (items: T[]) => U) => U; | |
} | |
Array.prototype.andThen = function<T, U>(this: T[], fn: (items: T[]) => U): U { | |
return fn(this); | |
}; |
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 users = await ["userid1", "userid2"].map(fetch).andThen(Promise.all); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment