prll
v1.5.3
Published
Runs a bunch of promises like Promise.all does, but takes an object instead of array
Downloads
4
Readme
Parallel
Runs a bunch of promises like Promise.all
does, but takes an object instead of array.
Keep the differences:
Promise.all([foo(), bar(), baz(), qux()])
.then(arr => magic(arr[2], arr[0], arr[1]));
vs
prll({foo: foo(), bar: bar(), baz: baz(), qux: qux()})
.then(r => magic(r.baz, r.foo, r.bar, r.qux));
Or with es6:
prll({a: foobar(), b: bazqux()})
.then(({a, b}) => magic(a, b));
Example
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));