Constructs more resources to bring the current count up to the minimum specified in the factory.

@private
@memberof PromisePool

@return {Promise} A promise to create all the resources needed.
546975
function _ensureMinimum() {
    // Nothing to do if draining.
    if (this._draining) {
        return Promise.resolve();
    }

    var diff = this._opts.min - this._count + this.availableLength;
    var promises = [];
    for (var i = 0; i < diff; ++i) {
        promises.push(this.acquire(function(client){ return Promise.resolve(); }));
    }

    return Promise.all(promises).then(function(){});
}
1184904
function (q) {
            var self = this;
            return this.find(q).chain(function (res) {
                return res || self.create(q);
            });
        }
1321846
function () {
    const oThis = this
      , promiseArray = [];

    return new Promise(async function (onResolve, onReject) {
      for (var chain in setupConfig.chains) {
        promiseArray.push(oThis._isRunning(chain));
      }
      return Promise.all(promiseArray).then(onResolve);
    });
  }
652424
function () {
                    if (this._lastGroup && typeof this._lastGroup.index === "number") {
                        return Promise.wrap(this._count);
                    } else {
                        // Even if there's a current estimate for _count, consider this call to be a request to determine the true
                        // count.

                        var that = this;
                        var countPromise = new Promise(function (complete) {
                            var fetch = {
                                initialBatch: function () {
                                    that._fetchNextIndex();
                                },
                                getGroup: function () { return null; },
                                countBefore: 0,
                                countAfter: 0,
                                complete: function (failed) {
                                    if (failed) {
                                        that._count = 0;
                                    }

                                    var count = that._count;
                                    if (typeof count === "number") {
                                        complete(count);
                                        return true;
                                    } else {
                                        return false;
                                    }
                                }
                            };

                            that._fetchQueue.push(fetch);

                            if (!that._itemBatch) {
                                that._continueFetch(fetch);
                            }
                        });

                        return (typeof this._count === "number" ? Promise.wrap(this._count) : countPromise);
                    }
                }
453806
function privateCreatePoolIfNotExists() {
        var createPoolOptions = Object.assign({}, defaultOptions, that.options, importantOptions);
        if (pool == null) {
            pool = mysql.createPool(createPoolOptions);
        }
    }
112661
function() {
        var self = this;

        return new Promise(function(resolve, reject) {
            var config = {};

            for (var i = 0; i < self._modules.length; i++) {
                var module = self._modules[i];

                var storedModule = config[module.name] = {
                    dependencies: module.dependencies
                };

                if (module.condition) {
                    storedModule.condition = module.condition;
                }

                if (!self._options.ignorePath) {
                    if (module.fullPath) {
                        storedModule.fullPath = upath.toUnix(module.fullPath);
                    } else {
                        var dirname = path.dirname(module.name);

                        var modulePath = module.path || (dirname !== '.' ? dirname + '/' + module.file : module.file);

                        storedModule.path = upath.toUnix(modulePath);
                    }
                }
            }

            resolve(config);
        });
    }
50111
function() {
        var self = this;

        self._modules = [];

        return new Promise(function(resolve, reject) {
            var base;
            var processors = [];

            if (self._options.base) {
                base = fs.readFileSync(path.resolve(self._options.base), 'utf8');
            }

            // For every file or folder, create a promise,
            // parse the file, extract the config and store it
            // to the global modules array.
            // Once all files are being processed, store the generated config.
            for (var i = 0; i < self._options.args.length; i++) {
                var file = self._options.args[i];

                var fileStats = fs.statSync(file);

                if (fileStats.isDirectory(file)) {
                    var walker = walk.walk(file, {
                        followLinks: false
                    });

                    walker.on('file', self._onWalkerFile.bind(self));

                    processors.push(self._onWalkerEnd(walker));
                } else if (fileStats.isFile()) {
                    processors.push(self._processFile(file));
                }
            }

            Promise.all(processors)
                .then(function(uselessPromises) {
                    return self._generateConfig();
                })
                .then(function(config) {
                    var content;

                    if (self._options.config) {
                        if (base) {
                            content = base + self._options.config + '.modules = ' + JSON.stringify(config) + ';';
                        } else {
                            content = 'var ' + self._options.config + ' = {modules: ' + JSON.stringify(config) + '};';
                        }
                    } else {
                        content = JSON.stringify(config);
                    }

                    return self._saveConfig(beautify(content));
                })
                .then(function(config) {
                    resolve(config);
                })
                .catch(function(error) {
                    reject(error);
                });
        });
    }
