Nodejs Async.Parallel parameter Receive

Source: Internet
Author: User

Async.Parallel is the control method of the IO parallel in the process control, if there is no IO operation inside the async.parallel, the function execution in the inside is serial.

Here we discuss the problem of parameter reception, on the code:

var async = require (' async '), function Process1 (CB) {var tx1 = {address: ' Dadada '};var total1 = 1;return CB (NULL,TX1,TOTAL1) ;} function Process2 (CB) {var tx2 = {address: "qweweee"};var Total2 = 2;return CB (NULL,TX2,TOTAL2);} Async.Parallel ([function (done) {Process1] (done),},function (done) {process2 (done);}],function (err,tx,total) { Console.log (Tx[0][0]) Console.log (tx[0][1]); Console.log (tx[1][0)); Console.log (tx[1][1]);//console.log (Total[0]) ;//console.log (total[1);});

Can see PROCESS1 and process2 have three parameters, we receive the time is not to use three parameters to receive it? In fact, in addition to the first err, only need a accept parameter can be, if there is superfluous, then he is in the form of an array to display, the above code to run the result is:

{address: ' Dadada '}1{address: ' Qweweee '}2

  

Nodejs Async.Parallel parameter Receive

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.