How to use the neo-async.waterfall function in neo-async

To help you get started, we’ve selected a few neo-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 validitylabs / hopr / src / getPubKey.js View on Github external
            node.dialProtocol(targetPeerInfo, PROTOCOL_DELIVER_PUBKEY, (err, conn) => waterfall([
                (cb) => pull(
                    conn,
                    lp.decode({
                        maxLength: MARSHALLED_PUBLIC_KEY_SIZE
                    }),
                    pull.take(1),
                    pull.drain((data) => cb(null, data))
                ),
                (pubKey, cb) => PeerId.createFromPubKey(pubKey, cb),
                (peerId, cb) => {
                    const peerInfo = new PeerInfo(peerId)
                    peerInfo.multiaddrs.replace([], targetPeerInfo.multiaddrs.toArray())
                    cb(null, peerInfo)
                }
            ], cb))
        }
github linitix / nzero-push / lib / endpoints / channel_endpoint.js View on Github external
module.exports = function (name, callback, self) {
  var nameErrors = Utils.validateJSONWithSchema(name, "string", stringSchema);

  if ( nameErrors )
    return callback(new InvalidPayloadError("Must be a string", nameErrors));

  async.waterfall(
    [
      function (next) { self.requestsManager.verifyCredentials(next); },
      function (next) { self.requestsManager.channel(name, next); }
    ],
    callback
  );
};
github linitix / nzero-push / lib / endpoints / notify_endpoint.js View on Github external
function notifyPlatform(deviceTokens, notification, callback, self) {
  async.waterfall(
    [
      function (next) { self.requestsManager.verifyCredentials(next); },
      function (next) { self.requestsManager.notify(deviceTokens, notification, next); }
    ],
    callback
  );
}
github validitylabs / hopr / src / paymentChannels / open.js View on Github external
module.exports = (self) => (to, cb) => {
    let restoreTx

    waterfall([
        (cb) => self.node.peerRouting.findPeer(to, cb),
        (peerInfo, cb) => self.node.dialProtocol(peerInfo, PROTOCOL_PAYMENT_CHANNEL, cb),
        (conn, cb) => {
            restoreTx = new Transaction()

            restoreTx.nonce = randomBytes(Transaction.NONCE_LENGTH)
            restoreTx.value = (new BN(toWei('1', 'shannon'))).toBuffer('be', Transaction.VALUE_LENGTH)
            restoreTx.index = numberToBuffer(1, Transaction.INDEX_LENGTH)

            restoreTx.sign(self.node.peerInfo.id)

            pull(
                pull.once(restoreTx.toBuffer()),
                lp.encode(),
                conn,
                lp.decode(),
github validitylabs / hopr / src / network / crawl.js View on Github external
function queryNode(peerId, cb) {
        waterfall([
            (cb) => node.peerRouting.findPeer(PeerId.createFromB58String(peerId), cb),
            (peerInfo, cb) => node.dialProtocol(peerInfo, PROTOCOL_CRAWLING, cb),
            (conn, cb) => pull(
                conn,
                lp.decode({
                    maxLength: MARSHALLED_PUBLIC_KEY_SIZE
                }),
                pull.asyncMap((pubKey, cb) => PeerId.createFromPubKey(pubKey, cb)),
                pull.filter(peerId => {
                    if (peerId.isEqual(node.peerInfo.id))
                        return false

                    const found = node.peerBook.has(peerId.toB58String())
                    node.peerBook.put(new PeerInfo(peerId))

                    return !found
github mcollina / fastfall / bench.js View on Github external
function benchNeoAsync (done) {
  neoAsync.waterfall(toCall, done)
}
github linitix / nzero-push / lib / endpoints / register_endpoint.js View on Github external
module.exports = function (deviceTokens, channels, callback, self) {
  var deviceTokensErrors = Utils.validateJSONWithSchema(deviceTokens, "device_tokens", deviceTokensSchema);

  if ( deviceTokensErrors )
    return callback(new InvalidPayloadError("Device tokens must be an array with at least one item or unique items of type string", deviceTokensErrors));

  debug("Device tokens: " + JSON.stringify(deviceTokens));

  async.waterfall(
    [
      function (next) { self.requestsManager.verifyCredentials(next); },
      function (next) {
        if ( typeof channels === "function" )
          registerDeviceTokens(deviceTokens, next, self);
        else
          registerDeviceTokensForChannels(deviceTokens, channels, next, self);
      }
    ],
    callback
  );
};
github linitix / nzero-push / lib / endpoints / broadcast_endpoint.js View on Github external
function broadcastDevices(notification, callback, self) {
  var notificationErrors = Utils.validateJSONWithSchema(notification, "notification", notificationSchema);

  if ( notificationErrors )
    return callback(new InvalidPayloadError("Unknown notification object type. Must be a valid iOS/MacOS, Safari or Android notification object", notificationErrors));

  debug("Notification object: " + JSON.stringify(notification));

  async.waterfall(
    [
      function (next) { self.requestsManager.verifyCredentials(next); },
      function (next) { self.requestsManager.broadcast(null, notification, next); }
    ],
    callback
  );
}
github suguru03 / func-comparator / sample / async / sample.waterfall.js View on Github external
'neo-async': function(callback) {
    neo_async.waterfall(tasks, callback);
  }
};
github pirxpilot / postcss-cli / index.js View on Github external
var options = {
      from: input,
      to: output
    };

    Object.keys(commonOptions).forEach(function(opt) {
      options[opt] = commonOptions[opt];
    });

    processor
      .process(css, options)
      .then(function(result) { fn(null, result); })
      .catch(fn);
  }

  async.waterfall([
    async.apply(fs.readFile, input),
    doProcess,
    async.apply(dumpWarnings),
    async.apply(writeResult, output)
  ], fn);
}