@byloth/core 1.5.3 → 2.0.0-rc.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,35 +0,0 @@
1
- import { ReferenceException } from "./exceptions/index.js";
2
-
3
- export default class Subscribers<P extends unknown[] = [], R = void, T extends (...args: P) => R = (...args: P) => R>
4
- {
5
- protected _subscribers: T[];
6
-
7
- public constructor()
8
- {
9
- this._subscribers = [];
10
- }
11
-
12
- public add(subscriber: T): void
13
- {
14
- this._subscribers.push(subscriber);
15
- }
16
- public remove(subscriber: T): void
17
- {
18
- const index = this._subscribers.indexOf(subscriber);
19
- if (index < 0)
20
- {
21
- throw new ReferenceException("Unable to remove the requested subscriber. It was not found.");
22
- }
23
-
24
- this._subscribers.splice(index, 1);
25
- }
26
-
27
- public call(...args: P): R[]
28
- {
29
- return this._subscribers
30
- .slice()
31
- .map((subscriber) => subscriber(...args));
32
- }
33
-
34
- public get [Symbol.toStringTag]() { return "Subscribers"; }
35
- }