639871
function () {
    return new Promise((resolve, reject) => {
      var startTime = Date.now();
      var size = fs.statSync(dataFile).size;
      var next = (readInfo, position) => {
        var jobs = [readNextChunk(readInfo)];

        if (position) {
          jobs.push(readAndIndex(position, readInfo.readBuffer));
          debug(position);
        }

        Q.all(jobs).then(results => {
          var nextReadInfo = results[0];
          var nextPosition = results[1] || {};

          readInfo.readBuffer = null;

          if (nextReadInfo.done && position) {
            debug("indexSize size: %s", (indexSize / 1024) + "KB");
            debug("index ready (took %s secs)", (Date.now() - startTime) / 1000);

            meta.size = indexSize;

            debug(meta);

            resolve();
          } else {
            next(nextReadInfo, nextPosition);
          }
        }).catch(err => reject(err));
      };

      debug("creating index");
      next({ size: size, fd: openDataFile() });
    });
  }
514808
function() {
		var length = this.promises.length,
			last = this.promises[length - 1];
		if (length && last && !last.scraper) {
			var ss = StaticScraper.create();
			last.scraper = ss;
			return ss;
		} else {
			throw new ScraperError('');
		}
	}
212132
function fin(promise, finalPromiseFactory) {
  return promise.then(function (res) {
    return finalPromiseFactory().then(function () {
      return res;
    });
  }, function (reason) {
    return finalPromiseFactory().then(function () {
      throw reason;
    });
  });
}
447482
function () {

        $global.TaskPool = $prototype ({

            constructor: function (cfg) {
                            
                            this.maxTime        = cfg && cfg.maxTime
                            this.pending        = []

                            if (this.maxConcurrency = cfg && cfg.maxConcurrency) {
                                this.numActive = 0
                                this.queue     = [] } },

            run: function (task) { var self = this

                        if (this.numActive >= this.maxConcurrency) { // queue task

                            return new Promise (function (resolve) {
                                                    self.queue.push (function () {
                                                                        return self.run  (task)
                                                                                   .then (resolve) }) }) }
                        else { // execute task

                            var p = __(task)

                            if (this.maxTime !== undefined) {
                                p = p.timeout (this.maxTime) }

                            if (this.maxConcurrency !== undefined) { // if queueing, wait until complete and pop next task

                                                           self.numActive++
                                p = p.then (function (x) { self.numActive--

                                                   return (self.queue.length &&
                                                          (self.numActive < self.maxConcurrency))
                                                                          ? self.queue.shift () ().then (_.constant (x))
                                                                          : x }) }
                            this.pending.push (p)

                            return p } },


            all: $property (function () {
                                return Promise.all (this.pending) }) }) // @hide

     */

        __.scatter = function (x, fn, cfg /* { maxConcurrency, maxTime } */) {

                    return __.then (x, function (x) {

                        if (_.isStrictlyObject (x)) {

                            var result = _.coerceToEmpty (x),
                                tasks  = new TaskPool (cfg)

                            _.each2 (x, function (v, k) {
                                            tasks.run (fn.$ (v, k, x)).then (
                                                                        function (vk) {
                                                                            if (vk) {
                                                                                result[vk[1]] = vk[0] } }) })
                            return tasks.all.then (_.constant (result)) }

                        else {
                            return __(fn, x, undefined, x).then (function (vk) { return vk[0] }) } }) }
}
949220
function createReservation(resources, start, duration) {
    var end = start + (duration * later.MIN),
        reservation = {
          resources: resources,
          start: start,
          end: end,
          duration: duration,
          success: true
        };

    applyReservation(resources, start, end);
    return reservation;
  }
