Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

coforeach

Cereceres13MIT0.0.1

wrap to forEach method using generators

co, generators, promise, coroutines, foreach, array

readme

coForEach

co wrap to forEach method

Install

npm install coforeach

Usage

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 )

API

coFor(iterater[, context, arrayToIterate]) -> Promise

iterater(item, index) -> null

iterater should be a generator receive the item and index of arrayToIterate

context

the context to call iterater, default is {}

arrayToIterate

The array to iterate, can be passed as thid arg or with context with is called coFor