Skip to content
Open
Changes from all commits
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
21 changes: 21 additions & 0 deletions lib/concatSeries.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,27 @@ import awaitify from './internal/awaitify.js'
* containing the concatenated results of the `iteratee` function. Invoked with
* (err, results).
* @returns A Promise, if no callback is passed
* @example
*
* // One item at a time. Iteratee arrays are concatenated, in input order.
* const words = ["hello", "world", "async"];
*
* function chars(word, callback) {
* setTimeout(() => {
* callback(null, [...word]);
* }, 100);
* }
*
* async.concatSeries(words, chars, (err, results) => {
* if (err) throw err;
* console.log(results);
* // ["h","e","l","l","o","w","o","r","l","d","a","s","y"]
* });
*
* // Omit the callback and concatSeries returns a Promise.
* const results = await async.concatSeries(words, async (word) => [...word]);
* console.log(results);
* // ["h","e","l","l","o","w","o","r","l","d","a","s","y"]
*/
function concatSeries(coll, iteratee, callback) {
return concatLimit(coll, 1, iteratee, callback)
Expand Down