How to use the q.all function in q

To help you get started, we’ve selected a few q examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github katzer / cordova-plugin-badge / platforms / windows / cordova / lib / MSBuildTools.js View on Github external
function findAllAvailableVersionsFallBack () {
    // console.log('findAllAvailableVersionsFALLBACK');

    var versions = ['15.5', '15.0', '14.0', '12.0', '4.0'];
    events.emit('verbose', 'Searching for available MSBuild versions...');

    return Q.all(versions.map(checkMSBuildVersion)).then(function (unprocessedResults) {
        return unprocessedResults.filter(function (item) {
            return !!item;
        });
    });
}
github bower / bower / lib / core / Manager.js View on Github external
}
            }

            // Mark endpoint as unresolvable if the parent is also unresolvable
            childDecEndpoint.unresolvable = !!decEndpoint.unresolvable;

            // Otherwise, just fetch it from the repository
            decEndpoint.dependencies[key] = childDecEndpoint;
            childDecEndpoint.dependants = [decEndpoint];
            this._fetch(childDecEndpoint);
        },
        this
    );

    if (pending.length > 0) {
        Q.all(pending).then(
            function() {
                this._parseDependencies(decEndpoint, pkgMeta);
            }.bind(this)
        );
    }
};
github traviswimer / dir-to-json / src / createDirectoryObject.js View on Github external
.then(function( files ){

		// Recursively examine directory's children
		var promises = [];
		files.forEach(function( newFileName ){
			promises.push( createDirectoryObject( rootDir, fileName+'/'+newFileName, options ) );
		});

		// Wait for all children to complete before resolving main promise
		Q.all( promises ).then(function(data){

			if( options.sortType ){
				data = sortType( data );
			}

			fileInfo.children = data;
			deferred.resolve( fileInfo );
		});

	})
	.catch(function( err ){
github CodeboxIDE / codebox / src / core / cb.project.detect / main.js View on Github external
function projectTypes(projectDir) {
    var _supports = _.partial(supports, projectDir);

    // Try all our project types, return first supported
    // if none supported return NONE
    return Q.all(_.map(SUPPORTED, _supports))
    .then(function(supported_list) {
        var idx = supported_list.indexOf(true);
        if(idx === -1) {
            throw new Error("No supported project");
        }

        // List of supported project types
        return _.filter(SUPPORTED, function(lang, idx) {
            return supported_list[idx];
        });
    })
    .fail(utils.constant([NONE]));
}
github angular / dgeni / packages / jsdoc / processors / write-files.js View on Github external
process: function(docs) {
    return Q.all(_.map(docs, function(doc) {

      if ( !doc.outputPath ) {
        console.log(doc);
        log.error('Invalid document "' + doc.id + ', ' + doc.docType + '" - this document has no outputPath.');
      }

      var outputFile = path.resolve(outputFolder, doc.outputPath);

      log.silly('writing file', outputFile);
      return writer.writeFile(outputFile, doc.renderedContent).then(function() {
        log.debug('written file', outputFile);
        return outputFile;
      });
    }));
  }
};
github stanford-oval / thingengine-core / lib / object_set.js View on Github external
addMany: function(objs) {
        if (this._readonly)
            throw new Error('ObjectSet is readonly');

        var promise = Q.all(objs);
        this._promises.push(promise);
        return promise.then(function(objs) {
            objs.forEach(function(o) {
                this.addOne(o);
            }, this);
        }.bind(this));
    },
github kuzzleio / kuzzle / features / support / hooks.js View on Github external
setTimeout(() => {
      [api.world.fakeIndex, api.world.fakeAltIndex, api.world.fakeNewIndex].forEach(index => {
        promises.push(api.deleteIndex(index));
      });

      q.all(promises)
        .then(() => {
          callback();
        })
        .catch(error => { callback(new Error(error)); });
    }, 0);
github webgme / webgme / src / server / storage / safestorage.js View on Github external
})
                        .catch(function (err) {
                            if (err.message.indexOf('Project does not exist') > -1) {
                                self.logger.error('Inconsistency: project exists in user "' + data.username +
                                    '" and in _projects, but not as a collection on its own: ', project._id);
                                branchesDeferred.resolve();
                            } else {
                                branchesDeferred.reject(err);
                            }
                        });

                    return branchesDeferred.promise;
                }

                if (data.branches === true) {
                    return Q.all(filterArray(projects).map(getBranches));
                } else {
                    deferred.resolve(filterArray(projects));
                }
            })
            .then(function (projectsAndBranches) {
github IMA-WorldHealth / bhima / server / controllers / finance / reports / account_reference / index.js View on Github external
return;
  }

  const getFiscalYearSQL = `
    SELECT p.id, p.start_date, p.end_date, p.fiscal_year_id, p.number,
      fy.start_date AS fiscalYearStart, fy.end_date AS fiscalYearEnd
    FROM period p JOIN fiscal_year fy ON p.fiscal_year_id = fy.id
    WHERE p.id = ?;
  `;

  const dbPromises = [
    db.one(getFiscalYearSQL, [params.period_id]),
    AccountReference.computeAllAccountReference(params.period_id, params.reference_type_id),
  ];

  Q.all(dbPromises)
    .spread((period, data) => {
      _.merge(context, { period, data });
      context.referenceTypeLabel = params.reference_type_id ? params.reference_type_label : '';

      return reporting.render(context);
    })
    .then(result => {
      res.set(result.headers).send(result.report);
    })
    .catch(next)
    .done();
}