MCPcopy
hub / github.com/alsotang/node-lessons / fetchUrl

Function fetchUrl

lesson5/app.js:4–12  ·  view source on GitHub ↗
(url, callback)

Source from the content-addressed store, hash-verified

2
3var concurrencyCount = 0;
4var fetchUrl = function (url, callback) {
5 var delay = parseInt((Math.random() * 10000000) % 2000, 10);
6 concurrencyCount++;
7 console.log('现在的并发数是', concurrencyCount, ',正在抓取的是', url, ',耗时' + delay + '毫秒');
8 setTimeout(function () {
9 concurrencyCount--;
10 callback(null, url + ' html content');
11 }, delay);
12};
13
14var urls = [];
15for(var i = 0; i < 30; i++) {

Callers 1

app.jsFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected