How to use the async.waterfall function in async

To help you get started, we’ve selected a few async 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 TheAdrianProject / AdrianSmartAssistant / Library / googleSpeech / stream.js View on Github external
function main ( host) {
  async.waterfall([
    function (cb) {
      getSpeechService(host, cb);
      //console.log("start");
    },
    // [START send_request]

    function sendRequest (speechService, cb) {

        console.log(chalk.green('GOOGLE SPEACH DEAMON : Analyzing speech...'));

        var startOfSpeech   = false;
        var responses       = [];
        var responseTimeout = null;
        var call            = speechService.streamingRecognize();

        // Listen for various responses
github scality / Arsenal / lib / storage / data / external / GCP / GcpApis / mpuHelper.js View on Github external
copyToMain(res, aggregateETag, params, callback) {
        // move object from mpu bucket into the main bucket
        // retrieve initial metadata then compose the object
        const copySource = res ||
            createMpuKey(params.Key, params.UploadId, 'final');
        return async.waterfall([
            next => {
                // retrieve metadata from init object in mpu bucket
                const headParams = {
                    Bucket: params.MPU,
                    Key: createMpuKey(params.Key, params.UploadId,
                        'init'),
                };
                logger.trace('retrieving object metadata');
                return this.service.headObject(headParams, (err, res) => {
                    if (err) {
                        logHelper(logger, 'error',
                            'error in createMultipartUpload - headObject',
                            err);
                        return next(err);
                    }
                    return next(null, res);
github EasyERP / EasyERP_open_source / handlers / payment.js View on Github external
if (err) {
                    return waterfallCallback(err);
                }
                fx.rates = result && result.rates ? result.rates : {};
                fx.base = result && result.base ? result.base : 'USD';
                waterfallCallback();
            });
        }

        waterfallTasks = [getRates, fetchInvoice, savePayment, invoiceUpdater, createJournalEntry];

        if (isForSale) { // todo added condition for purchase payment
            waterfallTasks.push(updateWtrack);
        }

        async.waterfall(waterfallTasks, function (err, response) {
            if (err) {
                return next(err);
            }

            res.status(201).send(response);
        });
    };
github promethe42 / cocorico / blockchain-worker / src / ballot-consumer.js View on Github external
if (!ballot.transaction) {
    next(noRetryError({error:'missing ballot transaction'}), null);
    return;
  }

  var web3 = new Web3();
  // FIXME: read URI from the config
  web3.setProvider(new web3.providers.HttpProvider(
    'http://127.0.0.1:8545'
  ));

  var signedTx = new EthereumTx(ballot.transaction);
  var address = EthereumUtil.bufferToHex(signedTx.getSenderAddress());
  var rootAccount = null;

  async.waterfall(
    [
      (callback) => updateBallotStatus(
        ballot,
        'pending',
        (err, dbBallot) => callback(err)
      ),
      // Step 0: we make sure the ballot account is a new account.
      // Each account is unique: one vote => one account => one address. If
      // the address already has some funds, then it was used before and
      // something fishy is happening:
      // 1) someone is tempering with the platform; or
      // 2) the worker stopped/crashed after initializing the account but
      // before sending the vote transaction to the blockchain: not cool, but
      // it's safer to throw an error and ask the user to vote again.
      // (callback) => accountIsNotInitialized(web3, address, callback),
      (callback) => web3.eth.getAccounts((err, acc) => {
github Trott / fs-tools / lib / fs-tools.js View on Github external
// chmod dst
      chmod = async.apply(fs.chmod, dst, stats.mode.toString(8).slice(-4));

      // reject async.series' results
      done = function (err/*, results */) { callback(err); };

      // *** file
      if (stats.isFile()) {
        async.series([async.apply(copy_file, src, dst), chmod], done);
        return;
      }

      // *** symbolic link
      if (stats.isSymbolicLink()) {
        async.waterfall([
          function (next) {
            fs.exists(dst, function (exists) {
              if (exists) {
                fstools.remove(dst, next);
                return;
              }

              next();
            });
          },
          async.apply(fs.readlink, src),
          function (linkpath, next) {
            fs.symlink(linkpath, dst, next);
          },
          chmod
        ], done);
github giper45 / DockerSecurityPlayground / app / handlers / repos.js View on Github external
function remove(req, res) {
  log.info("[ REPOS ] Delete repo ");
  async.waterfall([
    (cb) => Checker.checkParams(req.params, ['name'], cb),
    (cb) => repos.remove(req.params.name, cb)
    ], (err, results) => {
      appUtils.response("Delete repo", res, err, results);
  });
}
github deitch / imapper / lib / commands / handlers / store.js View on Github external
storeHandlers.FLAGS = function(connection, messages, isUid, flags, parsed, data, cb) {
	async.waterfall([
		function (cb) {
	    connection.replaceFlags(messages, isUid, _.pluck(flags,"value"), cb);
		},
		function (msgs,cb) {
	    sendUpdate(connection, parsed, data, msgs, cb);
		}
	],cb);
};
github appium / appium / lib / devices / ios / ios.js View on Github external
IOS.prototype.typeAndNavToUrl = function (cb) {
  var initialUrl = this.args.safariInitialUrl || 'http://127.0.0.1:' + this.args.port + '/welcome';
  var oldImpWait = this.implicitWaitMs;
  this.implicitWaitMs = 7000;
  function noArgsCb(cb) { return function (err) { cb(err); }; }
  async.waterfall([
    this.findElement.bind(this, 'name', 'URL'),
    function (res, cb) {
      this.implicitWaitMs = oldImpWait;
      this.nativeTap(res.value.ELEMENT, noArgsCb(cb));
    }.bind(this),
    this.findElements.bind(this, 'name', 'Address'),
    function (res, cb) {
      var addressEl = res.value[res.value.length -1].ELEMENT;
      this.setValueImmediate(addressEl, initialUrl, noArgsCb(cb));
    }.bind(this),
    this.findElement.bind(this, 'name', 'go'),
    function (res, cb) {
      this.nativeTap(res.value.ELEMENT, noArgsCb(cb));
    }.bind(this)
  ], function () {
    this.navToViewWithTitle(/.*/i, function (err) {
github appium / appium / lib / devices / firefoxos / firefoxos.js View on Github external
this.onConnect = function () {
    logger.debug("Firefox OS socket connected");
    var mainCb = cb;
    async.waterfall([
      function (cb) { this.getMarionetteId(cb); }.bind(this),
      function (cb) { this.createSession(cb); }.bind(this),
      function (cb) { this.launchAppByName(cb); }.bind(this),
      function (frameId, cb) { this.frame(frameId, cb); }.bind(this)
    ], function () { mainCb(null, this.sessionId); }.bind(this));
  };
github QTGate / CoNET / core / tools / imap.js View on Github external
sendDone() {
        return Async.waterfall([
            next => this.enCrypto(JSON.stringify({ done: new Date().toISOString() }), next),
            (data, next) => this.trySendToRemote(buffer_1.Buffer.from(data), next)
        ], (err) => {
            if (err)
                return saveLog(`sendDone got error [${err.message}]`);
        });
    }
}