co wrap to forEach metho
npm install coforeach
let coFor = require('coforeach')
let returned = coFor(function * (item, index) {
assert(item ===3) // the item is equal to item in array
assert(this.test === 'context is the second arg') // the context is the passed as second arg to coForEach
},
{test: 'context is the second arg'}, // this is the context
[3] // this is array over which iterate
)
assert(returned instanceof Promise )
coFor(iterater[, context, arrayToIterate]) -> Promise
iterater should be a generator receive the item and index of arrayToIterate
the context to call iterater, default is {}
The array to iterate, can be passed as third arg or like second arg if third is undefined.