web chat
This commit is contained in:
18
JavaScript/web-chat/utils.js
Normal file
18
JavaScript/web-chat/utils.js
Normal file
@@ -0,0 +1,18 @@
|
||||
module.exports.currenttime = function() {
|
||||
let d = new Date(Date.now());
|
||||
return `[${pad(d.getHours(), 2)}:${pad(d.getMinutes(), 2)}:${pad(d.getSeconds(), 2)}]`;
|
||||
}
|
||||
|
||||
function pad(n, width, z) {
|
||||
z = z || '0';
|
||||
n = n + '';
|
||||
return n.length >= width ? n : new Array(width - n.length + 1).join(z) + n;
|
||||
}
|
||||
|
||||
module.exports.sleep = function(ms) {
|
||||
return new Promise((resolve, reject) => {
|
||||
setTimeout(() => {
|
||||
resolve();
|
||||
}, ms);
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user