pre-2.2.8

This commit is contained in:
zsviczian
2024-07-04 20:15:33 +02:00
parent 325bfd825f
commit 4a430f5fe7
43 changed files with 2477 additions and 1729 deletions

18
src/utils/WeakArray.ts Normal file
View File

@@ -0,0 +1,18 @@
export class WeakArray<T extends object> {
private weakArray: WeakRef<T>[] = [];
constructor() {}
push(obj: T) {
this.weakArray.push(new WeakRef(obj));
}
forEach(callback: (obj: T, index: number) => void) {
this.weakArray.forEach((ref, index) => {
const obj = ref.deref();
if (obj) {
callback(obj, index);
}
});
}
}