Created
July 28, 2022 23:49
-
-
Save tsibley/c1a6a620b31a915d4b58c8a7ee30bd78 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
| async function map(iterable, fn = x => x) { | |
| let array; | |
| if (iterable.map) { | |
| array = iterable; | |
| } else { | |
| array = []; | |
| for await (const x of iterable) { | |
| array.push(x); | |
| } | |
| } | |
| return array.map(x => fn(x)); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment