1
0

add element iterators to async collections

This commit is contained in:
2024-05-13 22:42:43 +02:00
parent 1f8e8039b6
commit 7553b70882
2 changed files with 40 additions and 0 deletions

View File

@@ -111,6 +111,7 @@ export interface AsyncEqualitySet<T> extends Iterable<T> {
contains(obj: T): Promise<boolean>;
remove(obj: T): Promise<boolean>;
clear(): void;
values(): IterableIterator<T>;
}
class NativeAsyncEqualitySet<T> implements AsyncEqualitySet<T> {
@@ -138,6 +139,10 @@ class NativeAsyncEqualitySet<T> implements AsyncEqualitySet<T> {
this.#set.clear();
}
values() {
return this.#set.values();
}
[Symbol.iterator]() {
return this.#set[Symbol.iterator]();
}
@@ -192,6 +197,10 @@ class CustomAsyncEqualitySet<T> implements AsyncEqualitySet<T> {
this.#list.length = 0;
}
values() {
return this[Symbol.iterator]();
}
[Symbol.iterator]() {
return this.#list[Symbol.iterator]();
}