Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/a-x-/parallel
Runs a bunch of promises like Promise.all does, but takes an object instead of array
https://github.com/a-x-/parallel
promise
Last synced: about 2 months ago
JSON representation
Runs a bunch of promises like Promise.all does, but takes an object instead of array
- Host: GitHub
- URL: https://github.com/a-x-/parallel
- Owner: a-x-
- License: mit
- Created: 2015-10-06T08:01:55.000Z (about 9 years ago)
- Default Branch: master
- Last Pushed: 2017-03-02T10:38:38.000Z (almost 8 years ago)
- Last Synced: 2024-11-03T21:04:10.054Z (about 2 months ago)
- Topics: promise
- Language: JavaScript
- Homepage: https://www.npmjs.com/package/prll
- Size: 16.6 KB
- Stars: 2
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Parallel
Runs a bunch of promises like `Promise.all` does, but takes an object instead of array.Keep the differences:
```js
Promise.all([foo(), bar(), baz(), qux()])
.then(arr => magic(arr[2], arr[0], arr[1]));
```
vs
```js
prll({foo: foo(), bar: bar(), baz: baz(), qux: qux()})
.then(r => magic(r.baz, r.foo, r.bar, r.qux));
```Or with es6:
```js
prll({a: foobar(), b: bazqux()})
.then(({a, b}) => magic(a, b));
```### Example
```js
import 'prll' as parallel;parallel(_.mapValues({
questions: '/data/questions.json',
cv: '/data/user/_cv.json'
}, url => $.ajax(url)))
.then(({questions, cv}) => console.log(questions, cv));
```### Alternativies
* [bluebird](https://github.com/petkaantonov/bluebird) [Promise.props](http://bluebirdjs.com/docs/api/promise.props.html)