Skip to content

Commit

Permalink
fix: type
Browse files Browse the repository at this point in the history
  • Loading branch information
wan2land committed Jun 23, 2024
1 parent 258383a commit e96d9a1
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions iterable_weak_set.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,17 @@
export class IterableWeakSet<T extends object> implements WeakSet<T>, Set<T> {
export class IterableWeakSet<T extends object> implements
WeakSet<T>,
Omit<
Set<T>,
| "add" // override to return this
| "forEach" // override to call callbackfn with IterableWeakSet
| "union" // not implemented
| "intersection" // not implemented
| "difference" // not implemented
| "symmetricDifference" // not implemented
| "isSubsetOf" // not implemented
| "isSupersetOf" // not implemented
| "isDisjointFrom" // not implemented
> {
#weakMap = new WeakMap<T, WeakRef<T>>();
#set = new Set<WeakRef<T>>();
#registry = new FinalizationRegistry<WeakRef<T>>(
Expand Down Expand Up @@ -50,7 +63,7 @@ export class IterableWeakSet<T extends object> implements WeakSet<T>, Set<T> {
}

forEach(
callbackfn: (value: T, value2: T, set: Set<T>) => void,
callbackfn: (value: T, value2: T, set: IterableWeakSet<T>) => void,
thisArg?: unknown,
): void {
for (const tuple of this.entries()) {
Expand Down

0 comments on commit e96d9a1

Please sign in to comment.