@mieweb/wikigdrive
Version:
Google Drive to MarkDown synchronization
34 lines (33 loc) • 823 B
JavaScript
export class StopWatch {
constructor() {
Object.defineProperty(this, "start", {
enumerable: true,
configurable: true,
writable: true,
value: void 0
});
Object.defineProperty(this, "end", {
enumerable: true,
configurable: true,
writable: true,
value: void 0
});
this.start = Date.now();
}
stop() {
this.end = Date.now();
}
toString(limitMs = 500) {
if (!this.end) {
this.stop();
}
const delta = this.end - this.start;
if (delta > limitMs) {
if (delta > 1000) {
return `${Math.round(delta / 100) / 10}s`;
}
return `${delta}ms`;
}
return '';
}
}