gocsp-limit
Parallel execution with max concurrency limit.
Installation
$ npm install gocsp-limit
Example
var go = require('gocsp-go')
var limit = require('gocsp-limit')
var thunk = require('gocsp-thunk')
var readFile = thunk.ify(require('fs').readFile)
go(function* () {
var files = yield [
'example.js',
'index.js',
'package.json',
'README.md',
'test.js'
].map(limit.wrap(3, function* (filename) {
return yield readFile(__dirname + '/' + filename, 'utf8')
}))
})
API
limit( concurrency )
like go
in gocsp-go, but with max concurrency limit
Example:
var limitGo = limit(5)
for (var i = 0; i < 10; i++) {
limitGo(function* () {
})
}
limit.wrap( concurrency, generatorFunction )
like go.wrap
in gocsp-go, but with max concurrency limit
Example:
go(function* () {
var files = yield [
'example.js',
'index.js',
'package.json',
'README.md',
'test.js'
].map(limit.wrap(3, function* (filename) {
return yield readFile(__dirname + '/' + filename, 'utf8')
}))
})
License
MIT