function batchProcess(limit, list) {
        var total = list.length;
        return new Promise(function (resolve) {
            next(0, []);
            function next(start, queue) {
                if (start >= total)
                    return complete(queue);
                var batch = list.slice(start, start + limit).map(function (promise) { return promise(); });
                [].push.apply(queue, batch);
                Promise.all(batch).then(function () { return next(start + limit, queue); });
                console.log("Start >>>  " + start.toString().padStart(3, " ") + " To " + (start + limit).toString().padStart(3, " "));
            }
            function complete(queue) {
                resolve(Promise.all(queue));
            }
        });
    }
/**
     * Processes a list of promises in batches, helps to avoid overloading clients during bulk processing
     * @param {number} limit number of promises to process in a batch
     * @param {Array<Function>} list list of functions that returns promises to be procesed
     * @returns {Promise<Array>} promise
     */
Processes a list of promises in batches, helps to avoid overloading clients during bulk processing
@param {number} limit number of promises to process in a batch
@param {Array} list list of functions that returns promises to be procesed
@returns {Promise} promise
Processes a list of promises in batches helps to avoid overloading clients during bulk processing @param { number } limit number of promises to process in a batch @param { Array } list list of functions that returns promises to be procesed @returns { Promise } promise
function batchProcess(limit, list) {
        var total = list.length;
        return new Promise(function (resolve) {
            next(0, []);
            function next(start, queue) {
                if (start >= total)
                    return complete(queue);
                var batch = list.slice(start, start + limit).map(function (promise) { return promise(); });
                [].push.apply(queue, batch);
                Promise.all(batch).then(function () { return next(start + limit, queue); });
                console.log("Start >>>  " + start.toString().padStart(3, " ") + " To " + (start + limit).toString().padStart(3, " "));
            }
            function complete(queue) {
                resolve(Promise.all(queue));
            }
        });
    }
function batchProcess ( limit , list ) { var total = list . length ; return new Promise ( function ( resolve ) { next ( 0 , [ ] ) ; function next ( start , queue ) { if ( start >= total ) return complete ( queue ) ; var batch = list . slice ( start , start + limit ) . map ( function ( promise ) { return promise ( ) ; } ) ; [ ] . push . apply ( queue , batch ) ; Promise . all ( batch ) . then ( function ( ) { return next ( start + limit , queue ) ; } ) ; console . log ( "Start >>>  " + start . toString ( ) . padStart ( 3 , " " ) + " To " + ( start + limit ) . toString ( ) . padStart ( 3 , " " ) ) ; } function complete ( queue ) { resolve ( Promise . all ( queue ) ) ; } } ) ; }
Processes a list of promises in batches, helps to avoid overloading clients during bulk processing
 @param {number} limit number of promises to process in a batch
 @param {Array<Function>} list list of functions that returns promises to be procesed
 @returns {Promise<Array>} promise
Processes a list of promises in batches helps to avoid overloading clients during bulk processing @param { number } limit number of promises to process in a batch @param { Array<Function > } list list of functions that returns promises to be procesed @returns { Promise<Array > } promise