Skip to content

Instantly share code, notes, and snippets.

@DanShappir
Created November 1, 2020 10:06
Show Gist options
  • Save DanShappir/eac080c897639dea4044f19af1a795b3 to your computer and use it in GitHub Desktop.
Save DanShappir/eac080c897639dea4044f19af1a795b3 to your computer and use it in GitHub Desktop.
forEach for use with pipeline operator
async function forEach(src, op) {
let index = 0;
for await (const value of src) {
if (op(value, index++) === false) {
break;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment