You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
31 lines
677 B
31 lines
677 B
'use strict'; |
|
|
|
var initial = require('array-initial'); |
|
var last = require('array-last'); |
|
var asyncSettle = require('async-settle'); |
|
var nowAndLater = require('now-and-later'); |
|
|
|
var helpers = require('./helpers'); |
|
|
|
function iterator(fn, key, cb) { |
|
return asyncSettle(fn, cb); |
|
} |
|
|
|
function buildSettleSeries() { |
|
var args = helpers.verifyArguments(arguments); |
|
|
|
var extensions = helpers.getExtensions(last(args)); |
|
|
|
if (extensions) { |
|
args = initial(args); |
|
} |
|
|
|
function settleSeries(done) { |
|
var onSettled = helpers.onSettled(done); |
|
nowAndLater.mapSeries(args, iterator, extensions, onSettled); |
|
} |
|
|
|
return settleSeries; |
|
} |
|
|
|
module.exports = buildSettleSeries;
|
|
|