Skip to content

Instantly share code, notes, and snippets.

@mattpodwysocki
Last active April 21, 2017 15:18
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 mattpodwysocki/ae6ccace2e1eb835e7fa2d5284b6245a to your computer and use it in GitHub Desktop.
Save mattpodwysocki/ae6ccace2e1eb835e7fa2d5284b6245a to your computer and use it in GitHub Desktop.
async function forEach<T>(iterable: AsyncIterable<T>, fn: (value: T, index: number) => void, thisArg?: any): Promise<void> {
const fun = fn.bind(thisArg);
let i = 0;
for await (let item of iterable) {
fun(item, i++);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment