diff --git a/lib/util.js b/lib/util.js index 5300fa5..8dc625e 100644 --- a/lib/util.js +++ b/lib/util.js @@ -70,22 +70,15 @@ class Util { /** * Serialize a series of asynchronous calls to a function * over a list of objects - * ref: http://www.joezimjs.com/javascript/patterns-asynchronous-programming-promises/ */ - static seriesCall(list, fn) { + static async seriesCall(list, fn) { const results = [] - return list.reduce((memo, item) => { - return memo.then(() => { - return fn(item) - }).then(result => { - results.push(result) - }) - }, - Promise.resolve() - ).then(function() { - return results - }) + for (const item of list) { + results.push(await fn(item)); + } + + return results; } /**