-
Notifications
You must be signed in to change notification settings - Fork 397
/
t.js
38 lines (33 loc) · 870 Bytes
/
t.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
var moment = require('moment');
exports.inc = function(n, callback, timeout) {
timeout = timeout || 200;
setTimeout(function() {
callback(null, n+1);
}, timeout);
};
exports.fire = function(obj, callback, timeout) {
timeout = timeout || 200;
setTimeout(function() {
callback(null, obj);
}, timeout);
};
exports.err = function(errMsg, callback, timeout) {
timeout = timeout || 200;
setTimeout(function() {
callback(errMsg);
}, timeout);
};
// utils
exports.log = function(msg, obj) {
process.stdout.write(moment().format('ss.SSS')+'> ');
if(obj!==undefined) {
process.stdout.write(msg);
console.log(obj);
} else {
console.log(msg);
}
};
exports.wait = function(mils) {
var now = new Date;
while(new Date - now <= mils);
}