-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathutil.js
More file actions
29 lines (25 loc) · 737 Bytes
/
Copy pathutil.js
File metadata and controls
29 lines (25 loc) · 737 Bytes
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
class StopWatch {
static start() {
this.startTime = new Date().getTime();
}
static stop() {
let duration = new Date().getTime() - this.startTime;
if (duration > 5000)
console.log('duration:', duration / 1000, "sec");
else
console.log('duration:', duration, "ms");
}
}
class Random {
constructor(min, max) {
this.min = min || 0;
this.max = max || 0;
this.prev = null;
}
next() {
let num = Math.floor((Math.random() * (this.max - this.min + 1)) + this.min);
this.prev = (num === this.prev && this.min !== this.max) ? this.next() : num;
return this.prev;
};
}
module.exports = { Random, StopWatch };