mirror of
https://github.com/advplyr/audiobookshelf.git
synced 2025-06-24 17:59:06 +02:00
Remove dependency express-fileupload
This commit is contained in:
parent
1dbfb5637a
commit
7aa7e662b2
20 changed files with 2782 additions and 23 deletions
26
server/libs/expressFileupload/uploadtimer.js
Normal file
26
server/libs/expressFileupload/uploadtimer.js
Normal file
|
@ -0,0 +1,26 @@
|
|||
class UploadTimer {
|
||||
/**
|
||||
* @constructor
|
||||
* @param {number} timeout - timer timeout in msecs.
|
||||
* @param {Function} callback - callback to run when timeout reached.
|
||||
*/
|
||||
constructor(timeout = 0, callback = () => {}) {
|
||||
this.timeout = timeout;
|
||||
this.callback = callback;
|
||||
this.timer = null;
|
||||
}
|
||||
|
||||
clear() {
|
||||
clearTimeout(this.timer);
|
||||
}
|
||||
|
||||
set() {
|
||||
// Do not start a timer if zero timeout or it hasn't been set.
|
||||
if (!this.timeout) return false;
|
||||
this.clear();
|
||||
this.timer = setTimeout(this.callback, this.timeout);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = UploadTimer;
|
Loading…
Add table
Add a link
Reference in a new issue