Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/alsotang/co-async
https://github.com/alsotang/co-async
Last synced: 13 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/alsotang/co-async
- Owner: alsotang
- License: mit
- Created: 2015-11-15T11:02:47.000Z (about 9 years ago)
- Default Branch: master
- Last Pushed: 2017-10-19T04:08:41.000Z (about 7 years ago)
- Last Synced: 2024-11-03T17:04:51.244Z (2 months ago)
- Language: JavaScript
- Size: 4.88 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# co-async
**DEPRECATED. please use bluebird.map, it can control concurrency limit now. http://bluebirdjs.com/docs/api/promise.map.html**
[![Build Status](https://travis-ci.org/alsotang/co-async.svg?branch=master)](https://travis-ci.org/alsotang/co-async)
## quick start
```js
var coAsync = require('co-async')
var initValues = {a: 1, b: 2, c: 3, d: 4}var start = new Date
var values = yield coAsync.map(initValues, 1, function * (v, k) {
yield sleep(10)
return v * 2
});
(new Date - start).should.aboveOrEqual(40)
values.should.eql({a: 2, b: 4, c: 6, d: 8})
```## API
### map(obj, gen)
### map(obj, limit, gen)`obj` -- array or object. e.g. `[1,2,3,4]` or `{a: 1, b: 2}`
`limit` -- concurrency limit
`gen` -- a generator