-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Vasile
committed
May 23, 2017
1 parent
a47cb27
commit 38045d5
Showing
1 changed file
with
31 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
"use strict"; | ||
|
||
var evenDouble = function(v, callback){ | ||
var start = new Date(); | ||
setTimeout(function(){ | ||
var end = new Date(); | ||
var time = end.getTime() - start.getTime(); | ||
|
||
if (v % 2 == 0){ | ||
callback.call(null, 1, v*2, time); | ||
}else{ | ||
callback.call(null, 0, -1, time); | ||
} | ||
},generateNumber(1,10) * 100); | ||
} | ||
|
||
function generateNumber(start,end){ | ||
return Math.floor(Math.random() * end) + start ; | ||
} | ||
|
||
var handler = function(err,result,time){ | ||
if (err){ | ||
console.log("ERR"); | ||
}else{ | ||
console.log("result: " + result + " in " + time + "ms"); | ||
}; | ||
}; | ||
|
||
for(let i = 0; i < 10; i++) { | ||
evenDouble(i,handler); | ||
} |