mirror of
https://github.com/advplyr/audiobookshelf.git
synced 2025-08-31 15:19:42 +02:00
Fix:Include Watcher as lib with no dependencies and fix tiny-readdir bug #610
This commit is contained in:
parent
160dac109d
commit
ec6e70725c
34 changed files with 2187 additions and 281 deletions
39
server/libs/watcher/aborter/signal.js
Normal file
39
server/libs/watcher/aborter/signal.js
Normal file
|
@ -0,0 +1,39 @@
|
|||
"use strict";
|
||||
/* IMPORT */
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
/* ABORT SIGNAL */
|
||||
var AbortSignal = /** @class */ (function () {
|
||||
function AbortSignal() {
|
||||
/* VARIABLES */
|
||||
this.aborted = false;
|
||||
this.listeners = {};
|
||||
}
|
||||
/* EVENTS API */
|
||||
AbortSignal.prototype.addEventListener = function (event, listener) {
|
||||
var listeners = this.listeners[event] || (this.listeners[event] = []);
|
||||
listeners.push(listener);
|
||||
};
|
||||
AbortSignal.prototype.removeEventListener = function (event, listener) {
|
||||
var listeners = this.listeners[event];
|
||||
if (!listeners)
|
||||
return;
|
||||
listeners.splice(listeners.indexOf(listener), 1);
|
||||
};
|
||||
AbortSignal.prototype.dispatchEvent = function (event) {
|
||||
var listeners = this.listeners[event];
|
||||
if (!listeners)
|
||||
return true;
|
||||
listeners.slice().forEach(function (listener) { return listener(); });
|
||||
return true;
|
||||
};
|
||||
/* API */
|
||||
AbortSignal.prototype.abort = function () {
|
||||
if (this.aborted)
|
||||
return;
|
||||
this.aborted = true;
|
||||
this.dispatchEvent('abort');
|
||||
};
|
||||
return AbortSignal;
|
||||
}());
|
||||
/* EXPORT */
|
||||
exports.default = AbortSignal;
|
Loading…
Add table
Add a link
Reference in a new issue