638523
function buildFile() {
    var reader = readline.createInterface({
        input: fs.createReadStream(path.resolve("./src/assets/template.html"))
    });
    
    var lines = [];
    reader.on("line", line => lines.push(line));

    return new Promise(resolve => {
        reader.on("close", () => resolve(buildJsFileContents(lines)));
    });
}
745534
function randomCallback() {

  if (!randomQueue.length) {
    self.postMessage({ event: 'request-seed', amount: MAX_SIZE_RANDOM_BUFFER });
  }

  return new Promise(function(resolve) {
    randomQueue.push(resolve);
  });
}
667521
function iterator(iterId, conn) {
      var nextElems = [];
      var done = false;

      function nextPromise() {
        var kv = nextElems.pop();
        return new Promise(function (fulfill, reject) {
          fulfill(f.merge({done: done}, kv));
        });
      }

      function donePromise() {
        return new Promise(function (fulfill, reject) {
          fulfill({done: done});
        });
      }

      return {
        /**
         * Iterator next object returned from completed Iterator.next() calls.
         *
         * @typedef {Object} IteratorNext
         * @property {?(String|Object)} key -
         * If iteration not done, entry's key, otherwise undefined.
         * @property {?(String|Object)} value -
         * If iteration not done, entry's value, otherwise undefined.
         * @property {Boolean} done -
         * Indicates whether iteration has been completed.
         * When true, key and value will be undefined.
         * When false, key and value will be non-null.
         * @since 0.3
         */
        /**
         * Returns the next entry being iterated over.
         *
         * @returns {module:promise.Promise.<IteratorNext>}
         * It returns a Promise which will be completed with an instance that
         * provides the next element.
         * @memberof Iterator#
         * @since 0.3
         */
        next: function() {
          if (done) {
            logger.tracef('Iterator(iteratorId=%s) already exhausted', iterId);
            return donePromise();
          } else if (_.isEmpty(nextElems)) {
            var ctx = u.context(SMALL);
            logger.tracef(
                'Invoke iterator.next(msgId=%d,iteratorId=%s) on %s'
                , ctx.id, iterId, conn.toString()
            );
            var remote = futurePinned(ctx, 0x33, p.encodeIterId(iterId), p.decodeNextEntries(), conn);
            return remote.then(function(entries) {
              if (_.isEmpty(entries)) {
                done = true;
                return donePromise();
              } else {
                _.each(entries, function(entry) {
                  nextElems.push(entry);
                });
                return nextPromise();
              }
            });
          }
          logger.tracef('Return next from locally cached entries for iterator(iteratorId=%s)', iterId);
          return nextPromise();
        },
        /**
         * Close the iteration.
         *
         * @returns {module:promise.Promise}
         * A Promise which will be completed once the iteration has been closed.
         * @memberof Iterator#
         * @since 0.3
         */
        close: function() {
          var ctx = u.context(SMALL);
          logger.debugf('Invoke iterator.close(msgId=%d,iteratorId=%s) on %s', ctx.id, iterId, conn.toString());
          return futurePinned(
              ctx, 0x35, p.encodeIterId(iterId), p.complete(p.hasSuccess), conn);
        }
      }
    }
583109
function () {
		var that = this,
				independent, 
				dependencyNotRequired;
		
		promiseIndependent = this.saveFixturesFromArray(independentFixtures);
		promiseDelayedDependency = this.saveFixturesFromArray(delayedDependencyFixtures);
		
		promise = Q.all([ promiseIndependent, promiseDelayedDependency ])
			.then(function(models) {
				return that.saveFixturesFromArray(requiredDependencyFixtures);
			});
		
		return promise;
	}
280725
function( min, startFunc ) {
		var self = this;

		if ( min > self.state ) {
			self._stateError( startFunc || self.requireMinState );
		}

		return self;
	}