Created
May 29, 2020 15:09
-
-
Save fostyfost/9e972b1ad9dbd4ffd4e4703c00060fea to your computer and use it in GitHub Desktop.
Util: foreach-generator (ex. for redux-saga)
This file contains 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
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