Js inside callback ()?

  node.js, question

Lz beginner nodejs, met the following code according to the tutorial today:

var async = require('async');
 
 var concurrencyCount = 0;
 var fetchUrl = function (url, callback) {
 Vardelay = parseint (math.random () * 10000000) percentage 2000, 10);
 ConcurrencyCount plus;
 Log ('the current concurrencyCount is', concurrency count,', what is being retrieved is', url,', time consuming' plus delay plus' milliseconds');
 setTimeout(function () {
 concurrencyCount--;
 Callback(null, url plus 'htmlcontent');
 }, delay);
 };
 
 var urls = [];
 for(var i = 0;   i < 30;  I plus)
 Urls.push('http://datasource_' plus i);
 bracket
 
 async.mapLimit(urls, 5, function (url, callback) {
 fetchUrl(url, callback);
 }, function (err, result) {
 console.log('final:');
 console.log(result);
 });

Questions:

How did the callback () here become the function (err, result) {...}?  My understanding is that there should be a function instance that directly writes a callback when calling a fetchUrl(url, callback). Does async specify this?

First of all, in the programurlsThe array contains 30 URLs. It is not difficult to request these 30 URLs, but it is necessary toThese 30 URL requests control the number of concurrent requests and return all results at the end of all requests.Because of the asynchronous nature of Node.js, this is very difficult to implement. So it was used in the codeconcurrency controlAsync.js

async.mapLimit(urls, 5, function (url, callback) {
 fetchUrl(url, callback);
 }, function (err, result) {
 console.log('final:');
 console.log(result);
 });

MapLimit has four parameters: (urls, 5, function1, function2)
The above code means: traversalurlsEach element in the array executes function1 (that is, function1 will execute 30 times). The first parameter of function1 isurlsThe second parameter callback is to notify async.js that I have finished executing your HTTP request and can do other things. The parameters of the callback function are specified by async.jsThe first parameter must be errJs when an error occurs.
Of the async.mapLimit functionFunction2 is called when all 30 requests are completed or when the callback(err) is called in error for the above requests, two parameters of function2function (err, result)The first number is wrong and the second is the result of all requests.

About Async.js can learn from one of my blogs:http://xxgblog.com/2015/12/22/nodejs-asy …