1234567891011121314151617181920212223242526 |
- class UploadTimer {
-
- constructor(timeout = 0, callback = () => {}) {
- this.timeout = timeout;
- this.callback = callback;
- this.timer = null;
- }
- clear() {
- clearTimeout(this.timer);
- }
- set() {
-
- if (!this.timeout) return false;
- this.clear();
- this.timer = setTimeout(this.callback, this.timeout);
- return true;
- }
- }
- module.exports = UploadTimer;
|