zoukankan      html  css  js  c++  java
  • async.waterfall

    async.waterfall

      if any of the tasks pass an error to their own callback, the next function is not executed, and the main callback is immediately called with the error.

    async.waterfall([
        function(callback) {
            callback(null, 'one', 'two');
        },
        function(arg1, arg2, callback) {
            // arg1 now equals 'one' and arg2 now equals 'two'
            callback(null, 'three');
        },
        function(arg1, callback) {
            // arg1 now equals 'three'
            callback(null, 'done');
        }
    ], function (err, result) {
        // result now equals 'done'
    });
    View Code
    // Or, with named functions:
    async.waterfall([
        myFirstFunction,
        mySecondFunction,
        myLastFunction,
    ], function (err, result) {
        // result now equals 'done'
    });
    function myFirstFunction(callback) {
        callback(null, 'one', 'two');
    }
    function mySecondFunction(arg1, arg2, callback) {
        // arg1 now equals 'one' and arg2 now equals 'two'
        callback(null, 'three');
    }
    function myLastFunction(arg1, callback) {
        // arg1 now equals 'three'
        callback(null, 'done');
    }
    View Code

    参考:https://caolan.github.io/async/docs.html#waterfall

  • 相关阅读:
    HDU
    HDU
    HDU
    CodeForces
    还没有过的题目记录
    HDU
    FZU
    排序:根据数组里某个对象排序
    获取当前毫秒数
    选择日期默认月初到月末
  • 原文地址:https://www.cnblogs.com/tekkaman/p/7490846.html
Copyright © 2011-2022 走看看