Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: await-able Async methods #1572

Merged
merged 25 commits into from
Oct 1, 2018
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
awaitable series (lol)
aearly committed Sep 3, 2018
commit 4dbafbafe1747ed0952bac91f58d36f56e8f0c52
5 changes: 3 additions & 2 deletions lib/series.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import parallel from './internal/parallel';
import _parallel from './internal/parallel';
import eachOfSeries from './eachOfSeries';

/**
@@ -34,6 +34,7 @@ import eachOfSeries from './eachOfSeries';
* functions have completed. This function gets a results array (or object)
* containing all the result arguments passed to the `task` callbacks. Invoked
* with (err, result).
* @return {Promise} a promise, if no callback is passed
* @example
* async.series([
* function(callback) {
@@ -66,5 +67,5 @@ import eachOfSeries from './eachOfSeries';
* });
*/
export default function series(tasks, callback) {
parallel(eachOfSeries, tasks, callback);
return _parallel(eachOfSeries, tasks, callback);
}
11 changes: 11 additions & 0 deletions test/es2017/awaitableFunctions.js
Original file line number Diff line number Diff line change
@@ -484,6 +484,17 @@ module.exports = function () {
], 2)
expect(calls).to.eql([1, 1, 1, 1])
});
it('should return a Promise: series', async () => {
expect (async.series.name).to.contain('series')
const calls = []
await async.series([
async () => { await Promise.resolve(); calls.push(1) },
async () => { await Promise.resolve(); calls.push(1) },
async () => { await Promise.resolve(); calls.push(1) },
async () => { await Promise.resolve(); calls.push(1) },
], 2)
expect(calls).to.eql([1, 1, 1, 1])
});

it('should return a Promise: race', async () => {
expect (async.race.name).to.contain('race')