diff --git a/bower.json b/bower.json index f2970141..1c1a3285 100644 --- a/bower.json +++ b/bower.json @@ -1,7 +1,7 @@ { "name": "neo-async", "main": "lib/async.js", - "version": "2.5.2", + "version": "2.6.0", "homepage": "https://github.com/suguru03/neo-async", "authors": [ "Suguru Motegi" diff --git a/dist/async.js b/dist/async.js index a891d295..cfb3691c 100644 --- a/dist/async.js +++ b/dist/async.js @@ -1964,11 +1964,11 @@ var dir = createLogger('dir'); /** - * @version 2.5.2 + * @version 2.6.0 * @namespace async */ var index = { - VERSION: '2.5.2', + VERSION: '2.6.0', // Collections each: each, @@ -2427,17 +2427,19 @@ */ function symbolEach(collection, iterator, callback) { var iter = collection[iteratorSymbol](); - var index = -1; + var index = 0; var item; if (iterator.length === 3) { while ((item = iter.next()).done === false) { - iterator(item.value, ++index, onlyOnce(callback)); + iterator(item.value, index++, onlyOnce(callback)); } } else { while ((item = iter.next()).done === false) { + index++; iterator(item.value, onlyOnce(callback)); } } + return index; } /** @@ -2483,18 +2485,20 @@ */ function symbolEachResult(collection, result, iterator, callback) { var item; - var index = -1; + var index = 0; var iter = collection[iteratorSymbol](); if (iterator.length === 4) { while ((item = iter.next()).done === false) { - iterator(result, item.value, ++index, onlyOnce(callback)); + iterator(result, item.value, index++, onlyOnce(callback)); } } else { while ((item = iter.next()).done === false) { + index++; iterator(result, item.value, onlyOnce(callback)); } } + return index; } /** @@ -2565,21 +2569,20 @@ * @private */ function symbolEachIndex(collection, iterator, createCallback) { - var values; - var index = -1; - var size = collection.size; + var item; + var index = 0; var iter = collection[iteratorSymbol](); if (iterator.length === 3) { - while (++index < size) { - values = iter.next().value; - iterator(values, index, createCallback(index)); + while ((item = iter.next()).done === false) { + iterator(item.value, index, createCallback(index++)); } } else { - while (++index < size) { - iterator(iter.next().value, createCallback(index)); + while ((item = iter.next()).done === false) { + iterator(item.value, createCallback(index++)); } } + return index; } /** @@ -2608,18 +2611,19 @@ */ function symbolEachKey(collection, iterator, createCallback) { var item; - var index = -1; + var index = 0; var iter = collection[iteratorSymbol](); if (iterator.length === 3) { while ((item = iter.next()).done === false) { - iterator(item.value, ++index, createCallback(index)); + iterator(item.value, index, createCallback(index++)); } } else { while ((item = iter.next()).done === false) { - iterator(item.value, createCallback(++index)); + iterator(item.value, createCallback(index++)); } } + return index; } /** @@ -2670,20 +2674,22 @@ */ function symbolEachValue(collection, iterator, createCallback) { var value, item; - var index = -1; + var index = 0; var iter = collection[iteratorSymbol](); if (iterator.length === 3) { while ((item = iter.next()).done === false) { value = item.value; - iterator(value, ++index, createCallback(value)); + iterator(value, index++, createCallback(value)); } } else { while ((item = iter.next()).done === false) { + index++; value = item.value; iterator(value, createCallback(value)); } } + return index; } /** @@ -2734,20 +2740,21 @@ */ function symbolEachIndexValue(collection, iterator, createCallback) { var value, item; - var index = -1; + var index = 0; var iter = collection[iteratorSymbol](); if (iterator.length === 3) { while ((item = iter.next()).done === false) { value = item.value; - iterator(value, ++index, createCallback(index, value)); + iterator(value, index, createCallback(index++, value)); } } else { while ((item = iter.next()).done === false) { value = item.value; - iterator(value, createCallback(++index, value)); + iterator(value, createCallback(index++, value)); } } + return index; } /** @@ -2778,20 +2785,21 @@ */ function symbolEachKeyValue(collection, iterator, createCallback) { var value, item; - var index = -1; + var index = 0; var iter = collection[iteratorSymbol](); if (iterator.length === 3) { while ((item = iter.next()).done === false) { value = item.value; - iterator(value, ++index, createCallback(index, value)); + iterator(value, index, createCallback(index++, value)); } } else { while ((item = iter.next()).done === false) { value = item.value; - iterator(value, createCallback(++index, value)); + iterator(value, createCallback(index++, value)); } } + return index; } /** @@ -2818,7 +2826,6 @@ }; } - /** * @private * @param {Function} arrayEach @@ -2827,7 +2834,7 @@ function createEach(arrayEach, baseEach, symbolEach) { return function each(collection, iterator, callback) { - callback = callback || noop; + callback = once(callback || noop); var size, keys; var completed = 0; if (isArray(collection)) { @@ -2835,8 +2842,8 @@ arrayEach(collection, iterator, done); } else if (!collection) { } else if (iteratorSymbol && collection[iteratorSymbol]) { - size = collection.size; - symbolEach(collection, iterator, done); + size = symbolEach(collection, iterator, done); + size && size === completed && callback(null); } else if (typeof collection === obj) { keys = nativeKeys(collection); size = keys.length; @@ -2890,9 +2897,10 @@ arrayEach(collection, iterator, createCallback); } else if (!collection) { } else if (iteratorSymbol && collection[iteratorSymbol]) { - size = collection.size; - result = init(size); - symbolEach(collection, iterator, createCallback); + // TODO: size could be changed + result = init(0); + size = symbolEach(collection, iterator, createCallback); + size && size === completed && callback(null, result); } else if (typeof collection === obj) { keys = nativeKeys(collection); size = keys.length; @@ -2944,9 +2952,9 @@ arrayEach(collection, iterator, createCallback); } else if (!collection) { } else if (iteratorSymbol && collection[iteratorSymbol]) { - size = collection.size; - result = Array(size); - symbolEach(collection, iterator, createCallback); + result = []; + size = symbolEach(collection, iterator, createCallback); + size && size === completed && callback(null, compact(result)); } else if (typeof collection === obj) { keys = nativeKeys(collection); size = keys.length; @@ -2988,7 +2996,7 @@ return function(collection, iterator, callback) { callback = onlyOnce(callback || noop); - var size, key, value, keys, iter, iterate; + var size, key, value, keys, iter, item, iterate; var sync = false; var completed = 0; var result = []; @@ -2998,7 +3006,7 @@ iterate = iterator.length === 3 ? arrayIteratorWithIndex : arrayIterator; } else if (!collection) { } else if (iteratorSymbol && collection[iteratorSymbol]) { - size = collection.size; + size = Infinity; iter = collection[iteratorSymbol](); iterate = iterator.length === 3 ? symbolIteratorWithKey : symbolIterator; } else if (typeof collection === obj) { @@ -3022,13 +3030,15 @@ } function symbolIterator() { - value = iter.next().value; - iterator(value, done); + item = iter.next(); + value = item.value; + item.done ? callback(null, result) : iterator(value, done); } function symbolIteratorWithKey() { - value = iter.next().value; - iterator(value, completed, done); + item = iter.next(); + value = item.value; + item.done ? callback(null, result) : iterator(value, completed, done); } function objectIterator() { @@ -3083,7 +3093,8 @@ iterate = iterator.length === 3 ? arrayIteratorWithIndex : arrayIterator; } else if (!collection) { } else if (iteratorSymbol && collection[iteratorSymbol]) { - size = collection.size; + size = Infinity; + result = []; iter = collection[iteratorSymbol](); iterate = iterator.length === 3 ? symbolIteratorWithKey : symbolIterator; } else if (typeof collection === obj) { @@ -3094,7 +3105,7 @@ if (!size || isNaN(limit) || limit < 1) { return callback(null, []); } - result = Array(size); + result = result || Array(size); timesSync(limit > size ? size : limit, iterate); function arrayIterator() { @@ -3114,16 +3125,24 @@ } function symbolIterator() { - if ((item = iter.next()).done === false) { + item = iter.next(); + if (item.done === false) { value = item.value; iterator(value, createCallback(value, started++)); + } else if (completed >= collection.size && iterator !== noop) { + iterator = noop; + callback(null, compact(result)); } } function symbolIteratorWithKey() { - if ((item = iter.next()).done === false) { + item = iter.next(); + if (item.done === false) { value = item.value; iterator(value, started, createCallback(value, started++)); + } else if (completed >= collection.size && iterator !== noop) { + iterator = noop; + callback(null, compact(result)); } } @@ -3263,7 +3282,7 @@ */ function eachSeries(collection, iterator, callback) { callback = onlyOnce(callback || noop); - var size, key, keys, iter, value, iterate; + var size, key, keys, iter, item, iterate; var sync = false; var completed = 0; @@ -3272,7 +3291,7 @@ iterate = iterator.length === 3 ? arrayIteratorWithIndex : arrayIterator; } else if (!collection) { } else if (iteratorSymbol && collection[iteratorSymbol]) { - size = collection.size; + size = Infinity; iter = collection[iteratorSymbol](); iterate = iterator.length === 3 ? symbolIteratorWithKey : symbolIterator; } else if (typeof collection === obj) { @@ -3294,12 +3313,13 @@ } function symbolIterator() { - iterator(iter.next().value, done); + item = iter.next(); + item.done ? callback(null) : iterator(item.value, done); } function symbolIteratorWithKey() { - value = iter.next().value; - iterator(value, completed, done); + item = iter.next(); + item.done ? callback(null) : iterator(item.value, completed, done); } function objectIterator() { @@ -3314,10 +3334,7 @@ function done(err, bool) { if (err) { callback(err); - } else if (++completed === size) { - iterate = throwError; - callback(null); - } else if (bool === false) { + } else if (++completed === size || bool === false) { iterate = throwError; callback(null); } else if (sync) { @@ -3430,7 +3447,7 @@ iterate = iterator.length === 3 ? arrayIteratorWithIndex : arrayIterator; } else if (!collection) { } else if (iteratorSymbol && collection[iteratorSymbol]) { - size = collection.size; + size = Infinity; iter = collection[iteratorSymbol](); iterate = iterator.length === 3 ? symbolIteratorWithKey : symbolIterator; } else if (typeof collection === obj) { @@ -3459,14 +3476,22 @@ } function symbolIterator() { - if ((item = iter.next()).done === false) { + item = iter.next(); + if (item.done === false) { iterator(item.value, done); + } else if (completed >= collection.size && iterator !== noop) { + iterator = noop; + callback(null); } } function symbolIteratorWithKey() { - if ((item = iter.next()).done === false) { + item = iter.next(); + if (item.done === false) { iterator(item.value, started++, done); + } else if (completed >= collection.size && iterator !== noop) { + iterator = noop; + callback(null); } } @@ -3485,18 +3510,15 @@ } function done(err, bool) { - if (err) { + if (err || bool === false) { iterate = noop; callback = once(callback); callback(err); } else if (++completed === size) { + iterator = noop; iterate = throwError; callback = onlyOnce(callback); callback(null); - } else if (bool === false) { - iterate = noop; - callback = once(callback); - callback(null); } else if (sync) { nextTick(iterate); } else { @@ -3580,7 +3602,7 @@ */ function mapSeries(collection, iterator, callback) { callback = callback || noop; - var size, key, keys, iter, value, result, iterate; + var size, key, keys, iter, item, result, iterate; var sync = false; var completed = 0; @@ -3589,7 +3611,8 @@ iterate = iterator.length === 3 ? arrayIteratorWithIndex : arrayIterator; } else if (!collection) { } else if (iteratorSymbol && collection[iteratorSymbol]) { - size = collection.size; + size = Infinity; + result = []; iter = collection[iteratorSymbol](); iterate = iterator.length === 3 ? symbolIteratorWithKey : symbolIterator; } else if (typeof collection === obj) { @@ -3600,7 +3623,7 @@ if (!size) { return callback(null, []); } - result = Array(size); + result = result || Array(size); iterate(); function arrayIterator() { @@ -3612,12 +3635,13 @@ } function symbolIterator() { - iterator(iter.next().value, done); + item = iter.next(); + item.done ? callback(null, result) : iterator(item.value, done); } function symbolIteratorWithKey() { - value = iter.next().value; - iterator(value, completed, done); + item = iter.next(); + item.done ? callback(null, result) : iterator(item.value, completed, done); } function objectIterator() { @@ -3735,7 +3759,8 @@ iterate = iterator.length === 3 ? arrayIteratorWithIndex : arrayIterator; } else if (!collection) { } else if (iteratorSymbol && collection[iteratorSymbol]) { - size = collection.size; + size = Infinity; + result = []; iter = collection[iteratorSymbol](); iterate = iterator.length === 3 ? symbolIteratorWithKey : symbolIterator; } else if (typeof collection === obj) { @@ -3746,7 +3771,7 @@ if (!size || isNaN(limit) || limit < 1) { return callback(null, []); } - result = Array(size); + result = result || Array(size); timesSync(limit > size ? size : limit, iterate); function arrayIterator() { @@ -3764,14 +3789,22 @@ } function symbolIterator() { - if ((item = iter.next()).done === false) { + item = iter.next(); + if (item.done === false) { iterator(item.value, createCallback(started++)); + } else if (completed >= collection.size && iterator !== noop) { + iterator = noop; + callback(null, result); } } function symbolIteratorWithKey() { - if ((item = iter.next()).done === false) { + item = iter.next(); + if (item.done === false) { iterator(item.value, started, createCallback(started++)); + } else if (completed >= collection.size && iterator !== noop) { + iterator = noop; + callback(null, result); } } @@ -3892,7 +3925,7 @@ */ function mapValuesSeries(collection, iterator, callback) { callback = callback || noop; - var size, key, keys, iter, value, iterate; + var size, key, keys, iter, item, iterate; var sync = false; var result = {}; var completed = 0; @@ -3902,7 +3935,7 @@ iterate = iterator.length === 3 ? arrayIteratorWithIndex : arrayIterator; } else if (!collection) { } else if (iteratorSymbol && collection[iteratorSymbol]) { - size = collection.size; + size = Infinity; iter = collection[iteratorSymbol](); iterate = iterator.length === 3 ? symbolIteratorWithKey : symbolIterator; } else if (typeof collection === obj) { @@ -3927,14 +3960,14 @@ function symbolIterator() { key = completed; - value = iter.next().value; - iterator(value, done); + item = iter.next(); + item.done ? callback(null, result) : iterator(item.value, done); } function symbolIteratorWithKey() { key = completed; - value = iter.next().value; - iterator(value, completed, done); + item = iter.next(); + item.done ? callback(null, result) : iterator(item.value, completed, done); } function objectIterator() { @@ -4054,7 +4087,7 @@ iterate = iterator.length === 3 ? arrayIteratorWithIndex : arrayIterator; } else if (!collection) { } else if (iteratorSymbol && collection[iteratorSymbol]) { - size = collection.size; + size = Infinity; iter = collection[iteratorSymbol](); iterate = iterator.length === 3 ? symbolIteratorWithKey : symbolIterator; } else if (typeof collection === obj) { @@ -4082,14 +4115,22 @@ } function symbolIterator() { - if ((item = iter.next()).done === false) { + item = iter.next(); + if (item.done === false) { iterator(item.value, createCallback(started++)); + } else if (completed >= collection.size && iterator !== noop) { + iterator = noop; + callback(null, result); } } function symbolIteratorWithKey() { - if ((item = iter.next()).done === false) { + item = iter.next(); + if (item.done === false) { iterator(item.value, started, createCallback(started++)); + } else if (completed >= collection.size && iterator !== noop) { + iterator = noop; + callback(null, result); } } @@ -4155,8 +4196,8 @@ arrayEach(collection, iterator, createCallback); } else if (!collection) { } else if (iteratorSymbol && collection[iteratorSymbol]) { - size = collection.size; - symbolEach(collection, iterator, createCallback); + size = symbolEach(collection, iterator, createCallback); + size && size === completed && callback(null); } else if (typeof collection === obj) { keys = nativeKeys(collection); size = keys.length; @@ -4195,7 +4236,7 @@ return function(collection, iterator, callback) { callback = onlyOnce(callback || noop); - var size, key, value, keys, iter, iterate; + var size, key, value, keys, iter, item, iterate; var sync = false; var completed = 0; @@ -4204,7 +4245,7 @@ iterate = iterator.length === 3 ? arrayIteratorWithIndex : arrayIterator; } else if (!collection) { } else if (iteratorSymbol && collection[iteratorSymbol]) { - size = collection.size; + size = Infinity; iter = collection[iteratorSymbol](); iterate = iterator.length === 3 ? symbolIteratorWithKey : symbolIterator; } else if (typeof collection === obj) { @@ -4228,13 +4269,15 @@ } function symbolIterator() { - value = iter.next().value; - iterator(value, done); + item = iter.next(); + value = item.value; + item.done ? callback(null) : iterator(value, done); } function symbolIteratorWithKey() { - value = iter.next().value; - iterator(value, completed, done); + item = iter.next(); + value = item.value; + item.done ? callback(null) : iterator(value, completed, done); } function objectIterator() { @@ -4286,7 +4329,7 @@ iterate = iterator.length === 3 ? arrayIteratorWithIndex : arrayIterator; } else if (!collection) { } else if (iteratorSymbol && collection[iteratorSymbol]) { - size = collection.size; + size = Infinity; iter = collection[iteratorSymbol](); iterate = iterator.length === 3 ? symbolIteratorWithKey : symbolIterator; } else if (typeof collection === obj) { @@ -4316,16 +4359,24 @@ } function symbolIterator() { - if ((item = iter.next()).done === false) { + item = iter.next(); + if (item.done === false) { value = item.value; iterator(value, createCallback(value)); + } else if (completed >= collection.size && iterator !== noop) { + iterator = noop; + callback(null); } } function symbolIteratorWithKey() { - if ((item = iter.next()).done === false) { + item = iter.next(); + if (item.done === false) { value = item.value; iterator(value, started++, createCallback(value)); + } else if (completed >= collection.size && iterator !== noop) { + iterator = noop; + callback(null); } } @@ -4394,8 +4445,8 @@ arrayEach(collection, iterator, createCallback); } else if (!collection) { } else if (iteratorSymbol && collection[iteratorSymbol]) { - size = collection.size; - symbolEach(collection, iterator, createCallback); + size = symbolEach(collection, iterator, createCallback); + size && size === completed && callback(null, result); } else if (typeof collection === obj) { keys = nativeKeys(collection); size = keys.length; @@ -4436,7 +4487,7 @@ return function(collection, iterator, callback) { callback = onlyOnce(callback || noop); - var size, key, value, keys, iter, iterate; + var size, key, value, keys, iter, item, iterate; var sync = false; var result = {}; var completed = 0; @@ -4446,7 +4497,7 @@ iterate = iterator.length === 3 ? arrayIteratorWithIndex : arrayIterator; } else if (!collection) { } else if (iteratorSymbol && collection[iteratorSymbol]) { - size = collection.size; + size = Infinity; iter = collection[iteratorSymbol](); iterate = iterator.length === 3 ? symbolIteratorWithKey : symbolIterator; } else if (typeof collection === obj) { @@ -4459,6 +4510,7 @@ } iterate(); + function arrayIterator() { key = completed; value = collection[completed]; @@ -4473,14 +4525,16 @@ function symbolIterator() { key = completed; - value = iter.next().value; - iterator(value, done); + item = iter.next(); + value = item.value; + item.done ? callback(null, result) : iterator(value, done); } function symbolIteratorWithKey() { key = completed; - value = iter.next().value; - iterator(value, key, done); + item = iter.next(); + value = item.value; + item.done ? callback(null, result) : iterator(value, key, done); } function objectIterator() { @@ -4536,7 +4590,7 @@ iterate = iterator.length === 3 ? arrayIteratorWithIndex : arrayIterator; } else if (!collection) { } else if (iteratorSymbol && collection[iteratorSymbol]) { - size = collection.size; + size = Infinity; iter = collection[iteratorSymbol](); iterate = iterator.length === 3 ? symbolIteratorWithKey : symbolIterator; } else if (typeof collection === obj) { @@ -4566,16 +4620,24 @@ } function symbolIterator() { - if ((item = iter.next()).done === false) { + item = iter.next(); + if (item.done === false) { value = item.value; iterator(value, createCallback(value, started++)); + } else if (completed >= collection.size && iterator !== noop) { + iterator = noop; + callback(null, result); } } function symbolIteratorWithKey() { - if ((item = iter.next()).done === false) { + item = iter.next(); + if (item.done === false) { value = item.value; iterator(value, started, createCallback(value, started++)); + } else if (completed >= collection.size && iterator !== noop) { + iterator = noop; + callback(null, result); } } @@ -4926,9 +4988,9 @@ arrayEach(collection, result, iterator, done); } else if (!collection) { } else if (iteratorSymbol && collection[iteratorSymbol]) { - size = collection.size; result = accumulator !== undefined ? accumulator : {}; - symbolEach(collection, result, iterator, done); + size = symbolEach(collection, result, iterator, done); + size && size === completed && callback(null, result); } else if (typeof collection === obj) { keys = nativeKeys(collection); size = keys.length; @@ -5036,7 +5098,7 @@ accumulator = undefined; } callback = onlyOnce(callback || noop); - var size, key, keys, iter, iterate, result; + var size, key, keys, iter, item, iterate, result; var sync = false; var completed = 0; @@ -5070,11 +5132,13 @@ } function symbolIterator() { - iterator(result, iter.next().value, done); + item = iter.next(); + item.done ? callback(null, result) : iterator(result, item.value, done); } function symbolIteratorWithKey() { - iterator(result, iter.next().value, completed, done); + item = iter.next(); + item.done ? callback(null, result) : iterator(result, item.value, completed, done); } function objectIterator() { @@ -5089,10 +5153,7 @@ function done(err, bool) { if (err) { callback(err, result); - } else if (++completed === size) { - iterate = throwError; - callback(null, result); - } else if (bool === false) { + } else if (++completed === size || bool === false) { iterate = throwError; callback(null, result); } else if (sync) { @@ -5200,7 +5261,7 @@ iterate = iterator.length === 4 ? arrayIteratorWithIndex : arrayIterator; } else if (!collection) { } else if (iteratorSymbol && collection[iteratorSymbol]) { - size = collection.size; + size = Infinity; iter = collection[iteratorSymbol](); result = accumulator !== undefined ? accumulator : {}; iterate = iterator.length === 4 ? symbolIteratorWithKey : symbolIterator; @@ -5230,14 +5291,22 @@ } function symbolIterator() { - if ((item = iter.next()).done === false) { + item = iter.next(); + if (item.done === false) { iterator(result, item.value, onlyOnce(done)); + } else if (completed >= collection.size && iterator !== noop) { + iterator = noop; + callback(null, result); } } function symbolIteratorWithKey() { - if ((item = iter.next()).done === false) { + item = iter.next(); + if (item.done === false) { iterator(result, item.value, started++, onlyOnce(done)); + } else if (completed >= collection.size && iterator !== noop) { + iterator = noop; + callback(null, result); } } @@ -5257,16 +5326,13 @@ } function done(err, bool) { - if (err) { + if (err || bool === false) { iterate = noop; - callback(err, isArray(result) ? createArray(result) : objectClone(result)); + callback(err || null, isArray(result) ? createArray(result) : objectClone(result)); callback = noop; } else if (++completed === size) { + iterator = noop; callback(null, result); - } else if (bool === false) { - iterate = noop; - callback(null, isArray(result) ? createArray(result) : objectClone(result)); - callback = noop; } else if (sync) { nextTick(iterate); } else { @@ -5297,10 +5363,10 @@ arrayEach(collection, iterator, createCallback); } else if (!collection) { } else if (iteratorSymbol && collection[iteratorSymbol]) { - size = collection.size; - array = Array(size); - criteria = Array(size); - symbolEach(collection, iterator, createCallback); + array = []; + criteria = []; + size = symbolEach(collection, iterator, createCallback); + size && size === completed && callback(null, sortByCriteria(array, criteria)); } else if (typeof collection === obj) { var keys = nativeKeys(collection); size = keys.length; @@ -5405,7 +5471,7 @@ */ function sortBySeries(collection, iterator, callback) { callback = onlyOnce(callback || noop); - var size, key, value, keys, iter, array, criteria, iterate; + var size, key, value, keys, iter, item, array, criteria, iterate; var sync = false; var completed = 0; @@ -5416,9 +5482,9 @@ iterate = iterator.length === 3 ? arrayIteratorWithIndex : arrayIterator; } else if (!collection) { } else if (iteratorSymbol && collection[iteratorSymbol]) { - size = collection.size; - array = Array(size); - criteria = Array(size); + size = Infinity; + array = []; + criteria = []; iter = collection[iteratorSymbol](); iterate = iterator.length === 3 ? symbolIteratorWithKey : symbolIterator; } else if (typeof collection === obj) { @@ -5444,13 +5510,21 @@ } function symbolIterator() { - value = iter.next().value; + item = iter.next(); + if (item.done) { + return callback(null, sortByCriteria(array, criteria)); + } + value = item.value; array[completed] = value; iterator(value, done); } function symbolIteratorWithKey() { - value = iter.next().value; + item = iter.next(); + if (item.done) { + return callback(null, sortByCriteria(array, criteria)); + } + value = item.value; array[completed] = value; iterator(value, completed, done); } @@ -5570,9 +5644,10 @@ iterate = iterator.length === 3 ? arrayIteratorWithIndex : arrayIterator; } else if (!collection) { } else if (iteratorSymbol && collection[iteratorSymbol]) { - size = collection.size; + size = Infinity; iter = collection[iteratorSymbol](); - array = Array(size); + array = []; + criteria = []; iterate = iterator.length === 3 ? symbolIteratorWithKey : symbolIterator; } else if (typeof collection === obj) { keys = nativeKeys(collection); @@ -5583,7 +5658,7 @@ if (!size || isNaN(limit) || limit < 1) { return callback(null, []); } - criteria = Array(size); + criteria = criteria || Array(size); timesSync(limit > size ? size : limit, iterate); function arrayIterator() { @@ -5602,18 +5677,26 @@ } function symbolIterator() { - if ((item = iter.next()).done === false) { + item = iter.next(); + if (item.done === false) { value = item.value; array[started] = value; iterator(value, createCallback(value, started++)); + } else if (completed >= collection.size && iterator !== noop) { + iterator = noop; + callback(null, sortByCriteria(array, criteria)); } } function symbolIteratorWithKey() { - if ((item = iter.next()).done === false) { + item = iter.next(); + if (item.done === false) { value = item.value; array[started] = value; iterator(value, started, createCallback(value, started++)); + } else if (completed >= collection.size && iterator !== noop) { + iterator = noop; + callback(null, sortByCriteria(array, criteria)); } } @@ -5991,9 +6074,9 @@ arrayEach(collection, iterator, createCallback); } else if (!collection) { } else if (iteratorSymbol && collection[iteratorSymbol]) { - size = collection.size; - result = Array(size); - symbolEach(collection, iterator, createCallback); + result = []; + size = symbolEach(collection, iterator, createCallback); + size && size === completed && callback(null, result); } else if (typeof collection === obj) { var keys = nativeKeys(collection); size = keys.length; @@ -6114,7 +6197,7 @@ */ function concatSeries(collection, iterator, callback) { callback = onlyOnce(callback || noop); - var size, key, keys, iter, values, iterate; + var size, key, keys, iter, item, iterate; var sync = false; var result = []; var completed = 0; @@ -6124,7 +6207,7 @@ iterate = iterator.length === 3 ? arrayIteratorWithIndex : arrayIterator; } else if (!collection) { } else if (iteratorSymbol && collection[iteratorSymbol]) { - size = collection.size; + size = Infinity; iter = collection[iteratorSymbol](); iterate = iterator.length === 3 ? symbolIteratorWithKey : symbolIterator; } else if (typeof collection === obj) { @@ -6146,12 +6229,13 @@ } function symbolIterator() { - iterator(iter.next().value, done); + item = iter.next(); + item.done ? callback(null, result) : iterator(item.value, done); } function symbolIteratorWithKey() { - values = iter.next().value; - iterator(values, completed, done); + item = iter.next(); + item.done ? callback(null, result) : iterator(item.value, completed, done); } function objectIterator() { @@ -6258,7 +6342,7 @@ */ function concatLimit(collection, limit, iterator, callback) { callback = callback || noop; - var size, key, iter, item, iterate; + var size, key, iter, item, iterate, result; var sync = false; var started = 0; var completed = 0; @@ -6268,7 +6352,8 @@ iterate = iterator.length === 3 ? arrayIteratorWithIndex : arrayIterator; } else if (!collection) { } else if (iteratorSymbol && collection[iteratorSymbol]) { - size = collection.size; + size = Infinity; + result = []; iter = collection[iteratorSymbol](); iterate = iterator.length === 3 ? symbolIteratorWithKey : symbolIterator; } else if (typeof collection === obj) { @@ -6279,7 +6364,7 @@ if (!size || isNaN(limit) || limit < 1) { return callback(null, []); } - var result = Array(size); + result = result || Array(size); timesSync(limit > size ? size : limit, iterate); function arrayIterator() { @@ -6295,14 +6380,22 @@ } function symbolIterator() { - if ((item = iter.next()).done === false) { + item = iter.next(); + if (item.done === false) { iterator(item.value, createCallback(started++)); + } else if (completed >= collection.size && iterator !== noop) { + iterator = noop; + callback(null, makeConcatResult(result)); } } function symbolIteratorWithKey() { - if ((item = iter.next()).done === false) { + item = iter.next(); + if (item.done === false) { iterator(item.value, started, createCallback(started++)); + } else if (completed >= collection.size && iterator !== noop) { + iterator = noop; + callback(null, makeConcatResult(result)); } } @@ -6383,8 +6476,8 @@ arrayEach(collection, iterator, createCallback); } else if (!collection) { } else if (iteratorSymbol && collection[iteratorSymbol]) { - size = collection.size; - symbolEach(collection, iterator, createCallback); + size = symbolEach(collection, iterator, createCallback); + size && size === completed && callback(null, result); } else if (typeof collection === obj) { var keys = nativeKeys(collection); size = keys.length; @@ -6408,7 +6501,7 @@ } var array = result[key]; if (!array) { - array = result[key] = [value]; + result[key] = [value]; } else { array.push(value); } @@ -6493,7 +6586,7 @@ */ function groupBySeries(collection, iterator, callback) { callback = onlyOnce(callback || noop); - var size, key, value, keys, iter, iterate; + var size, key, value, keys, iter, item, iterate; var sync = false; var completed = 0; var result = {}; @@ -6503,7 +6596,7 @@ iterate = iterator.length === 3 ? arrayIteratorWithIndex : arrayIterator; } else if (!collection) { } else if (iteratorSymbol && collection[iteratorSymbol]) { - size = collection.size; + size = Infinity; iter = collection[iteratorSymbol](); iterate = iterator.length === 3 ? symbolIteratorWithKey : symbolIterator; } else if (typeof collection === obj) { @@ -6527,13 +6620,15 @@ } function symbolIterator() { - value = iter.next().value; - iterator(value, done); + item = iter.next(); + value = item.value; + item.done ? callback(null, result) : iterator(value, done); } function symbolIteratorWithKey() { - value = iter.next().value; - iterator(value, completed, done); + item = iter.next(); + value = item.value; + item.done ? callback(null, result) : iterator(value, completed, done); } function objectIterator() { @@ -6556,7 +6651,7 @@ } var array = result[key]; if (!array) { - array = result[key] = [value]; + result[key] = [value]; } else { array.push(value); } @@ -6657,7 +6752,7 @@ iterate = iterator.length === 3 ? arrayIteratorWithIndex : arrayIterator; } else if (!collection) { } else if (iteratorSymbol && collection[iteratorSymbol]) { - size = collection.size; + size = Infinity; iter = collection[iteratorSymbol](); iterate = iterator.length === 3 ? symbolIteratorWithKey : symbolIterator; } else if (typeof collection === obj) { @@ -6686,16 +6781,24 @@ } function symbolIterator() { - if ((item = iter.next()).done === false) { + item = iter.next(); + if (item.done === false) { value = item.value; iterator(value, createCallback(value)); + } else if (completed >= collection.size && iterator !== noop) { + iterator = noop; + callback(null, result); } } function symbolIteratorWithKey() { - if ((item = iter.next()).done === false) { + item = iter.next(); + if (item.done === false) { value = item.value; iterator(value, started++, createCallback(value)); + } else if (completed >= collection.size && iterator !== noop) { + iterator = noop; + callback(null, result); } } @@ -9011,14 +9114,12 @@ * @return {Function} */ function reflectAll(tasks) { - var size, newTasks, keys; + var newTasks, keys; if (isArray(tasks)) { - size = tasks.length; - newTasks = Array(size); + newTasks = Array(tasks.length); arrayEachSync(tasks, iterate); } else if (tasks && typeof tasks === obj) { keys = nativeKeys(tasks); - size = keys.length; newTasks = {}; baseEachSync(tasks, iterate, keys); } diff --git a/dist/async.min.js b/dist/async.min.js index e54dda4a..36a35a77 100644 --- a/dist/async.min.js +++ b/dist/async.min.js @@ -1,77 +1,80 @@ -(function(N,O){"object"===typeof exports&&"undefined"!==typeof module?O(exports):"function"===typeof define&&define.amd?define(["exports"],O):N.async?O(N.neo_async=N.neo_async||{}):O(N.async=N.async||{})})(this,function(N){function O(a){var b=function(a){var b=I(arguments,1);setTimeout(function(){a.apply(null,b)})};Q="function"===typeof setImmediate?setImmediate:b;"object"===typeof process&&"function"===typeof process.nextTick?(C=/^v0.10/.test(process.version)?Q:process.nextTick,Z=/^v0/.test(process.version)? -Q:process.nextTick):Z=C=Q;!1===a&&(C=function(a){a()})}function G(a){for(var b=-1,c=a.length,d=Array(c);++b=d)return[];for(var e=Array(d);++cd[e]){var g=d[f]; -d[f]=d[e];d[e]=g}}if(!(e>c)){for(var k,e=a[a[b]>a[e]?b:e],f=b,g=c;f<=g;){for(k=f;f=k&&a[g]>=e;)g--;if(f>g)break;var r=a;k=d;var s=f++,h=g--,l=r[s];r[s]=r[h];r[h]=l;r=k[s];k[s]=k[h];k[h]=r}e=f;aa(a,b,e-1,d);aa(a,e,c,d)}}}function T(a){var b=[];P(a,function(a){a!==y&&(B(a)?U.apply(b,a):b.push(a))});return b}function ba(a,b,c){var d=-1,e=a.length;if(3===b.length)for(;++dc)return e(null,[]);A=Array(m); -K(c>m?m:c,w)}}function V(a,b,c){function d(){b(a[t],s)}function e(){b(a[t],t,s)}function f(){b(q.next().value,s)}function g(){p=q.next().value;b(p,t,s)}function k(){b(a[m[t]],s)}function r(){l=m[t];b(a[l],l,s)}function s(a,b){a?c(a):++t===h?(n=z,c(null)):!1===b?(n=z,c(null)):u?C(n):(u=!0,n());u=!1}c=E(c||y);var h,l,m,q,p,n,u=!1,t=0;B(a)?(h=a.length,n=3===b.length?e:d):a&&(x&&a[x]?(h=a.size,q=a[x](),n=3===b.length?g:f):"object"===typeof a&&(m=F(a),h=m.length,n=3===b.length?r:k));if(!h)return c(null); -n()}function W(a,b,c,d){function e(){wb)return d(null);K(b>l?l:b,t)}function ya(a,b,c){function d(){b(a[v],s)}function e(){b(a[v],v,s)}function f(){b(q.next().value,s)}function g(){p=q.next().value;b(p,v,s)}function k(){b(a[m[v]],s)}function r(){l=m[v];b(a[l],l,s)}function s(a,b){a?(u=z,c=E(c),c(a,G(n))):(n[v]=b,++v===h?(u=z,c(null,n),c=z):t?C(u):(t=!0,u()),t=!1)}c=c||y;var h,l,m,q,p,n,u,t=!1,v=0;B(a)?(h=a.length, -u=3===b.length?e:d):a&&(x&&a[x]?(h=a.size,q=a[x](),u=3===b.length?g:f):"object"===typeof a&&(m=F(a),h=m.length,u=3===b.length?r:k));if(!h)return c(null,[]);n=Array(h);u()}function za(a,b,c,d){return function(e,f,g){function k(a){var b=!1;return function(c,e){b&&z();b=!0;c?(g=H(g),g(c)):!!e===d?(g=H(g),g(null,a)):++h===r&&g(null)}}g=g||y;var r,s,h=0;B(e)?(r=e.length,a(e,f,k)):e&&(x&&e[x]?(r=e.size,c(e,f,k)):"object"===typeof e&&(s=F(e),r=s.length,b(e,f,k,s)));r||g(null)}}function Aa(a){return function(b, -c,d){function e(){q=b[v];c(q,h)}function f(){q=b[v];c(q,v,h)}function g(){q=n.next().value;c(q,h)}function k(){q=n.next().value;c(q,v,h)}function r(){q=b[p[v]];c(q,h)}function s(){m=p[v];q=b[m];c(q,m,h)}function h(b,c){b?d(b):!!c===a?(u=z,d(null,q)):++v===l?(u=z,d(null)):t?C(u):(t=!0,u());t=!1}d=E(d||y);var l,m,q,p,n,u,t=!1,v=0;B(b)?(l=b.length,u=3===c.length?f:e):b&&(x&&b[x]?(l=b.size,n=b[x](),u=3===c.length?k:g):"object"===typeof b&&(p=F(b),l=p.length,u=3===c.length?s:r));if(!l)return d(null);u()}} -function Ba(a){return function(b,c,d,e){function f(){q=J++;qc)return e(null);K(c>m?m:c,w)}}function Ca(a,b,c,d){return function(e,f,g){function k(a,b){return function(c,e){null===a&&z();c?(a=null,g=H(g),g(c,L(l))):(!!e===d&&(l[a]=b),a=null,++h===r&&g(null,l))}}g=g||y;var r,s,h=0,l={};B(e)?(r=e.length,a(e,f,k)):e&&(x&&e[x]?(r=e.size,c(e,f,k)):"object"===typeof e&&(s= -F(e),r=s.length,b(e,f,k,s)));if(!r)return g(null,{})}}function Da(a){return function(b,c,d){function e(){m=w;q=b[w];c(q,h)}function f(){m=w;q=b[w];c(q,w,h)}function g(){m=w;q=n.next().value;c(q,h)}function k(){m=w;q=n.next().value;c(q,m,h)}function r(){m=p[w];q=b[m];c(q,h)}function s(){m=p[w];q=b[m];c(q,m,h)}function h(b,c){b?d(b,v):(!!c===a&&(v[m]=q),++w===l?(u=z,d(null,v)):t?C(u):(t=!0,u()),t=!1)}d=E(d||y);var l,m,q,p,n,u,t=!1,v={},w=0;B(b)?(l=b.length,u=3===c.length?f:e):b&&(x&&b[x]?(l=b.size, -n=b[x](),u=3===c.length?k:g):"object"===typeof b&&(p=F(b),l=p.length,u=3===c.length?s:r));if(!l)return d(null,{});u()}}function Ea(a){return function(b,c,d,e){function f(){q=D++;qc)return e(null,{});K(c>m?m:c,w)}}function X(a,b,c,d){function e(b){c(b,a[t],h)}function f(b){c(b,a[t],t,h)}function g(){c(b,p.next().value,h)}function k(){c(b, -p.next().value,t,h)}function r(b){c(b,a[q[t]],h)}function s(b){m=q[t];c(b,a[m],m,h)}function h(a,b){a?d(a,b):++t===l?(c=z,d(null,b)):u?C(function(){n(b)}):(u=!0,n(b));u=!1}d=E(d||y);var l,m,q,p,n,u=!1,t=0;B(a)?(l=a.length,n=4===c.length?f:e):a&&(x&&a[x]?(l=a.size,p=a[x](),n=4===c.length?k:g):"object"===typeof a&&(q=F(a),l=q.length,n=4===c.length?s:r));if(!l)return d(null,b);n(b)}function Fa(a,b,c,d){function e(b){c(b,a[--s],r)}function f(b){c(b,a[--s],s,r)}function g(b){c(b,a[m[--s]],r)}function k(b){l= -m[--s];c(b,a[l],l,r)}function r(a,b){a?d(a,b):0===s?(u=z,d(null,b)):t?C(function(){u(b)}):(t=!0,u(b));t=!1}d=E(d||y);var s,h,l,m,q,p,n,u,t=!1;if(B(a))s=a.length,u=4===c.length?f:e;else if(a)if(x&&a[x]){s=a.size;n=Array(s);q=a[x]();for(h=-1;!1===(p=q.next()).done;)n[++h]=p.value;a=n;u=4===c.length?f:e}else"object"===typeof a&&(m=F(a),s=m.length,u=4===c.length?k:g);if(!s)return d(null,b);u(b)}function Ga(a,b,c){c=c||y;ha(a,b,function(a,b){if(a)return c(a);c(null,!!b)})}function Ha(a,b,c){c=c||y;ia(a, -b,function(a,b){if(a)return c(a);c(null,!!b)})}function Ia(a,b,c,d){d=d||y;ja(a,b,c,function(a,b){if(a)return d(a);d(null,!!b)})}function Ja(a,b){return B(a)?0===a.length?(b(null),!1):!0:(b(Error("First argument to waterfall must be an array of functions")),!1)}function ka(a,b,c){switch(b.length){case 0:case 1:return a(c);case 2:return a(b[1],c);case 3:return a(b[1],b[2],c);case 4:return a(b[1],b[2],b[3],c);case 5:return a(b[1],b[2],b[3],b[4],c);case 6:return a(b[1],b[2],b[3],b[4],b[5],c);default:return b= -I(b,1),b.push(c),a.apply(null,b)}}function Ka(a,b){function c(c,h){if(c)r=z,b=E(b),b(c);else if(++d===f){r=z;var l=b;b=z;2===arguments.length?l(c,h):l.apply(null,G(arguments))}else g=a[d],k=arguments,e?C(r):(e=!0,r()),e=!1}b=b||y;if(Ja(a,b)){var d=0,e=!1,f=a.length,g=a[d],k=[],r=function(){switch(g.length){case 0:try{c(null,g())}catch(a){c(a)}break;case 1:return g(c);case 2:return g(k[1],c);case 3:return g(k[1],k[2],c);case 4:return g(k[1],k[2],k[3],c);case 5:return g(k[1],k[2],k[3],k[4],c);default:return k= -I(k,1),k[g.length-1]=c,g.apply(null,k)}};r()}}function La(){var a=G(arguments);return function(){var b=this,c=G(arguments),d=c[c.length-1];"function"===typeof d?c.pop():d=y;X(a,c,function(a,c,d){a.push(function(a){var b=I(arguments,1);d(a,b)});c.apply(b,a)},function(a,c){c=B(c)?c:[c];c.unshift(a);d.apply(b,c)})}}function Ma(a){return function(b){var c=function(){var c=this,d=G(arguments),g=d.pop()||y;return a(b,function(a,b){a.apply(c,d.concat([b]))},g)};if(1c)throw Error("Concurrency must not be zero");var h=0,l=[],m,q,p={_tasks:new M,concurrency:c,payload:d,saturated:y,unsaturated:y,buffer:c/4,empty:y,drain:y,error:y,started:!1,paused:!1,push:function(a,b){f(a,b)},kill:function(){p.drain=y;p._tasks.empty()}, -unshift:function(a,b){f(a,b,!0)},remove:function(a){p._tasks.remove(a)},process:a?k:r,length:function(){return p._tasks.length},running:function(){return h},workersList:function(){return l},idle:function(){return 0===p.length()+h},pause:function(){p.paused=!0},resume:function(){!1!==p.paused&&(p.paused=!1,K(p.concurrency=arguments.length?f:I(arguments,1);if(a){r=g=0;s.length=0;var l=L(k);l[b]=f;b=null;var h=c;c=y;h(a,l)}else r--,g--,k[b]=f,e(b),b=null}function p(){0===--t&& -s.push([n,u,d])}var n,u;if(B(a)){var t=a.length-1;n=a[t];u=t;if(0===t)s.push([n,u,d]);else for(var v=-1;++v=arguments.length)return c(a,e);var f=G(arguments);return c.apply(null,f)}b(d)}function e(){b(f)}function f(a,b){if(++s===g||!a||r&&!r(a)){if(2>=arguments.length)return c(a,b);var d=G(arguments);return c.apply(null,d)}setTimeout(e,k(s))}var g,k,r,s=0;if(3>arguments.length&&"function"===typeof a)c=b||y,b=a,a=null,g=5;else switch(c=c||y,typeof a){case "object":"function"===typeof a.errorFilter&&(r=a.errorFilter);var h=a.interval;switch(typeof h){case "function":k=h;break;case "string":case "number":k= -(h=+h)?function(){return h}:function(){return 0}}g=+a.times||5;break;case "number":g=a||5;break;case "string":g=+a||5;break;default:throw Error("Invalid arguments for async.retry");}if("function"!==typeof b)throw Error("Invalid arguments for async.retry");k?b(f):b(d)}function Oa(a){return function(){var b=G(arguments),c=b.pop(),d;try{d=a.apply(this,b)}catch(e){return c(e)}d&&"function"===typeof d.then?d.then(function(a){try{c(null,a)}catch(b){C(Pa,b)}},function(a){a=a&&a.message?a:Error(a);try{c(a, -void 0)}catch(b){C(Pa,b)}}):c(null,d)}}function Pa(a){throw a;}function Qa(a){return function(){function b(a,b){if(a)return c(null,{error:a});2=arguments.length?c: -I(arguments,1),a=null,++r===f&&d(null,k))}}d=d||y;var f,g,k,r=0;B(c)?(f=c.length,k=Array(f),a(c,e)):c&&"object"===typeof c&&(g=F(c),f=g.length,k={},b(c,e,g));f||d(null,k)}}(function(a,b){for(var c=-1,d=a.length;++cb)return d(null,[]);t=Array(l);K(b>l?l:b,v)},mapValues:eb,mapValuesSeries:function(a,b,c){function d(){l=v;b(a[v],s)}function e(){l=v;b(a[v],v,s)}function f(){l=v;p=q.next().value;b(p,s)}function g(){l=v;p=q.next().value;b(p,v,s)}function k(){l=m[v];b(a[l],s)}function r(){l=m[v];b(a[l],l,s)}function s(a,b){a? -(n=z,c=E(c),c(a,L(t))):(t[l]=b,++v===h?(n=z,c(null,t),c=z):u?C(n):(u=!0,n()),u=!1)}c=c||y;var h,l,m,q,p,n,u=!1,t={},v=0;B(a)?(h=a.length,n=3===b.length?e:d):a&&(x&&a[x]?(h=a.size,q=a[x](),n=3===b.length?g:f):"object"===typeof a&&(m=F(a),h=m.length,n=3===b.length?r:k));if(!h)return c(null,t);n()},mapValuesLimit:function(a,b,c,d){function e(){m=A++;mb)return d(null,w);K(b>l?l:b,t)},filter:Sa,filterSeries:Ta, -filterLimit:Ua,select:Sa,selectSeries:Ta,selectLimit:Ua,reject:fb,rejectSeries:gb,rejectLimit:hb,detect:ha,detectSeries:ia,detectLimit:ja,find:ha,findSeries:ia,findLimit:ja,pick:ib,pickSeries:jb,pickLimit:kb,omit:lb,omitSeries:mb,omitLimit:nb,reduce:X,inject:X,foldl:X,reduceRight:Fa,foldr:Fa,transform:ob,transformSeries:function(a,b,c,d){function e(){c(u,a[v],h)}function f(){c(u,a[v],v,h)}function g(){c(u,p.next().value,h)}function k(){c(u,p.next().value,v,h)}function r(){c(u,a[q[v]],h)}function s(){m= -q[v];c(u,a[m],m,h)}function h(a,b){a?d(a,u):++v===l?(n=z,d(null,u)):!1===b?(n=z,d(null,u)):t?C(n):(t=!0,n());t=!1}3===arguments.length&&(d=c,c=b,b=void 0);d=E(d||y);var l,m,q,p,n,u,t=!1,v=0;B(a)?(l=a.length,u=void 0!==b?b:[],n=4===c.length?f:e):a&&(x&&a[x]?(l=a.size,p=a[x](),u=void 0!==b?b:{},n=4===c.length?k:g):"object"===typeof a&&(q=F(a),l=q.length,u=void 0!==b?b:{},n=4===c.length?s:r));if(!l)return d(null,void 0!==b?b:u||{});n()},transformLimit:function(a,b,c,d,e){function f(){q=z++;qb)return e(null,void 0!==c?c:w||{});K(b>m?m:b,v)},sortBy:pb,sortBySeries:function(a,b,c){function d(){m=a[w];b(m,s)}function e(){m=a[w];b(m,w,s)}function f(){m=p.next().value;n[w]=m;b(m,s)}function g(){m=p.next().value;n[w]=m;b(m,w,s)}function k(){m=a[q[w]];n[w]=m;b(m,s)}function r(){l=q[w];m=a[l];n[w]=m;b(m,l,s)} -function s(a,b){u[w]=b;a?c(a):++w===h?(t=z,c(null,$(n,u))):v?C(t):(v=!0,t());v=!1}c=E(c||y);var h,l,m,q,p,n,u,t,v=!1,w=0;B(a)?(h=a.length,n=a,u=Array(h),t=3===b.length?e:d):a&&(x&&a[x]?(h=a.size,n=Array(h),u=Array(h),p=a[x](),t=3===b.length?g:f):"object"===typeof a&&(q=F(a),h=q.length,n=Array(h),u=Array(h),t=3===b.length?r:k));if(!h)return c(null,[]);t()},sortByLimit:function(a,b,c,d){function e(){Db)return d(null,[]);w=Array(l);K(b>l?l:b,A)},some:Ga,someSeries:Ha,someLimit:Ia,any:Ga,anySeries:Ha,anyLimit:Ia,every:Va,everySeries:Wa,everyLimit:Xa,all:Va,allSeries:Wa,allLimit:Xa,concat:qb,concatSeries:function(a,b,c){function d(){b(a[v],s)}function e(){b(a[v],v,s)}function f(){b(q.next().value,s)}function g(){p=q.next().value;b(p,v,s)}function k(){b(a[m[v]],s)}function r(){l=m[v];b(a[l],l,s)}function s(a,b){B(b)?U.apply(t,b): -2<=arguments.length&&U.apply(t,I(arguments,1));a?c(a,t):++v===h?(n=z,c(null,t)):u?C(n):(u=!0,n());u=!1}c=E(c||y);var h,l,m,q,p,n,u=!1,t=[],v=0;B(a)?(h=a.length,n=3===b.length?e:d):a&&(x&&a[x]?(h=a.size,q=a[x](),n=3===b.length?g:f):"object"===typeof a&&(m=F(a),h=m.length,n=3===b.length?r:k));if(!h)return c(null,t);n()},concatLimit:function(a,b,c,d){function e(){tb)return d(null,[]);var A=Array(l);K(b>l?l:b,n)},groupBy:rb,groupBySeries:function(a,b,c){function d(){m=a[t];b(m,s)}function e(){m=a[t];b(m,t,s)}function f(){m=p.next().value;b(m,s)}function g(){m=p.next().value;b(m,t,s)}function k(){m=a[q[t]];b(m,s)}function r(){l=q[t];m=a[l];b(m,l,s)}function s(a,b){if(a)n=z,c=E(c),c(a,L(v));else{var d=v[b];d?d.push(m):v[b]=[m];++t===h?(n=z,c(null,v)):u? -C(n):(u=!0,n());u=!1}}c=E(c||y);var h,l,m,q,p,n,u=!1,t=0,v={};B(a)?(h=a.length,n=3===b.length?e:d):a&&(x&&a[x]?(h=a.size,p=a[x](),n=3===b.length?g:f):"object"===typeof a&&(q=F(a),h=q.length,n=3===b.length?r:k));if(!h)return c(null,v);n()},groupByLimit:function(a,b,c,d){function e(){Ab)return d(null,D);K(b>l?l:b,v)},parallel:sb,series:function(a,b){function c(){g= -l;a[l](e)}function d(){g=k[l];a[g](e)}function e(a,c){a?(s=z,b=E(b),b(a,r)):(r[g]=2>=arguments.length?c:I(arguments,1),++l===f?(s=z,b(null,r)):h?C(s):(h=!0,s()),h=!1)}b=b||y;var f,g,k,r,s,h=!1,l=0;if(B(a))f=a.length,r=Array(f),s=c;else if(a&&"object"===typeof a)k=F(a),f=k.length,r={},s=d;else return b(null);if(!f)return b(null,r);s()},parallelLimit:function(a,b,c){function d(){k=q++;if(k=arguments.length?d:I(arguments,1),a=null,++p===g?c(null,h):m?C(l):(m=!0,l()),m=!1)}}c=c||y;var g,k,r,s,h,l,m=!1,q=0,p=0;B(a)?(g=a.length,h=Array(g),l=d):a&&"object"===typeof a&&(s=F(a),g=s.length,h={},l=e);if(!g||isNaN(b)||1>b)return c(null,h);K(b>g?g:b,l)},tryEach:function(a,b){function c(){a[r](e)}function d(){a[g[r]](e)}function e(a,c){a?++r===f?b(a):k():2>=arguments.length?b(null,c):b(null,I(arguments,1))}b=b||y;var f,g,k,r=0;B(a)?(f=a.length,k=c):a&&"object"===typeof a&& -(g=F(a),f=g.length,k=d);if(!f)return b(null);k()},waterfall:function(a,b){function c(){ka(e,f,d(e))}function d(h){return function(l,m){void 0===h&&(b=y,z());h=void 0;l?(g=b,b=z,g(l)):++r===s?(g=b,b=z,2>=arguments.length?g(l,m):g.apply(null,G(arguments))):(k?(f=arguments,e=a[r]||z,C(c)):(k=!0,ka(a[r]||z,arguments,d(r))),k=!1)}}b=b||y;if(Ja(a,b)){var e,f,g,k,r=0,s=a.length;ka(a[0],[],d(0))}},angelFall:Ka,angelfall:Ka,whilst:function(a,b,c){function d(){g?C(e):(g=!0,b(f));g=!1}function e(){b(f)}function f(b, -e){if(b)return c(b);2>=arguments.length?a(e)?d():c(null,e):(e=I(arguments,1),a.apply(null,e)?d():c.apply(null,[null].concat(e)))}c=c||y;var g=!1;a()?d():c(null)},doWhilst:function(a,b,c){function d(){g?C(e):(g=!0,a(f));g=!1}function e(){a(f)}function f(a,e){if(a)return c(a);2>=arguments.length?b(e)?d():c(null,e):(e=I(arguments,1),b.apply(null,e)?d():c.apply(null,[null].concat(e)))}c=c||y;var g=!1;e()},until:function(a,b,c){function d(){g?C(e):(g=!0,b(f));g=!1}function e(){b(f)}function f(b,e){if(b)return c(b); -2>=arguments.length?a(e)?c(null,e):d():(e=I(arguments,1),a.apply(null,e)?c.apply(null,[null].concat(e)):d())}c=c||y;var g=!1;a()?c(null):d()},doUntil:function(a,b,c){function d(){g?C(e):(g=!0,a(f));g=!1}function e(){a(f)}function f(a,e){if(a)return c(a);2>=arguments.length?b(e)?c(null,e):d():(e=I(arguments,1),b.apply(null,e)?c.apply(null,[null].concat(e)):d())}c=c||y;var g=!1;e()},during:function(a,b,c){function d(a,d){if(a)return c(a);d?b(e):c(null)}function e(b){if(b)return c(b);a(d)}c=c||y;a(d)}, -doDuring:function(a,b,c){function d(b,d){if(b)return c(b);d?a(e):c(null)}function e(a,e){if(a)return c(a);switch(arguments.length){case 0:case 1:b(d);break;case 2:b(e,d);break;default:var k=I(arguments,1);k.push(d);b.apply(null,k)}}c=c||y;d(null,!0)},forever:function(a,b){function c(){a(d)}function d(a){if(a){if(b)return b(a);throw a;}e?C(c):(e=!0,c());e=!1}var e=!1;c()},compose:function(){return La.apply(null,Ya(arguments))},seq:La,applyEach:tb,applyEachSeries:ub,queue:function(a,b){return la(!0, -a,b)},priorityQueue:function(a,b){var c=la(!0,a,b);c.push=function(a,b,f){c.started=!0;b=b||0;var g=B(a)?a:[a],k=g.length;if(void 0===a||0===k)c.idle()&&C(c.drain);else{f="function"===typeof f?f:y;for(a=c._tasks.head;a&&b>=a.priority;)a=a.next;for(;k--;){var r={data:g[k],priority:b,callback:f};a?c._tasks.insertBefore(a,r):c._tasks.push(r);C(c.process)}}};delete c.unshift;return c},cargo:function(a,b){return la(!1,a,1,b)},auto:Na,autoInject:function(a,b,c){var d={};S(a,function(a,b){var c,k=a.length; -if(B(a)){if(0===k)throw Error("autoInject task functions require explicit parameters.");c=G(a);k=c.length-1;a=c[k];if(0===k){d[b]=a;return}}else{if(1===k){d[b]=a;return}c=$a(a);if(0===k&&0===c.length)throw Error("autoInject task functions require explicit parameters.");k=c.length-1}c[k]=function(b,d){switch(k){case 1:a(b[c[0]],d);break;case 2:a(b[c[0]],b[c[1]],d);break;case 3:a(b[c[0]],b[c[1]],b[c[2]],d);break;default:for(var f=-1;++fa)return c(null,[]);var e=Array(a);K(a,function(a){b(a,d(a))})},timesSeries:function(a,b,c){function d(){b(k,e)}function e(b,e){f[k]=e;b?(c(b),c=z):++k>=a?(c(null,f),c=z):g?C(d):(g=!0,d());g=!1}c=c||y;a=+a;if(isNaN(a)||1>a)return c(null,[]);var f=Array(a),g=!1,k=0;d()},timesLimit:function(a,b,c,d){function e(){var b= -r++;b=a?(d(null,g),d=z):k?C(e):(k=!0,e());k=!1}}d=d||y;a=+a;if(isNaN(a)||1>a||isNaN(b)||1>b)return d(null,[]);var g=Array(a),k=!1,r=0,s=0;K(b>a?a:b,e)},race:function(a,b){b=H(b||y);var c,d,e=-1;if(B(a))for(c=a.length;++e=d)return[];for(var e=Array(d);++bd[e]){var g=d[f]; +d[f]=d[e];d[e]=g}}if(!(e>b)){for(var l,e=a[a[c]>a[e]?c:e],f=c,g=b;f<=g;){for(l=f;f=l&&a[g]>=e;)g--;if(f>g)break;var q=a;l=d;var s=f++,h=g--,k=q[s];q[s]=q[h];q[h]=k;q=l[s];l[s]=l[h];l[h]=q}e=f;ca(a,c,e-1,d);ca(a,e,b,d)}}}function S(a){var c=[];Q(a,function(a){a!==w&&(C(a)?X.apply(c,a):c.push(a))});return c}function da(a,c,b){var d=-1,e=a.length;if(3===c.length)for(;++d=c.size&&d!==w&&(d=w,e(null,U(y)))}function q(){v=t.next();!1===v.done?(p=v.value,d(p,B,k(p,B++))):R>=c.size&&d!==w&&(d=w,e(null,U(y)))}function s(){r=B++;rb)return e(null,[]);y=y||Array(m);K(b>m?m:b,x)}}function Y(a,c,b){function d(){c(a[t],s)}function e(){c(a[t],t,s)}function f(){n=r.next();n.done?b(null):c(n.value,s)}function g(){n=r.next();n.done?b(null):c(n.value,t,s)}function l(){c(a[m[t]],s)}function q(){k=m[t];c(a[k],k,s)}function s(a,d){a?b(a):++t===h||!1===d?(p=A,b(null)): +u?D(p):(u=!0,p());u=!1}b=E(b||w);var h,k,m,r,n,p,u=!1,t=0;C(a)?(h=a.length,p=3===c.length?e:d):a&&(z&&a[z]?(h=Infinity,r=a[z](),p=3===c.length?g:f):"object"===typeof a&&(m=F(a),h=m.length,p=3===c.length?q:l));if(!h)return b(null);p()}function Z(a,c,b,d){function e(){x=a.size&&b!==w&&(b=w,d(null))}function l(){u=p.next();!1===u.done?b(u.value,x++,h):y>=a.size&&b!==w&&(b=w,d(null))}function q(){x< +k&&b(a[n[x++]],h)}function s(){m=x++;mc)return d(null);K(c>k?k:c,t)}function za(a,c,b){function d(){c(a[v],s)}function e(){c(a[v],v,s)}function f(){n= +r.next();n.done?b(null,p):c(n.value,s)}function g(){n=r.next();n.done?b(null,p):c(n.value,v,s)}function l(){c(a[m[v]],s)}function q(){k=m[v];c(a[k],k,s)}function s(a,d){a?(u=A,b=E(b),b(a,H(p))):(p[v]=d,++v===h?(u=A,b(null,p),b=A):t?D(u):(t=!0,u()),t=!1)}b=b||w;var h,k,m,r,n,p,u,t=!1,v=0;C(a)?(h=a.length,u=3===c.length?e:d):a&&(z&&a[z]?(h=Infinity,p=[],r=a[z](),u=3===c.length?g:f):"object"===typeof a&&(m=F(a),h=m.length,u=3===c.length?q:l));if(!h)return b(null,[]);p=p||Array(h);u()}function Aa(a,c, +b,d){return function(e,f,g){function l(a){var b=!1;return function(c,e){b&&A();b=!0;c?(g=I(g),g(c)):!!e===d?(g=I(g),g(null,a)):++h===q&&g(null)}}g=g||w;var q,s,h=0;C(e)?(q=e.length,a(e,f,l)):e&&(z&&e[z]?(q=b(e,f,l))&&q===h&&g(null):"object"===typeof e&&(s=F(e),q=s.length,c(e,f,l,s)));q||g(null)}}function Ba(a){return function(c,b,d){function e(){r=c[x];b(r,h)}function f(){r=c[x];b(r,x,h)}function g(){u=p.next();r=u.value;u.done?d(null):b(r,h)}function l(){u=p.next();r=u.value;u.done?d(null):b(r,x, +h)}function q(){r=c[n[x]];b(r,h)}function s(){m=n[x];r=c[m];b(r,m,h)}function h(b,c){b?d(b):!!c===a?(t=A,d(null,r)):++x===k?(t=A,d(null)):v?D(t):(v=!0,t());v=!1}d=E(d||w);var k,m,r,n,p,u,t,v=!1,x=0;C(c)?(k=c.length,t=3===b.length?f:e):c&&(z&&c[z]?(k=Infinity,p=c[z](),t=3===b.length?l:g):"object"===typeof c&&(n=F(c),k=n.length,t=3===b.length?s:q));if(!k)return d(null);t()}}function Ca(a){return function(c,b,d,e){function f(){r=G++;r=c.size&&d!==w&&(d=w,e(null))}function q(){v=t.next();!1===v.done?(p=v.value,d(p,G++,k(p))):B>=c.size&&d!==w&&(d=w,e(null))}function s(){r=G++;rb)return e(null);K(b>m?m:b,x)}}function Da(a,c,b,d){return function(e,f,g){function l(a,b){return function(c,e){null===a&&A();c?(a=null,g=I(g),g(c,L(k))):(!!e===d&&(k[a]=b),a=null,++h===q&&g(null,k))}}g=g||w;var q,s,h=0,k={};C(e)?(q=e.length,a(e,f,l)):e&&(z&&e[z]?(q=b(e,f,l))&&q===h&&g(null,k):"object"===typeof e&&(s=F(e),q=s.length,c(e,f,l,s)));if(!q)return g(null, +{})}}function Ea(a){return function(c,b,d){function e(){m=y;r=c[y];b(r,h)}function f(){m=y;r=c[y];b(r,y,h)}function g(){m=y;u=p.next();r=u.value;u.done?d(null,x):b(r,h)}function l(){m=y;u=p.next();r=u.value;u.done?d(null,x):b(r,m,h)}function q(){m=n[y];r=c[m];b(r,h)}function s(){m=n[y];r=c[m];b(r,m,h)}function h(b,c){b?d(b,x):(!!c===a&&(x[m]=r),++y===k?(t=A,d(null,x)):v?D(t):(v=!0,t()),v=!1)}d=E(d||w);var k,m,r,n,p,u,t,v=!1,x={},y=0;C(c)?(k=c.length,t=3===b.length?f:e):c&&(z&&c[z]?(k=Infinity,p=c[z](), +t=3===b.length?l:g):"object"===typeof c&&(n=F(c),k=n.length,t=3===b.length?s:q));if(!k)return d(null,{});t()}}function Fa(a){return function(c,b,d,e){function f(){r=B++;r=c.size&&d!==w&&(d=w,e(null,G))}function q(){v=t.next();!1===v.done?(p=v.value,d(p,B,k(p,B++))):R>=c.size&&d!==w&&(d=w,e(null,G))}function s(){Bb)return e(null,{});K(b>m?m:b,x)}}function $(a,c,b,d){function e(d){b(d,a[t],h)}function f(d){b(d, +a[t],t,h)}function g(){b(c,n.next().value,h)}function l(){b(c,n.next().value,t,h)}function q(d){b(d,a[r[t]],h)}function s(d){m=r[t];b(d,a[m],m,h)}function h(a,c){a?d(a,c):++t===k?(b=A,d(null,c)):u?D(function(){p(c)}):(u=!0,p(c));u=!1}d=E(d||w);var k,m,r,n,p,u=!1,t=0;C(a)?(k=a.length,p=4===b.length?f:e):a&&(z&&a[z]?(k=a.size,n=a[z](),p=4===b.length?l:g):"object"===typeof a&&(r=F(a),k=r.length,p=4===b.length?s:q));if(!k)return d(null,c);p(c)}function Ga(a,c,b,d){function e(d){b(d,a[--s],q)}function f(d){b(d, +a[--s],s,q)}function g(d){b(d,a[m[--s]],q)}function l(d){k=m[--s];b(d,a[k],k,q)}function q(a,b){a?d(a,b):0===s?(u=A,d(null,b)):t?D(function(){u(b)}):(t=!0,u(b));t=!1}d=E(d||w);var s,h,k,m,r,n,p,u,t=!1;if(C(a))s=a.length,u=4===b.length?f:e;else if(a)if(z&&a[z]){s=a.size;p=Array(s);r=a[z]();for(h=-1;!1===(n=r.next()).done;)p[++h]=n.value;a=p;u=4===b.length?f:e}else"object"===typeof a&&(m=F(a),s=m.length,u=4===b.length?l:g);if(!s)return d(null,c);u(c)}function Ha(a,c,b){b=b||w;ja(a,c,function(a,c){if(a)return b(a); +b(null,!!c)})}function Ia(a,c,b){b=b||w;ka(a,c,function(a,c){if(a)return b(a);b(null,!!c)})}function Ja(a,c,b,d){d=d||w;la(a,c,b,function(a,b){if(a)return d(a);d(null,!!b)})}function Ka(a,c){return C(a)?0===a.length?(c(null),!1):!0:(c(Error("First argument to waterfall must be an array of functions")),!1)}function ma(a,c,b){switch(c.length){case 0:case 1:return a(b);case 2:return a(c[1],b);case 3:return a(c[1],c[2],b);case 4:return a(c[1],c[2],c[3],b);case 5:return a(c[1],c[2],c[3],c[4],b);case 6:return a(c[1], +c[2],c[3],c[4],c[5],b);default:return c=J(c,1),c.push(b),a.apply(null,c)}}function La(a,c){function b(b,h){if(b)q=A,c=E(c),c(b);else if(++d===f){q=A;var k=c;c=A;2===arguments.length?k(b,h):k.apply(null,H(arguments))}else g=a[d],l=arguments,e?D(q):(e=!0,q()),e=!1}c=c||w;if(Ka(a,c)){var d=0,e=!1,f=a.length,g=a[d],l=[],q=function(){switch(g.length){case 0:try{b(null,g())}catch(a){b(a)}break;case 1:return g(b);case 2:return g(l[1],b);case 3:return g(l[1],l[2],b);case 4:return g(l[1],l[2],l[3],b);case 5:return g(l[1], +l[2],l[3],l[4],b);default:return l=J(l,1),l[g.length-1]=b,g.apply(null,l)}};q()}}function Ma(){var a=H(arguments);return function(){var c=this,b=H(arguments),d=b[b.length-1];"function"===typeof d?b.pop():d=w;$(a,b,function(a,b,d){a.push(function(a){var b=J(arguments,1);d(a,b)});b.apply(c,a)},function(a,b){b=C(b)?b:[b];b.unshift(a);d.apply(c,b)})}}function Na(a){return function(c){var b=function(){var b=this,d=H(arguments),g=d.pop()||w;return a(c,function(a,c){a.apply(b,d.concat([c]))},g)};if(1b)throw Error("Concurrency must not be zero");var h=0,k=[],m,r,n={_tasks:new M,concurrency:b,payload:d,saturated:w,unsaturated:w,buffer:b/4,empty:w,drain:w,error:w,started:!1,paused:!1,push:function(a,b){f(a,b)},kill:function(){n.drain= +w;n._tasks.empty()},unshift:function(a,b){f(a,b,!0)},remove:function(a){n._tasks.remove(a)},process:a?l:q,length:function(){return n._tasks.length},running:function(){return h},workersList:function(){return k},idle:function(){return 0===n.length()+h},pause:function(){n.paused=!0},resume:function(){!1!==n.paused&&(n.paused=!1,K(n.concurrency=arguments.length?f:J(arguments,1);if(a){q=g=0;s.length=0;var k=L(l);k[d]=f;d=null;var h=b;b=w;h(a,k)}else q--,g--,l[d]=f,e(d),d=null}function n(){0===--t&& +s.push([p,u,c])}var p,u;if(C(a)){var t=a.length-1;p=a[t];u=t;if(0===t)s.push([p,u,c]);else for(var v=-1;++v=arguments.length)return b(a,e);var f=H(arguments);return b.apply(null,f)}c(d)}function e(){c(f)}function f(a,d){if(++s===g||!a||q&&!q(a)){if(2>=arguments.length)return b(a,d);var c=H(arguments);return b.apply(null,c)}setTimeout(e,l(s))}var g,l,q,s=0;if(3>arguments.length&&"function"===typeof a)b=c||w,c=a,a=null,g=5;else switch(b=b||w,typeof a){case "object":"function"===typeof a.errorFilter&&(q=a.errorFilter);var h=a.interval;switch(typeof h){case "function":l=h;break;case "string":case "number":l= +(h=+h)?function(){return h}:function(){return 0}}g=+a.times||5;break;case "number":g=a||5;break;case "string":g=+a||5;break;default:throw Error("Invalid arguments for async.retry");}if("function"!==typeof c)throw Error("Invalid arguments for async.retry");l?c(f):c(d)}function Pa(a){return function(){var c=H(arguments),b=c.pop(),d;try{d=a.apply(this,c)}catch(e){return b(e)}d&&"function"===typeof d.then?d.then(function(a){try{b(null,a)}catch(d){D(Qa,d)}},function(a){a=a&&a.message?a:Error(a);try{b(a, +void 0)}catch(d){D(Qa,d)}}):b(null,d)}}function Qa(a){throw a;}function Ra(a){return function(){function c(a,d){if(a)return b(null,{error:a});2=arguments.length?c:J(arguments,1),a=null,++q===f&&d(null,l))}}d=d||w;var f,g,l,q=0;C(b)?(f=b.length,l=Array(f),a(b,e)):b&&"object"===typeof b&&(g=F(b),f=g.length,l={},c(b,e,g));f||d(null,l)}}(function(a,c){for(var b=-1,d=a.length;++b=a.size&&b!==w&&(b=w,d(null,t))}function l(){u=p.next();!1===u.done?b(u.value,y,h(y++)):G>=a.size&&b!==w&&(b=w,d(null,t))}function q(){m=y++;mc)return d(null,[]);t=t||Array(k);K(c>k?k:c,v)},mapValues:fb,mapValuesSeries:function(a,c,b){function d(){k=v;c(a[v],s)}function e(){k=v;c(a[v],v,s)}function f(){k=v;n=r.next(); +n.done?b(null,t):c(n.value,s)}function g(){k=v;n=r.next();n.done?b(null,t):c(n.value,v,s)}function l(){k=m[v];c(a[k],s)}function q(){k=m[v];c(a[k],k,s)}function s(a,d){a?(p=A,b=E(b),b(a,L(t))):(t[k]=d,++v===h?(p=A,b(null,t),b=A):u?D(p):(u=!0,p()),u=!1)}b=b||w;var h,k,m,r,n,p,u=!1,t={},v=0;C(a)?(h=a.length,p=3===c.length?e:d):a&&(z&&a[z]?(h=Infinity,r=a[z](),p=3===c.length?g:f):"object"===typeof a&&(m=F(a),h=m.length,p=3===c.length?q:l));if(!h)return b(null,t);p()},mapValuesLimit:function(a,c,b,d){function e(){m= +y++;m=a.size&&b!==w&&(b=w,d(null,x))}function l(){u=p.next();!1===u.done?b(u.value,y,h(y++)):G>=a.size&&b!==w&&(b=w,d(null,x))}function q(){m=y++;mc)return d(null,x);K(c>k?k:c,t)},filter:Ta,filterSeries:Ua,filterLimit:Va,select:Ta,selectSeries:Ua,selectLimit:Va,reject:gb,rejectSeries:hb,rejectLimit:ib,detect:ja,detectSeries:ka,detectLimit:la,find:ja,findSeries:ka,findLimit:la,pick:jb,pickSeries:kb,pickLimit:lb,omit:mb,omitSeries:nb,omitLimit:ob,reduce:$,inject:$, +foldl:$,reduceRight:Ga,foldr:Ga,transform:pb,transformSeries:function(a,c,b,d){function e(){b(t,a[x],h)}function f(){b(t,a[x],x,h)}function g(){p=n.next();p.done?d(null,t):b(t,p.value,h)}function l(){p=n.next();p.done?d(null,t):b(t,p.value,x,h)}function q(){b(t,a[r[x]],h)}function s(){m=r[x];b(t,a[m],m,h)}function h(a,b){a?d(a,t):++x===k||!1===b?(u=A,d(null,t)):v?D(u):(v=!0,u());v=!1}3===arguments.length&&(d=b,b=c,c=void 0);d=E(d||w);var k,m,r,n,p,u,t,v=!1,x=0;C(a)?(k=a.length,t=void 0!==c?c:[],u= +4===b.length?f:e):a&&(z&&a[z]?(k=a.size,n=a[z](),t=void 0!==c?c:{},u=4===b.length?l:g):"object"===typeof a&&(r=F(a),k=r.length,t=void 0!==c?c:{},u=4===b.length?s:q));if(!k)return d(null,void 0!==c?c:t||{});u()},transformLimit:function(a,c,b,d,e){function f(){r=A++;r=a.size&&d!==w&&(d=w,e(null,x))}function q(){t=u.next();!1===t.done?d(x,t.value,A++,E(k)):B>=a.size&&d!==w&&(d=w,e(null, +x))}function s(){r=A++;rc)return e(null,void 0!==b?b:x||{});K(c>m?m:c,v)},sortBy:qb,sortBySeries:function(a,c,b){function d(){m=a[y];c(m,s)}function e(){m=a[y];c(m,y,s)}function f(){p=n.next();if(p.done)return b(null,P(u,t));m=p.value;u[y]=m;c(m,s)}function g(){p=n.next();if(p.done)return b(null,P(u,t));m=p.value;u[y]=m;c(m,y,s)}function l(){m=a[r[y]];u[y]=m;c(m,s)}function q(){k=r[y];m=a[k];u[y]=m;c(m,k,s)}function s(a,d){t[y]=d;a?b(a):++y===h?(v=A,b(null,P(u,t))):x?D(v):(x=!0,v());x=!1}b=E(b||w);var h,k,m,r,n,p,u,t, +v,x=!1,y=0;C(a)?(h=a.length,u=a,t=Array(h),v=3===c.length?e:d):a&&(z&&a[z]?(h=Infinity,u=[],t=[],n=a[z](),v=3===c.length?g:f):"object"===typeof a&&(r=F(a),h=r.length,u=Array(h),t=Array(h),v=3===c.length?q:l));if(!h)return b(null,[]);v()},sortByLimit:function(a,c,b,d){function e(){B=a.size&&b!==w&&(b=w,d(null,P(p,x)))}function l(){v=t.next();!1===v.done?(n= +v.value,p[B]=n,b(n,B,h(n,B++))):E>=a.size&&b!==w&&(b=w,d(null,P(p,x)))}function q(){Bc)return d(null,[]);x=x||Array(k);K(c>k?k:c,y)},some:Ha,someSeries:Ia,someLimit:Ja,any:Ha,anySeries:Ia,anyLimit:Ja,every:Wa,everySeries:Xa,everyLimit:Ya,all:Wa,allSeries:Xa,allLimit:Ya,concat:rb,concatSeries:function(a,c,b){function d(){c(a[v],s)}function e(){c(a[v],v,s)}function f(){n=r.next();n.done?b(null,t):c(n.value,s)}function g(){n=r.next();n.done?b(null,t):c(n.value,v,s)}function l(){c(a[m[v]],s)}function q(){k=m[v];c(a[k],k,s)}function s(a,d){C(d)? +X.apply(t,d):2<=arguments.length&&X.apply(t,J(arguments,1));a?b(a,t):++v===h?(p=A,b(null,t)):u?D(p):(u=!0,p());u=!1}b=E(b||w);var h,k,m,r,n,p,u=!1,t=[],v=0;C(a)?(h=a.length,p=3===c.length?e:d):a&&(z&&a[z]?(h=Infinity,r=a[z](),p=3===c.length?g:f):"object"===typeof a&&(m=F(a),h=m.length,p=3===c.length?q:l));if(!h)return b(null,t);p()},concatLimit:function(a,c,b,d){function e(){v=a.size&&b!== +w&&(b=w,d(null,S(u)))}function l(){n=r.next();!1===n.done?b(n.value,v,h(v++)):x>=a.size&&b!==w&&(b=w,d(null,S(u)))}function q(){vc)return d(null,[]);u=u||Array(k);K(c>k?k:c,p)},groupBy:sb,groupBySeries:function(a,c,b){function d(){m=a[v];c(m,s)}function e(){m=a[v];c(m,v,s)}function f(){p=n.next();m=p.value;p.done?b(null,x):c(m,s)}function g(){p=n.next();m=p.value;p.done?b(null,x):c(m,v,s)}function l(){m=a[r[v]];c(m, +s)}function q(){k=r[v];m=a[k];c(m,k,s)}function s(a,d){if(a)u=A,b=E(b),b(a,L(x));else{var c=x[d];c?c.push(m):x[d]=[m];++v===h?(u=A,b(null,x)):t?D(u):(t=!0,u());t=!1}}b=E(b||w);var h,k,m,r,n,p,u,t=!1,v=0,x={};C(a)?(h=a.length,u=3===c.length?e:d):a&&(z&&a[z]?(h=Infinity,n=a[z](),u=3===c.length?g:f):"object"===typeof a&&(r=F(a),h=r.length,u=3===c.length?q:l));if(!h)return b(null,x);u()},groupByLimit:function(a,c,b,d){function e(){y=a.size&&b!==w&&(b=w,d(null,B))}function l(){t=u.next();!1===t.done?(n=t.value,b(n,y++,h(n))):E>=a.size&&b!==w&&(b=w,d(null,B))}function q(){yc)return d(null,B);K(c>k?k:c,v)},parallel:tb,series:function(a,c){function b(){g=k;a[k](e)}function d(){g=l[k];a[g](e)}function e(a,b){a?(s=A,c=E(c),c(a,q)):(q[g]=2>=arguments.length?b:J(arguments,1),++k===f?(s=A,c(null,q)):h?D(s):(h=!0,s()),h=!1)}c=c||w;var f,g,l,q,s,h=!1,k=0;if(C(a))f=a.length,q=Array(f),s=b;else if(a&&"object"===typeof a)l=F(a), +f=l.length,q={},s=d;else return c(null);if(!f)return c(null,q);s()},parallelLimit:function(a,c,b){function d(){l=r++;if(l=arguments.length?c:J(arguments,1),a=null,++n===g?b(null,h):m?D(k):(m=!0,k()),m=!1)}}b=b||w;var g,l,q,s,h,k,m=!1,r=0,n=0;C(a)?(g=a.length,h=Array(g),k=d):a&&"object"===typeof a&&(s=F(a),g=s.length,h={},k=e);if(!g||isNaN(c)||1>c)return b(null, +h);K(c>g?g:c,k)},tryEach:function(a,c){function b(){a[q](e)}function d(){a[g[q]](e)}function e(a,b){a?++q===f?c(a):l():2>=arguments.length?c(null,b):c(null,J(arguments,1))}c=c||w;var f,g,l,q=0;C(a)?(f=a.length,l=b):a&&"object"===typeof a&&(g=F(a),f=g.length,l=d);if(!f)return c(null);l()},waterfall:function(a,c){function b(){ma(e,f,d(e))}function d(h){return function(k,m){void 0===h&&(c=w,A());h=void 0;k?(g=c,c=A,g(k)):++q===s?(g=c,c=A,2>=arguments.length?g(k,m):g.apply(null,H(arguments))):(l?(f=arguments, +e=a[q]||A,D(b)):(l=!0,ma(a[q]||A,arguments,d(q))),l=!1)}}c=c||w;if(Ka(a,c)){var e,f,g,l,q=0,s=a.length;ma(a[0],[],d(0))}},angelFall:La,angelfall:La,whilst:function(a,c,b){function d(){g?D(e):(g=!0,c(f));g=!1}function e(){c(f)}function f(c,e){if(c)return b(c);2>=arguments.length?a(e)?d():b(null,e):(e=J(arguments,1),a.apply(null,e)?d():b.apply(null,[null].concat(e)))}b=b||w;var g=!1;a()?d():b(null)},doWhilst:function(a,c,b){function d(){g?D(e):(g=!0,a(f));g=!1}function e(){a(f)}function f(a,e){if(a)return b(a); +2>=arguments.length?c(e)?d():b(null,e):(e=J(arguments,1),c.apply(null,e)?d():b.apply(null,[null].concat(e)))}b=b||w;var g=!1;e()},until:function(a,c,b){function d(){g?D(e):(g=!0,c(f));g=!1}function e(){c(f)}function f(c,e){if(c)return b(c);2>=arguments.length?a(e)?b(null,e):d():(e=J(arguments,1),a.apply(null,e)?b.apply(null,[null].concat(e)):d())}b=b||w;var g=!1;a()?b(null):d()},doUntil:function(a,c,b){function d(){g?D(e):(g=!0,a(f));g=!1}function e(){a(f)}function f(a,e){if(a)return b(a);2>=arguments.length? +c(e)?b(null,e):d():(e=J(arguments,1),c.apply(null,e)?b.apply(null,[null].concat(e)):d())}b=b||w;var g=!1;e()},during:function(a,c,b){function d(a,d){if(a)return b(a);d?c(e):b(null)}function e(c){if(c)return b(c);a(d)}b=b||w;a(d)},doDuring:function(a,c,b){function d(d,c){if(d)return b(d);c?a(e):b(null)}function e(a,e){if(a)return b(a);switch(arguments.length){case 0:case 1:c(d);break;case 2:c(e,d);break;default:var l=J(arguments,1);l.push(d);c.apply(null,l)}}b=b||w;d(null,!0)},forever:function(a,c){function b(){a(d)} +function d(a){if(a){if(c)return c(a);throw a;}e?D(b):(e=!0,b());e=!1}var e=!1;b()},compose:function(){return Ma.apply(null,Za(arguments))},seq:Ma,applyEach:ub,applyEachSeries:vb,queue:function(a,c){return na(!0,a,c)},priorityQueue:function(a,c){var b=na(!0,a,c);b.push=function(a,c,f){b.started=!0;c=c||0;var g=C(a)?a:[a],l=g.length;if(void 0===a||0===l)b.idle()&&D(b.drain);else{f="function"===typeof f?f:w;for(a=b._tasks.head;a&&c>=a.priority;)a=a.next;for(;l--;){var q={data:g[l],priority:c,callback:f}; +a?b._tasks.insertBefore(a,q):b._tasks.push(q);D(b.process)}}};delete b.unshift;return b},cargo:function(a,c){return na(!1,a,1,c)},auto:Oa,autoInject:function(a,c,b){var d={};W(a,function(a,b){var c,l=a.length;if(C(a)){if(0===l)throw Error("autoInject task functions require explicit parameters.");c=H(a);l=c.length-1;a=c[l];if(0===l){d[b]=a;return}}else{if(1===l){d[b]=a;return}c=ab(a);if(0===l&&0===c.length)throw Error("autoInject task functions require explicit parameters.");l=c.length-1}c[l]=function(b, +d){switch(l){case 1:a(b[c[0]],d);break;case 2:a(b[c[0]],b[c[1]],d);break;case 3:a(b[c[0]],b[c[1]],b[c[2]],d);break;default:for(var f=-1;++fa)return b(null,[]);var e=Array(a);K(a,function(a){c(a,d(a))})},timesSeries:function(a,c,b){function d(){c(l,e)}function e(c, +e){f[l]=e;c?(b(c),b=A):++l>=a?(b(null,f),b=A):g?D(d):(g=!0,d());g=!1}b=b||w;a=+a;if(isNaN(a)||1>a)return b(null,[]);var f=Array(a),g=!1,l=0;d()},timesLimit:function(a,c,b,d){function e(){var c=q++;c=a?(d(null,g),d=A):l?D(e):(l=!0,e());l=!1}}d=d||w;a=+a;if(isNaN(a)||1>a||isNaN(c)||1>c)return d(null,[]);var g=Array(a),l=!1,q=0,s=0;K(c>a?a:c,e)},race:function(a,c){c=I(c||w);var b,d,e=-1;if(C(a))for(b=a.length;++e< +b;)a[e](c);else if(a&&"object"===typeof a)for(d=F(a),b=d.length;++e=d)return[];for(var e=Array(d);++cd[e]){var g=d[f]; -d[f]=d[e];d[e]=g}}if(!(e>c)){for(var k,e=a[a[b]>a[e]?b:e],f=b,g=c;f<=g;){for(k=f;f=k&&a[g]>=e;)g--;if(f>g)break;var r=a;k=d;var s=f++,h=g--,l=r[s];r[s]=r[h];r[h]=l;r=k[s];k[s]=k[h];k[h]=r}e=f;aa(a,b,e-1,d);aa(a,e,c,d)}}}function T(a){var b=[];P(a,function(a){a!==y&&(B(a)?U.apply(b,a):b.push(a))});return b}function ba(a,b,c){var d=-1,e=a.length;if(3===b.length)for(;++dc)return e(null,[]);A=Array(m); -K(c>m?m:c,w)}}function V(a,b,c){function d(){b(a[t],s)}function e(){b(a[t],t,s)}function f(){b(q.next().value,s)}function g(){p=q.next().value;b(p,t,s)}function k(){b(a[m[t]],s)}function r(){l=m[t];b(a[l],l,s)}function s(a,b){a?c(a):++t===h?(n=z,c(null)):!1===b?(n=z,c(null)):u?C(n):(u=!0,n());u=!1}c=E(c||y);var h,l,m,q,p,n,u=!1,t=0;B(a)?(h=a.length,n=3===b.length?e:d):a&&(x&&a[x]?(h=a.size,q=a[x](),n=3===b.length?g:f):"object"===typeof a&&(m=F(a),h=m.length,n=3===b.length?r:k));if(!h)return c(null); -n()}function W(a,b,c,d){function e(){wb)return d(null);K(b>l?l:b,t)}function ya(a,b,c){function d(){b(a[v],s)}function e(){b(a[v],v,s)}function f(){b(q.next().value,s)}function g(){p=q.next().value;b(p,v,s)}function k(){b(a[m[v]],s)}function r(){l=m[v];b(a[l],l,s)}function s(a,b){a?(u=z,c=E(c),c(a,G(n))):(n[v]=b,++v===h?(u=z,c(null,n),c=z):t?C(u):(t=!0,u()),t=!1)}c=c||y;var h,l,m,q,p,n,u,t=!1,v=0;B(a)?(h=a.length, -u=3===b.length?e:d):a&&(x&&a[x]?(h=a.size,q=a[x](),u=3===b.length?g:f):"object"===typeof a&&(m=F(a),h=m.length,u=3===b.length?r:k));if(!h)return c(null,[]);n=Array(h);u()}function za(a,b,c,d){return function(e,f,g){function k(a){var b=!1;return function(c,e){b&&z();b=!0;c?(g=H(g),g(c)):!!e===d?(g=H(g),g(null,a)):++h===r&&g(null)}}g=g||y;var r,s,h=0;B(e)?(r=e.length,a(e,f,k)):e&&(x&&e[x]?(r=e.size,c(e,f,k)):"object"===typeof e&&(s=F(e),r=s.length,b(e,f,k,s)));r||g(null)}}function Aa(a){return function(b, -c,d){function e(){q=b[v];c(q,h)}function f(){q=b[v];c(q,v,h)}function g(){q=n.next().value;c(q,h)}function k(){q=n.next().value;c(q,v,h)}function r(){q=b[p[v]];c(q,h)}function s(){m=p[v];q=b[m];c(q,m,h)}function h(b,c){b?d(b):!!c===a?(u=z,d(null,q)):++v===l?(u=z,d(null)):t?C(u):(t=!0,u());t=!1}d=E(d||y);var l,m,q,p,n,u,t=!1,v=0;B(b)?(l=b.length,u=3===c.length?f:e):b&&(x&&b[x]?(l=b.size,n=b[x](),u=3===c.length?k:g):"object"===typeof b&&(p=F(b),l=p.length,u=3===c.length?s:r));if(!l)return d(null);u()}} -function Ba(a){return function(b,c,d,e){function f(){q=J++;qc)return e(null);K(c>m?m:c,w)}}function Ca(a,b,c,d){return function(e,f,g){function k(a,b){return function(c,e){null===a&&z();c?(a=null,g=H(g),g(c,L(l))):(!!e===d&&(l[a]=b),a=null,++h===r&&g(null,l))}}g=g||y;var r,s,h=0,l={};B(e)?(r=e.length,a(e,f,k)):e&&(x&&e[x]?(r=e.size,c(e,f,k)):"object"===typeof e&&(s= -F(e),r=s.length,b(e,f,k,s)));if(!r)return g(null,{})}}function Da(a){return function(b,c,d){function e(){m=w;q=b[w];c(q,h)}function f(){m=w;q=b[w];c(q,w,h)}function g(){m=w;q=n.next().value;c(q,h)}function k(){m=w;q=n.next().value;c(q,m,h)}function r(){m=p[w];q=b[m];c(q,h)}function s(){m=p[w];q=b[m];c(q,m,h)}function h(b,c){b?d(b,v):(!!c===a&&(v[m]=q),++w===l?(u=z,d(null,v)):t?C(u):(t=!0,u()),t=!1)}d=E(d||y);var l,m,q,p,n,u,t=!1,v={},w=0;B(b)?(l=b.length,u=3===c.length?f:e):b&&(x&&b[x]?(l=b.size, -n=b[x](),u=3===c.length?k:g):"object"===typeof b&&(p=F(b),l=p.length,u=3===c.length?s:r));if(!l)return d(null,{});u()}}function Ea(a){return function(b,c,d,e){function f(){q=D++;qc)return e(null,{});K(c>m?m:c,w)}}function X(a,b,c,d){function e(b){c(b,a[t],h)}function f(b){c(b,a[t],t,h)}function g(){c(b,p.next().value,h)}function k(){c(b, -p.next().value,t,h)}function r(b){c(b,a[q[t]],h)}function s(b){m=q[t];c(b,a[m],m,h)}function h(a,b){a?d(a,b):++t===l?(c=z,d(null,b)):u?C(function(){n(b)}):(u=!0,n(b));u=!1}d=E(d||y);var l,m,q,p,n,u=!1,t=0;B(a)?(l=a.length,n=4===c.length?f:e):a&&(x&&a[x]?(l=a.size,p=a[x](),n=4===c.length?k:g):"object"===typeof a&&(q=F(a),l=q.length,n=4===c.length?s:r));if(!l)return d(null,b);n(b)}function Fa(a,b,c,d){function e(b){c(b,a[--s],r)}function f(b){c(b,a[--s],s,r)}function g(b){c(b,a[m[--s]],r)}function k(b){l= -m[--s];c(b,a[l],l,r)}function r(a,b){a?d(a,b):0===s?(u=z,d(null,b)):t?C(function(){u(b)}):(t=!0,u(b));t=!1}d=E(d||y);var s,h,l,m,q,p,n,u,t=!1;if(B(a))s=a.length,u=4===c.length?f:e;else if(a)if(x&&a[x]){s=a.size;n=Array(s);q=a[x]();for(h=-1;!1===(p=q.next()).done;)n[++h]=p.value;a=n;u=4===c.length?f:e}else"object"===typeof a&&(m=F(a),s=m.length,u=4===c.length?k:g);if(!s)return d(null,b);u(b)}function Ga(a,b,c){c=c||y;ha(a,b,function(a,b){if(a)return c(a);c(null,!!b)})}function Ha(a,b,c){c=c||y;ia(a, -b,function(a,b){if(a)return c(a);c(null,!!b)})}function Ia(a,b,c,d){d=d||y;ja(a,b,c,function(a,b){if(a)return d(a);d(null,!!b)})}function Ja(a,b){return B(a)?0===a.length?(b(null),!1):!0:(b(Error("First argument to waterfall must be an array of functions")),!1)}function ka(a,b,c){switch(b.length){case 0:case 1:return a(c);case 2:return a(b[1],c);case 3:return a(b[1],b[2],c);case 4:return a(b[1],b[2],b[3],c);case 5:return a(b[1],b[2],b[3],b[4],c);case 6:return a(b[1],b[2],b[3],b[4],b[5],c);default:return b= -I(b,1),b.push(c),a.apply(null,b)}}function Ka(a,b){function c(c,h){if(c)r=z,b=E(b),b(c);else if(++d===f){r=z;var l=b;b=z;2===arguments.length?l(c,h):l.apply(null,G(arguments))}else g=a[d],k=arguments,e?C(r):(e=!0,r()),e=!1}b=b||y;if(Ja(a,b)){var d=0,e=!1,f=a.length,g=a[d],k=[],r=function(){switch(g.length){case 0:try{c(null,g())}catch(a){c(a)}break;case 1:return g(c);case 2:return g(k[1],c);case 3:return g(k[1],k[2],c);case 4:return g(k[1],k[2],k[3],c);case 5:return g(k[1],k[2],k[3],k[4],c);default:return k= -I(k,1),k[g.length-1]=c,g.apply(null,k)}};r()}}function La(){var a=G(arguments);return function(){var b=this,c=G(arguments),d=c[c.length-1];"function"===typeof d?c.pop():d=y;X(a,c,function(a,c,d){a.push(function(a){var b=I(arguments,1);d(a,b)});c.apply(b,a)},function(a,c){c=B(c)?c:[c];c.unshift(a);d.apply(b,c)})}}function Ma(a){return function(b){var c=function(){var c=this,d=G(arguments),g=d.pop()||y;return a(b,function(a,b){a.apply(c,d.concat([b]))},g)};if(1c)throw Error("Concurrency must not be zero");var h=0,l=[],m,q,p={_tasks:new M,concurrency:c,payload:d,saturated:y,unsaturated:y,buffer:c/4,empty:y,drain:y,error:y,started:!1,paused:!1,push:function(a,b){f(a,b)},kill:function(){p.drain=y;p._tasks.empty()}, -unshift:function(a,b){f(a,b,!0)},remove:function(a){p._tasks.remove(a)},process:a?k:r,length:function(){return p._tasks.length},running:function(){return h},workersList:function(){return l},idle:function(){return 0===p.length()+h},pause:function(){p.paused=!0},resume:function(){!1!==p.paused&&(p.paused=!1,K(p.concurrency=arguments.length?f:I(arguments,1);if(a){r=g=0;s.length=0;var l=L(k);l[b]=f;b=null;var h=c;c=y;h(a,l)}else r--,g--,k[b]=f,e(b),b=null}function p(){0===--t&& -s.push([n,u,d])}var n,u;if(B(a)){var t=a.length-1;n=a[t];u=t;if(0===t)s.push([n,u,d]);else for(var v=-1;++v=arguments.length)return c(a,e);var f=G(arguments);return c.apply(null,f)}b(d)}function e(){b(f)}function f(a,b){if(++s===g||!a||r&&!r(a)){if(2>=arguments.length)return c(a,b);var d=G(arguments);return c.apply(null,d)}setTimeout(e,k(s))}var g,k,r,s=0;if(3>arguments.length&&"function"===typeof a)c=b||y,b=a,a=null,g=5;else switch(c=c||y,typeof a){case "object":"function"===typeof a.errorFilter&&(r=a.errorFilter);var h=a.interval;switch(typeof h){case "function":k=h;break;case "string":case "number":k= -(h=+h)?function(){return h}:function(){return 0}}g=+a.times||5;break;case "number":g=a||5;break;case "string":g=+a||5;break;default:throw Error("Invalid arguments for async.retry");}if("function"!==typeof b)throw Error("Invalid arguments for async.retry");k?b(f):b(d)}function Oa(a){return function(){var b=G(arguments),c=b.pop(),d;try{d=a.apply(this,b)}catch(e){return c(e)}d&&"function"===typeof d.then?d.then(function(a){try{c(null,a)}catch(b){C(Pa,b)}},function(a){a=a&&a.message?a:Error(a);try{c(a, -void 0)}catch(b){C(Pa,b)}}):c(null,d)}}function Pa(a){throw a;}function Qa(a){return function(){function b(a,b){if(a)return c(null,{error:a});2=arguments.length?c: -I(arguments,1),a=null,++r===f&&d(null,k))}}d=d||y;var f,g,k,r=0;B(c)?(f=c.length,k=Array(f),a(c,e)):c&&"object"===typeof c&&(g=F(c),f=g.length,k={},b(c,e,g));f||d(null,k)}}(function(a,b){for(var c=-1,d=a.length;++cb)return d(null,[]);t=Array(l);K(b>l?l:b,v)},mapValues:eb,mapValuesSeries:function(a,b,c){function d(){l=v;b(a[v],s)}function e(){l=v;b(a[v],v,s)}function f(){l=v;p=q.next().value;b(p,s)}function g(){l=v;p=q.next().value;b(p,v,s)}function k(){l=m[v];b(a[l],s)}function r(){l=m[v];b(a[l],l,s)}function s(a,b){a? -(n=z,c=E(c),c(a,L(t))):(t[l]=b,++v===h?(n=z,c(null,t),c=z):u?C(n):(u=!0,n()),u=!1)}c=c||y;var h,l,m,q,p,n,u=!1,t={},v=0;B(a)?(h=a.length,n=3===b.length?e:d):a&&(x&&a[x]?(h=a.size,q=a[x](),n=3===b.length?g:f):"object"===typeof a&&(m=F(a),h=m.length,n=3===b.length?r:k));if(!h)return c(null,t);n()},mapValuesLimit:function(a,b,c,d){function e(){m=A++;mb)return d(null,w);K(b>l?l:b,t)},filter:Sa,filterSeries:Ta, -filterLimit:Ua,select:Sa,selectSeries:Ta,selectLimit:Ua,reject:fb,rejectSeries:gb,rejectLimit:hb,detect:ha,detectSeries:ia,detectLimit:ja,find:ha,findSeries:ia,findLimit:ja,pick:ib,pickSeries:jb,pickLimit:kb,omit:lb,omitSeries:mb,omitLimit:nb,reduce:X,inject:X,foldl:X,reduceRight:Fa,foldr:Fa,transform:ob,transformSeries:function(a,b,c,d){function e(){c(u,a[v],h)}function f(){c(u,a[v],v,h)}function g(){c(u,p.next().value,h)}function k(){c(u,p.next().value,v,h)}function r(){c(u,a[q[v]],h)}function s(){m= -q[v];c(u,a[m],m,h)}function h(a,b){a?d(a,u):++v===l?(n=z,d(null,u)):!1===b?(n=z,d(null,u)):t?C(n):(t=!0,n());t=!1}3===arguments.length&&(d=c,c=b,b=void 0);d=E(d||y);var l,m,q,p,n,u,t=!1,v=0;B(a)?(l=a.length,u=void 0!==b?b:[],n=4===c.length?f:e):a&&(x&&a[x]?(l=a.size,p=a[x](),u=void 0!==b?b:{},n=4===c.length?k:g):"object"===typeof a&&(q=F(a),l=q.length,u=void 0!==b?b:{},n=4===c.length?s:r));if(!l)return d(null,void 0!==b?b:u||{});n()},transformLimit:function(a,b,c,d,e){function f(){q=z++;qb)return e(null,void 0!==c?c:w||{});K(b>m?m:b,v)},sortBy:pb,sortBySeries:function(a,b,c){function d(){m=a[w];b(m,s)}function e(){m=a[w];b(m,w,s)}function f(){m=p.next().value;n[w]=m;b(m,s)}function g(){m=p.next().value;n[w]=m;b(m,w,s)}function k(){m=a[q[w]];n[w]=m;b(m,s)}function r(){l=q[w];m=a[l];n[w]=m;b(m,l,s)} -function s(a,b){u[w]=b;a?c(a):++w===h?(t=z,c(null,$(n,u))):v?C(t):(v=!0,t());v=!1}c=E(c||y);var h,l,m,q,p,n,u,t,v=!1,w=0;B(a)?(h=a.length,n=a,u=Array(h),t=3===b.length?e:d):a&&(x&&a[x]?(h=a.size,n=Array(h),u=Array(h),p=a[x](),t=3===b.length?g:f):"object"===typeof a&&(q=F(a),h=q.length,n=Array(h),u=Array(h),t=3===b.length?r:k));if(!h)return c(null,[]);t()},sortByLimit:function(a,b,c,d){function e(){Db)return d(null,[]);w=Array(l);K(b>l?l:b,A)},some:Ga,someSeries:Ha,someLimit:Ia,any:Ga,anySeries:Ha,anyLimit:Ia,every:Va,everySeries:Wa,everyLimit:Xa,all:Va,allSeries:Wa,allLimit:Xa,concat:qb,concatSeries:function(a,b,c){function d(){b(a[v],s)}function e(){b(a[v],v,s)}function f(){b(q.next().value,s)}function g(){p=q.next().value;b(p,v,s)}function k(){b(a[m[v]],s)}function r(){l=m[v];b(a[l],l,s)}function s(a,b){B(b)?U.apply(t,b): -2<=arguments.length&&U.apply(t,I(arguments,1));a?c(a,t):++v===h?(n=z,c(null,t)):u?C(n):(u=!0,n());u=!1}c=E(c||y);var h,l,m,q,p,n,u=!1,t=[],v=0;B(a)?(h=a.length,n=3===b.length?e:d):a&&(x&&a[x]?(h=a.size,q=a[x](),n=3===b.length?g:f):"object"===typeof a&&(m=F(a),h=m.length,n=3===b.length?r:k));if(!h)return c(null,t);n()},concatLimit:function(a,b,c,d){function e(){tb)return d(null,[]);var A=Array(l);K(b>l?l:b,n)},groupBy:rb,groupBySeries:function(a,b,c){function d(){m=a[t];b(m,s)}function e(){m=a[t];b(m,t,s)}function f(){m=p.next().value;b(m,s)}function g(){m=p.next().value;b(m,t,s)}function k(){m=a[q[t]];b(m,s)}function r(){l=q[t];m=a[l];b(m,l,s)}function s(a,b){if(a)n=z,c=E(c),c(a,L(v));else{var d=v[b];d?d.push(m):v[b]=[m];++t===h?(n=z,c(null,v)):u? -C(n):(u=!0,n());u=!1}}c=E(c||y);var h,l,m,q,p,n,u=!1,t=0,v={};B(a)?(h=a.length,n=3===b.length?e:d):a&&(x&&a[x]?(h=a.size,p=a[x](),n=3===b.length?g:f):"object"===typeof a&&(q=F(a),h=q.length,n=3===b.length?r:k));if(!h)return c(null,v);n()},groupByLimit:function(a,b,c,d){function e(){Ab)return d(null,D);K(b>l?l:b,v)},parallel:sb,series:function(a,b){function c(){g= -l;a[l](e)}function d(){g=k[l];a[g](e)}function e(a,c){a?(s=z,b=E(b),b(a,r)):(r[g]=2>=arguments.length?c:I(arguments,1),++l===f?(s=z,b(null,r)):h?C(s):(h=!0,s()),h=!1)}b=b||y;var f,g,k,r,s,h=!1,l=0;if(B(a))f=a.length,r=Array(f),s=c;else if(a&&"object"===typeof a)k=F(a),f=k.length,r={},s=d;else return b(null);if(!f)return b(null,r);s()},parallelLimit:function(a,b,c){function d(){k=q++;if(k=arguments.length?d:I(arguments,1),a=null,++p===g?c(null,h):m?C(l):(m=!0,l()),m=!1)}}c=c||y;var g,k,r,s,h,l,m=!1,q=0,p=0;B(a)?(g=a.length,h=Array(g),l=d):a&&"object"===typeof a&&(s=F(a),g=s.length,h={},l=e);if(!g||isNaN(b)||1>b)return c(null,h);K(b>g?g:b,l)},tryEach:function(a,b){function c(){a[r](e)}function d(){a[g[r]](e)}function e(a,c){a?++r===f?b(a):k():2>=arguments.length?b(null,c):b(null,I(arguments,1))}b=b||y;var f,g,k,r=0;B(a)?(f=a.length,k=c):a&&"object"===typeof a&& -(g=F(a),f=g.length,k=d);if(!f)return b(null);k()},waterfall:function(a,b){function c(){ka(e,f,d(e))}function d(h){return function(l,m){void 0===h&&(b=y,z());h=void 0;l?(g=b,b=z,g(l)):++r===s?(g=b,b=z,2>=arguments.length?g(l,m):g.apply(null,G(arguments))):(k?(f=arguments,e=a[r]||z,C(c)):(k=!0,ka(a[r]||z,arguments,d(r))),k=!1)}}b=b||y;if(Ja(a,b)){var e,f,g,k,r=0,s=a.length;ka(a[0],[],d(0))}},angelFall:Ka,angelfall:Ka,whilst:function(a,b,c){function d(){g?C(e):(g=!0,b(f));g=!1}function e(){b(f)}function f(b, -e){if(b)return c(b);2>=arguments.length?a(e)?d():c(null,e):(e=I(arguments,1),a.apply(null,e)?d():c.apply(null,[null].concat(e)))}c=c||y;var g=!1;a()?d():c(null)},doWhilst:function(a,b,c){function d(){g?C(e):(g=!0,a(f));g=!1}function e(){a(f)}function f(a,e){if(a)return c(a);2>=arguments.length?b(e)?d():c(null,e):(e=I(arguments,1),b.apply(null,e)?d():c.apply(null,[null].concat(e)))}c=c||y;var g=!1;e()},until:function(a,b,c){function d(){g?C(e):(g=!0,b(f));g=!1}function e(){b(f)}function f(b,e){if(b)return c(b); -2>=arguments.length?a(e)?c(null,e):d():(e=I(arguments,1),a.apply(null,e)?c.apply(null,[null].concat(e)):d())}c=c||y;var g=!1;a()?c(null):d()},doUntil:function(a,b,c){function d(){g?C(e):(g=!0,a(f));g=!1}function e(){a(f)}function f(a,e){if(a)return c(a);2>=arguments.length?b(e)?c(null,e):d():(e=I(arguments,1),b.apply(null,e)?c.apply(null,[null].concat(e)):d())}c=c||y;var g=!1;e()},during:function(a,b,c){function d(a,d){if(a)return c(a);d?b(e):c(null)}function e(b){if(b)return c(b);a(d)}c=c||y;a(d)}, -doDuring:function(a,b,c){function d(b,d){if(b)return c(b);d?a(e):c(null)}function e(a,e){if(a)return c(a);switch(arguments.length){case 0:case 1:b(d);break;case 2:b(e,d);break;default:var k=I(arguments,1);k.push(d);b.apply(null,k)}}c=c||y;d(null,!0)},forever:function(a,b){function c(){a(d)}function d(a){if(a){if(b)return b(a);throw a;}e?C(c):(e=!0,c());e=!1}var e=!1;c()},compose:function(){return La.apply(null,Ya(arguments))},seq:La,applyEach:tb,applyEachSeries:ub,queue:function(a,b){return la(!0, -a,b)},priorityQueue:function(a,b){var c=la(!0,a,b);c.push=function(a,b,f){c.started=!0;b=b||0;var g=B(a)?a:[a],k=g.length;if(void 0===a||0===k)c.idle()&&C(c.drain);else{f="function"===typeof f?f:y;for(a=c._tasks.head;a&&b>=a.priority;)a=a.next;for(;k--;){var r={data:g[k],priority:b,callback:f};a?c._tasks.insertBefore(a,r):c._tasks.push(r);C(c.process)}}};delete c.unshift;return c},cargo:function(a,b){return la(!1,a,1,b)},auto:Na,autoInject:function(a,b,c){var d={};S(a,function(a,b){var c,k=a.length; -if(B(a)){if(0===k)throw Error("autoInject task functions require explicit parameters.");c=G(a);k=c.length-1;a=c[k];if(0===k){d[b]=a;return}}else{if(1===k){d[b]=a;return}c=$a(a);if(0===k&&0===c.length)throw Error("autoInject task functions require explicit parameters.");k=c.length-1}c[k]=function(b,d){switch(k){case 1:a(b[c[0]],d);break;case 2:a(b[c[0]],b[c[1]],d);break;case 3:a(b[c[0]],b[c[1]],b[c[2]],d);break;default:for(var f=-1;++fa)return c(null,[]);var e=Array(a);K(a,function(a){b(a,d(a))})},timesSeries:function(a,b,c){function d(){b(k,e)}function e(b,e){f[k]=e;b?(c(b),c=z):++k>=a?(c(null,f),c=z):g?C(d):(g=!0,d());g=!1}c=c||y;a=+a;if(isNaN(a)||1>a)return c(null,[]);var f=Array(a),g=!1,k=0;d()},timesLimit:function(a,b,c,d){function e(){var b= -r++;b=a?(d(null,g),d=z):k?C(e):(k=!0,e());k=!1}}d=d||y;a=+a;if(isNaN(a)||1>a||isNaN(b)||1>b)return d(null,[]);var g=Array(a),k=!1,r=0,s=0;K(b>a?a:b,e)},race:function(a,b){b=H(b||y);var c,d,e=-1;if(B(a))for(c=a.length;++e=d)return[];for(var e=Array(d);++bd[e]){var g=d[f]; +d[f]=d[e];d[e]=g}}if(!(e>b)){for(var l,e=a[a[c]>a[e]?c:e],f=c,g=b;f<=g;){for(l=f;f=l&&a[g]>=e;)g--;if(f>g)break;var q=a;l=d;var s=f++,h=g--,k=q[s];q[s]=q[h];q[h]=k;q=l[s];l[s]=l[h];l[h]=q}e=f;ca(a,c,e-1,d);ca(a,e,b,d)}}}function S(a){var c=[];Q(a,function(a){a!==w&&(C(a)?X.apply(c,a):c.push(a))});return c}function da(a,c,b){var d=-1,e=a.length;if(3===c.length)for(;++d=c.size&&d!==w&&(d=w,e(null,U(y)))}function q(){v=t.next();!1===v.done?(p=v.value,d(p,B,k(p,B++))):R>=c.size&&d!==w&&(d=w,e(null,U(y)))}function s(){r=B++;rb)return e(null,[]);y=y||Array(m);K(b>m?m:b,x)}}function Y(a,c,b){function d(){c(a[t],s)}function e(){c(a[t],t,s)}function f(){n=r.next();n.done?b(null):c(n.value,s)}function g(){n=r.next();n.done?b(null):c(n.value,t,s)}function l(){c(a[m[t]],s)}function q(){k=m[t];c(a[k],k,s)}function s(a,d){a?b(a):++t===h||!1===d?(p=A,b(null)): +u?D(p):(u=!0,p());u=!1}b=E(b||w);var h,k,m,r,n,p,u=!1,t=0;C(a)?(h=a.length,p=3===c.length?e:d):a&&(z&&a[z]?(h=Infinity,r=a[z](),p=3===c.length?g:f):"object"===typeof a&&(m=F(a),h=m.length,p=3===c.length?q:l));if(!h)return b(null);p()}function Z(a,c,b,d){function e(){x=a.size&&b!==w&&(b=w,d(null))}function l(){u=p.next();!1===u.done?b(u.value,x++,h):y>=a.size&&b!==w&&(b=w,d(null))}function q(){x< +k&&b(a[n[x++]],h)}function s(){m=x++;mc)return d(null);K(c>k?k:c,t)}function za(a,c,b){function d(){c(a[v],s)}function e(){c(a[v],v,s)}function f(){n= +r.next();n.done?b(null,p):c(n.value,s)}function g(){n=r.next();n.done?b(null,p):c(n.value,v,s)}function l(){c(a[m[v]],s)}function q(){k=m[v];c(a[k],k,s)}function s(a,d){a?(u=A,b=E(b),b(a,H(p))):(p[v]=d,++v===h?(u=A,b(null,p),b=A):t?D(u):(t=!0,u()),t=!1)}b=b||w;var h,k,m,r,n,p,u,t=!1,v=0;C(a)?(h=a.length,u=3===c.length?e:d):a&&(z&&a[z]?(h=Infinity,p=[],r=a[z](),u=3===c.length?g:f):"object"===typeof a&&(m=F(a),h=m.length,u=3===c.length?q:l));if(!h)return b(null,[]);p=p||Array(h);u()}function Aa(a,c, +b,d){return function(e,f,g){function l(a){var b=!1;return function(c,e){b&&A();b=!0;c?(g=I(g),g(c)):!!e===d?(g=I(g),g(null,a)):++h===q&&g(null)}}g=g||w;var q,s,h=0;C(e)?(q=e.length,a(e,f,l)):e&&(z&&e[z]?(q=b(e,f,l))&&q===h&&g(null):"object"===typeof e&&(s=F(e),q=s.length,c(e,f,l,s)));q||g(null)}}function Ba(a){return function(c,b,d){function e(){r=c[x];b(r,h)}function f(){r=c[x];b(r,x,h)}function g(){u=p.next();r=u.value;u.done?d(null):b(r,h)}function l(){u=p.next();r=u.value;u.done?d(null):b(r,x, +h)}function q(){r=c[n[x]];b(r,h)}function s(){m=n[x];r=c[m];b(r,m,h)}function h(b,c){b?d(b):!!c===a?(t=A,d(null,r)):++x===k?(t=A,d(null)):v?D(t):(v=!0,t());v=!1}d=E(d||w);var k,m,r,n,p,u,t,v=!1,x=0;C(c)?(k=c.length,t=3===b.length?f:e):c&&(z&&c[z]?(k=Infinity,p=c[z](),t=3===b.length?l:g):"object"===typeof c&&(n=F(c),k=n.length,t=3===b.length?s:q));if(!k)return d(null);t()}}function Ca(a){return function(c,b,d,e){function f(){r=G++;r=c.size&&d!==w&&(d=w,e(null))}function q(){v=t.next();!1===v.done?(p=v.value,d(p,G++,k(p))):B>=c.size&&d!==w&&(d=w,e(null))}function s(){r=G++;rb)return e(null);K(b>m?m:b,x)}}function Da(a,c,b,d){return function(e,f,g){function l(a,b){return function(c,e){null===a&&A();c?(a=null,g=I(g),g(c,L(k))):(!!e===d&&(k[a]=b),a=null,++h===q&&g(null,k))}}g=g||w;var q,s,h=0,k={};C(e)?(q=e.length,a(e,f,l)):e&&(z&&e[z]?(q=b(e,f,l))&&q===h&&g(null,k):"object"===typeof e&&(s=F(e),q=s.length,c(e,f,l,s)));if(!q)return g(null, +{})}}function Ea(a){return function(c,b,d){function e(){m=y;r=c[y];b(r,h)}function f(){m=y;r=c[y];b(r,y,h)}function g(){m=y;u=p.next();r=u.value;u.done?d(null,x):b(r,h)}function l(){m=y;u=p.next();r=u.value;u.done?d(null,x):b(r,m,h)}function q(){m=n[y];r=c[m];b(r,h)}function s(){m=n[y];r=c[m];b(r,m,h)}function h(b,c){b?d(b,x):(!!c===a&&(x[m]=r),++y===k?(t=A,d(null,x)):v?D(t):(v=!0,t()),v=!1)}d=E(d||w);var k,m,r,n,p,u,t,v=!1,x={},y=0;C(c)?(k=c.length,t=3===b.length?f:e):c&&(z&&c[z]?(k=Infinity,p=c[z](), +t=3===b.length?l:g):"object"===typeof c&&(n=F(c),k=n.length,t=3===b.length?s:q));if(!k)return d(null,{});t()}}function Fa(a){return function(c,b,d,e){function f(){r=B++;r=c.size&&d!==w&&(d=w,e(null,G))}function q(){v=t.next();!1===v.done?(p=v.value,d(p,B,k(p,B++))):R>=c.size&&d!==w&&(d=w,e(null,G))}function s(){Bb)return e(null,{});K(b>m?m:b,x)}}function $(a,c,b,d){function e(d){b(d,a[t],h)}function f(d){b(d, +a[t],t,h)}function g(){b(c,n.next().value,h)}function l(){b(c,n.next().value,t,h)}function q(d){b(d,a[r[t]],h)}function s(d){m=r[t];b(d,a[m],m,h)}function h(a,c){a?d(a,c):++t===k?(b=A,d(null,c)):u?D(function(){p(c)}):(u=!0,p(c));u=!1}d=E(d||w);var k,m,r,n,p,u=!1,t=0;C(a)?(k=a.length,p=4===b.length?f:e):a&&(z&&a[z]?(k=a.size,n=a[z](),p=4===b.length?l:g):"object"===typeof a&&(r=F(a),k=r.length,p=4===b.length?s:q));if(!k)return d(null,c);p(c)}function Ga(a,c,b,d){function e(d){b(d,a[--s],q)}function f(d){b(d, +a[--s],s,q)}function g(d){b(d,a[m[--s]],q)}function l(d){k=m[--s];b(d,a[k],k,q)}function q(a,b){a?d(a,b):0===s?(u=A,d(null,b)):t?D(function(){u(b)}):(t=!0,u(b));t=!1}d=E(d||w);var s,h,k,m,r,n,p,u,t=!1;if(C(a))s=a.length,u=4===b.length?f:e;else if(a)if(z&&a[z]){s=a.size;p=Array(s);r=a[z]();for(h=-1;!1===(n=r.next()).done;)p[++h]=n.value;a=p;u=4===b.length?f:e}else"object"===typeof a&&(m=F(a),s=m.length,u=4===b.length?l:g);if(!s)return d(null,c);u(c)}function Ha(a,c,b){b=b||w;ja(a,c,function(a,c){if(a)return b(a); +b(null,!!c)})}function Ia(a,c,b){b=b||w;ka(a,c,function(a,c){if(a)return b(a);b(null,!!c)})}function Ja(a,c,b,d){d=d||w;la(a,c,b,function(a,b){if(a)return d(a);d(null,!!b)})}function Ka(a,c){return C(a)?0===a.length?(c(null),!1):!0:(c(Error("First argument to waterfall must be an array of functions")),!1)}function ma(a,c,b){switch(c.length){case 0:case 1:return a(b);case 2:return a(c[1],b);case 3:return a(c[1],c[2],b);case 4:return a(c[1],c[2],c[3],b);case 5:return a(c[1],c[2],c[3],c[4],b);case 6:return a(c[1], +c[2],c[3],c[4],c[5],b);default:return c=J(c,1),c.push(b),a.apply(null,c)}}function La(a,c){function b(b,h){if(b)q=A,c=E(c),c(b);else if(++d===f){q=A;var k=c;c=A;2===arguments.length?k(b,h):k.apply(null,H(arguments))}else g=a[d],l=arguments,e?D(q):(e=!0,q()),e=!1}c=c||w;if(Ka(a,c)){var d=0,e=!1,f=a.length,g=a[d],l=[],q=function(){switch(g.length){case 0:try{b(null,g())}catch(a){b(a)}break;case 1:return g(b);case 2:return g(l[1],b);case 3:return g(l[1],l[2],b);case 4:return g(l[1],l[2],l[3],b);case 5:return g(l[1], +l[2],l[3],l[4],b);default:return l=J(l,1),l[g.length-1]=b,g.apply(null,l)}};q()}}function Ma(){var a=H(arguments);return function(){var c=this,b=H(arguments),d=b[b.length-1];"function"===typeof d?b.pop():d=w;$(a,b,function(a,b,d){a.push(function(a){var b=J(arguments,1);d(a,b)});b.apply(c,a)},function(a,b){b=C(b)?b:[b];b.unshift(a);d.apply(c,b)})}}function Na(a){return function(c){var b=function(){var b=this,d=H(arguments),g=d.pop()||w;return a(c,function(a,c){a.apply(b,d.concat([c]))},g)};if(1b)throw Error("Concurrency must not be zero");var h=0,k=[],m,r,n={_tasks:new M,concurrency:b,payload:d,saturated:w,unsaturated:w,buffer:b/4,empty:w,drain:w,error:w,started:!1,paused:!1,push:function(a,b){f(a,b)},kill:function(){n.drain= +w;n._tasks.empty()},unshift:function(a,b){f(a,b,!0)},remove:function(a){n._tasks.remove(a)},process:a?l:q,length:function(){return n._tasks.length},running:function(){return h},workersList:function(){return k},idle:function(){return 0===n.length()+h},pause:function(){n.paused=!0},resume:function(){!1!==n.paused&&(n.paused=!1,K(n.concurrency=arguments.length?f:J(arguments,1);if(a){q=g=0;s.length=0;var k=L(l);k[d]=f;d=null;var h=b;b=w;h(a,k)}else q--,g--,l[d]=f,e(d),d=null}function n(){0===--t&& +s.push([p,u,c])}var p,u;if(C(a)){var t=a.length-1;p=a[t];u=t;if(0===t)s.push([p,u,c]);else for(var v=-1;++v=arguments.length)return b(a,e);var f=H(arguments);return b.apply(null,f)}c(d)}function e(){c(f)}function f(a,d){if(++s===g||!a||q&&!q(a)){if(2>=arguments.length)return b(a,d);var c=H(arguments);return b.apply(null,c)}setTimeout(e,l(s))}var g,l,q,s=0;if(3>arguments.length&&"function"===typeof a)b=c||w,c=a,a=null,g=5;else switch(b=b||w,typeof a){case "object":"function"===typeof a.errorFilter&&(q=a.errorFilter);var h=a.interval;switch(typeof h){case "function":l=h;break;case "string":case "number":l= +(h=+h)?function(){return h}:function(){return 0}}g=+a.times||5;break;case "number":g=a||5;break;case "string":g=+a||5;break;default:throw Error("Invalid arguments for async.retry");}if("function"!==typeof c)throw Error("Invalid arguments for async.retry");l?c(f):c(d)}function Pa(a){return function(){var c=H(arguments),b=c.pop(),d;try{d=a.apply(this,c)}catch(e){return b(e)}d&&"function"===typeof d.then?d.then(function(a){try{b(null,a)}catch(d){D(Qa,d)}},function(a){a=a&&a.message?a:Error(a);try{b(a, +void 0)}catch(d){D(Qa,d)}}):b(null,d)}}function Qa(a){throw a;}function Ra(a){return function(){function c(a,d){if(a)return b(null,{error:a});2=arguments.length?c:J(arguments,1),a=null,++q===f&&d(null,l))}}d=d||w;var f,g,l,q=0;C(b)?(f=b.length,l=Array(f),a(b,e)):b&&"object"===typeof b&&(g=F(b),f=g.length,l={},c(b,e,g));f||d(null,l)}}(function(a,c){for(var b=-1,d=a.length;++b=a.size&&b!==w&&(b=w,d(null,t))}function l(){u=p.next();!1===u.done?b(u.value,y,h(y++)):G>=a.size&&b!==w&&(b=w,d(null,t))}function q(){m=y++;mc)return d(null,[]);t=t||Array(k);K(c>k?k:c,v)},mapValues:fb,mapValuesSeries:function(a,c,b){function d(){k=v;c(a[v],s)}function e(){k=v;c(a[v],v,s)}function f(){k=v;n=r.next(); +n.done?b(null,t):c(n.value,s)}function g(){k=v;n=r.next();n.done?b(null,t):c(n.value,v,s)}function l(){k=m[v];c(a[k],s)}function q(){k=m[v];c(a[k],k,s)}function s(a,d){a?(p=A,b=E(b),b(a,L(t))):(t[k]=d,++v===h?(p=A,b(null,t),b=A):u?D(p):(u=!0,p()),u=!1)}b=b||w;var h,k,m,r,n,p,u=!1,t={},v=0;C(a)?(h=a.length,p=3===c.length?e:d):a&&(z&&a[z]?(h=Infinity,r=a[z](),p=3===c.length?g:f):"object"===typeof a&&(m=F(a),h=m.length,p=3===c.length?q:l));if(!h)return b(null,t);p()},mapValuesLimit:function(a,c,b,d){function e(){m= +y++;m=a.size&&b!==w&&(b=w,d(null,x))}function l(){u=p.next();!1===u.done?b(u.value,y,h(y++)):G>=a.size&&b!==w&&(b=w,d(null,x))}function q(){m=y++;mc)return d(null,x);K(c>k?k:c,t)},filter:Ta,filterSeries:Ua,filterLimit:Va,select:Ta,selectSeries:Ua,selectLimit:Va,reject:gb,rejectSeries:hb,rejectLimit:ib,detect:ja,detectSeries:ka,detectLimit:la,find:ja,findSeries:ka,findLimit:la,pick:jb,pickSeries:kb,pickLimit:lb,omit:mb,omitSeries:nb,omitLimit:ob,reduce:$,inject:$, +foldl:$,reduceRight:Ga,foldr:Ga,transform:pb,transformSeries:function(a,c,b,d){function e(){b(t,a[x],h)}function f(){b(t,a[x],x,h)}function g(){p=n.next();p.done?d(null,t):b(t,p.value,h)}function l(){p=n.next();p.done?d(null,t):b(t,p.value,x,h)}function q(){b(t,a[r[x]],h)}function s(){m=r[x];b(t,a[m],m,h)}function h(a,b){a?d(a,t):++x===k||!1===b?(u=A,d(null,t)):v?D(u):(v=!0,u());v=!1}3===arguments.length&&(d=b,b=c,c=void 0);d=E(d||w);var k,m,r,n,p,u,t,v=!1,x=0;C(a)?(k=a.length,t=void 0!==c?c:[],u= +4===b.length?f:e):a&&(z&&a[z]?(k=a.size,n=a[z](),t=void 0!==c?c:{},u=4===b.length?l:g):"object"===typeof a&&(r=F(a),k=r.length,t=void 0!==c?c:{},u=4===b.length?s:q));if(!k)return d(null,void 0!==c?c:t||{});u()},transformLimit:function(a,c,b,d,e){function f(){r=A++;r=a.size&&d!==w&&(d=w,e(null,x))}function q(){t=u.next();!1===t.done?d(x,t.value,A++,E(k)):B>=a.size&&d!==w&&(d=w,e(null, +x))}function s(){r=A++;rc)return e(null,void 0!==b?b:x||{});K(c>m?m:c,v)},sortBy:qb,sortBySeries:function(a,c,b){function d(){m=a[y];c(m,s)}function e(){m=a[y];c(m,y,s)}function f(){p=n.next();if(p.done)return b(null,P(u,t));m=p.value;u[y]=m;c(m,s)}function g(){p=n.next();if(p.done)return b(null,P(u,t));m=p.value;u[y]=m;c(m,y,s)}function l(){m=a[r[y]];u[y]=m;c(m,s)}function q(){k=r[y];m=a[k];u[y]=m;c(m,k,s)}function s(a,d){t[y]=d;a?b(a):++y===h?(v=A,b(null,P(u,t))):x?D(v):(x=!0,v());x=!1}b=E(b||w);var h,k,m,r,n,p,u,t, +v,x=!1,y=0;C(a)?(h=a.length,u=a,t=Array(h),v=3===c.length?e:d):a&&(z&&a[z]?(h=Infinity,u=[],t=[],n=a[z](),v=3===c.length?g:f):"object"===typeof a&&(r=F(a),h=r.length,u=Array(h),t=Array(h),v=3===c.length?q:l));if(!h)return b(null,[]);v()},sortByLimit:function(a,c,b,d){function e(){B=a.size&&b!==w&&(b=w,d(null,P(p,x)))}function l(){v=t.next();!1===v.done?(n= +v.value,p[B]=n,b(n,B,h(n,B++))):E>=a.size&&b!==w&&(b=w,d(null,P(p,x)))}function q(){Bc)return d(null,[]);x=x||Array(k);K(c>k?k:c,y)},some:Ha,someSeries:Ia,someLimit:Ja,any:Ha,anySeries:Ia,anyLimit:Ja,every:Wa,everySeries:Xa,everyLimit:Ya,all:Wa,allSeries:Xa,allLimit:Ya,concat:rb,concatSeries:function(a,c,b){function d(){c(a[v],s)}function e(){c(a[v],v,s)}function f(){n=r.next();n.done?b(null,t):c(n.value,s)}function g(){n=r.next();n.done?b(null,t):c(n.value,v,s)}function l(){c(a[m[v]],s)}function q(){k=m[v];c(a[k],k,s)}function s(a,d){C(d)? +X.apply(t,d):2<=arguments.length&&X.apply(t,J(arguments,1));a?b(a,t):++v===h?(p=A,b(null,t)):u?D(p):(u=!0,p());u=!1}b=E(b||w);var h,k,m,r,n,p,u=!1,t=[],v=0;C(a)?(h=a.length,p=3===c.length?e:d):a&&(z&&a[z]?(h=Infinity,r=a[z](),p=3===c.length?g:f):"object"===typeof a&&(m=F(a),h=m.length,p=3===c.length?q:l));if(!h)return b(null,t);p()},concatLimit:function(a,c,b,d){function e(){v=a.size&&b!== +w&&(b=w,d(null,S(u)))}function l(){n=r.next();!1===n.done?b(n.value,v,h(v++)):x>=a.size&&b!==w&&(b=w,d(null,S(u)))}function q(){vc)return d(null,[]);u=u||Array(k);K(c>k?k:c,p)},groupBy:sb,groupBySeries:function(a,c,b){function d(){m=a[v];c(m,s)}function e(){m=a[v];c(m,v,s)}function f(){p=n.next();m=p.value;p.done?b(null,x):c(m,s)}function g(){p=n.next();m=p.value;p.done?b(null,x):c(m,v,s)}function l(){m=a[r[v]];c(m, +s)}function q(){k=r[v];m=a[k];c(m,k,s)}function s(a,d){if(a)u=A,b=E(b),b(a,L(x));else{var c=x[d];c?c.push(m):x[d]=[m];++v===h?(u=A,b(null,x)):t?D(u):(t=!0,u());t=!1}}b=E(b||w);var h,k,m,r,n,p,u,t=!1,v=0,x={};C(a)?(h=a.length,u=3===c.length?e:d):a&&(z&&a[z]?(h=Infinity,n=a[z](),u=3===c.length?g:f):"object"===typeof a&&(r=F(a),h=r.length,u=3===c.length?q:l));if(!h)return b(null,x);u()},groupByLimit:function(a,c,b,d){function e(){y=a.size&&b!==w&&(b=w,d(null,B))}function l(){t=u.next();!1===t.done?(n=t.value,b(n,y++,h(n))):E>=a.size&&b!==w&&(b=w,d(null,B))}function q(){yc)return d(null,B);K(c>k?k:c,v)},parallel:tb,series:function(a,c){function b(){g=k;a[k](e)}function d(){g=l[k];a[g](e)}function e(a,b){a?(s=A,c=E(c),c(a,q)):(q[g]=2>=arguments.length?b:J(arguments,1),++k===f?(s=A,c(null,q)):h?D(s):(h=!0,s()),h=!1)}c=c||w;var f,g,l,q,s,h=!1,k=0;if(C(a))f=a.length,q=Array(f),s=b;else if(a&&"object"===typeof a)l=F(a), +f=l.length,q={},s=d;else return c(null);if(!f)return c(null,q);s()},parallelLimit:function(a,c,b){function d(){l=r++;if(l=arguments.length?c:J(arguments,1),a=null,++n===g?b(null,h):m?D(k):(m=!0,k()),m=!1)}}b=b||w;var g,l,q,s,h,k,m=!1,r=0,n=0;C(a)?(g=a.length,h=Array(g),k=d):a&&"object"===typeof a&&(s=F(a),g=s.length,h={},k=e);if(!g||isNaN(c)||1>c)return b(null, +h);K(c>g?g:c,k)},tryEach:function(a,c){function b(){a[q](e)}function d(){a[g[q]](e)}function e(a,b){a?++q===f?c(a):l():2>=arguments.length?c(null,b):c(null,J(arguments,1))}c=c||w;var f,g,l,q=0;C(a)?(f=a.length,l=b):a&&"object"===typeof a&&(g=F(a),f=g.length,l=d);if(!f)return c(null);l()},waterfall:function(a,c){function b(){ma(e,f,d(e))}function d(h){return function(k,m){void 0===h&&(c=w,A());h=void 0;k?(g=c,c=A,g(k)):++q===s?(g=c,c=A,2>=arguments.length?g(k,m):g.apply(null,H(arguments))):(l?(f=arguments, +e=a[q]||A,D(b)):(l=!0,ma(a[q]||A,arguments,d(q))),l=!1)}}c=c||w;if(Ka(a,c)){var e,f,g,l,q=0,s=a.length;ma(a[0],[],d(0))}},angelFall:La,angelfall:La,whilst:function(a,c,b){function d(){g?D(e):(g=!0,c(f));g=!1}function e(){c(f)}function f(c,e){if(c)return b(c);2>=arguments.length?a(e)?d():b(null,e):(e=J(arguments,1),a.apply(null,e)?d():b.apply(null,[null].concat(e)))}b=b||w;var g=!1;a()?d():b(null)},doWhilst:function(a,c,b){function d(){g?D(e):(g=!0,a(f));g=!1}function e(){a(f)}function f(a,e){if(a)return b(a); +2>=arguments.length?c(e)?d():b(null,e):(e=J(arguments,1),c.apply(null,e)?d():b.apply(null,[null].concat(e)))}b=b||w;var g=!1;e()},until:function(a,c,b){function d(){g?D(e):(g=!0,c(f));g=!1}function e(){c(f)}function f(c,e){if(c)return b(c);2>=arguments.length?a(e)?b(null,e):d():(e=J(arguments,1),a.apply(null,e)?b.apply(null,[null].concat(e)):d())}b=b||w;var g=!1;a()?b(null):d()},doUntil:function(a,c,b){function d(){g?D(e):(g=!0,a(f));g=!1}function e(){a(f)}function f(a,e){if(a)return b(a);2>=arguments.length? +c(e)?b(null,e):d():(e=J(arguments,1),c.apply(null,e)?b.apply(null,[null].concat(e)):d())}b=b||w;var g=!1;e()},during:function(a,c,b){function d(a,d){if(a)return b(a);d?c(e):b(null)}function e(c){if(c)return b(c);a(d)}b=b||w;a(d)},doDuring:function(a,c,b){function d(d,c){if(d)return b(d);c?a(e):b(null)}function e(a,e){if(a)return b(a);switch(arguments.length){case 0:case 1:c(d);break;case 2:c(e,d);break;default:var l=J(arguments,1);l.push(d);c.apply(null,l)}}b=b||w;d(null,!0)},forever:function(a,c){function b(){a(d)} +function d(a){if(a){if(c)return c(a);throw a;}e?D(b):(e=!0,b());e=!1}var e=!1;b()},compose:function(){return Ma.apply(null,Za(arguments))},seq:Ma,applyEach:ub,applyEachSeries:vb,queue:function(a,c){return na(!0,a,c)},priorityQueue:function(a,c){var b=na(!0,a,c);b.push=function(a,c,f){b.started=!0;c=c||0;var g=C(a)?a:[a],l=g.length;if(void 0===a||0===l)b.idle()&&D(b.drain);else{f="function"===typeof f?f:w;for(a=b._tasks.head;a&&c>=a.priority;)a=a.next;for(;l--;){var q={data:g[l],priority:c,callback:f}; +a?b._tasks.insertBefore(a,q):b._tasks.push(q);D(b.process)}}};delete b.unshift;return b},cargo:function(a,c){return na(!1,a,1,c)},auto:Oa,autoInject:function(a,c,b){var d={};W(a,function(a,b){var c,l=a.length;if(C(a)){if(0===l)throw Error("autoInject task functions require explicit parameters.");c=H(a);l=c.length-1;a=c[l];if(0===l){d[b]=a;return}}else{if(1===l){d[b]=a;return}c=ab(a);if(0===l&&0===c.length)throw Error("autoInject task functions require explicit parameters.");l=c.length-1}c[l]=function(b, +d){switch(l){case 1:a(b[c[0]],d);break;case 2:a(b[c[0]],b[c[1]],d);break;case 3:a(b[c[0]],b[c[1]],b[c[2]],d);break;default:for(var f=-1;++fa)return b(null,[]);var e=Array(a);K(a,function(a){c(a,d(a))})},timesSeries:function(a,c,b){function d(){c(l,e)}function e(c, +e){f[l]=e;c?(b(c),b=A):++l>=a?(b(null,f),b=A):g?D(d):(g=!0,d());g=!1}b=b||w;a=+a;if(isNaN(a)||1>a)return b(null,[]);var f=Array(a),g=!1,l=0;d()},timesLimit:function(a,c,b,d){function e(){var c=q++;c=a?(d(null,g),d=A):l?D(e):(l=!0,e());l=!1}}d=d||w;a=+a;if(isNaN(a)||1>a||isNaN(c)||1>c)return d(null,[]);var g=Array(a),l=!1,q=0,s=0;K(c>a?a:c,e)},race:function(a,c){c=I(c||w);var b,d,e=-1;if(C(a))for(b=a.length;++e< +b;)a[e](c);else if(a&&"object"===typeof a)for(d=F(a),b=d.length;++e