Skip to content

Instantly share code, notes, and snippets.

@fostyfost
Created May 29, 2020 15:09
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 fostyfost/9e972b1ad9dbd4ffd4e4703c00060fea to your computer and use it in GitHub Desktop.
Save fostyfost/9e972b1ad9dbd4ffd4e4703c00060fea to your computer and use it in GitHub Desktop.
Util: foreach-generator (ex. for redux-saga)
export default function* foreach(array, fn, context) {
let i = 0;
for (; i < array.length; i++) {
yield* fn.call(context, array[i], i, array);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment