add size to async equality map
This commit is contained in:
@@ -149,6 +149,7 @@ export function createEqualityMap<K, V>(keyComparer?: Equater<K>): EqualityMap<K
|
||||
}
|
||||
|
||||
export interface AsyncEqualityMap<K, V> extends Iterable<[K, V]> {
|
||||
readonly size: number;
|
||||
get(key: K): Promise<V | undefined>;
|
||||
set(key: K, value: V): Promise<V | undefined>;
|
||||
contains(key: K): Promise<boolean>;
|
||||
@@ -162,6 +163,10 @@ export interface AsyncEqualityMap<K, V> extends Iterable<[K, V]> {
|
||||
class NativeAsyncEqualityMap<K, V> implements AsyncEqualityMap<K, V> {
|
||||
readonly #map = new Map<K, V>();
|
||||
|
||||
get size() {
|
||||
return this.#map.size;
|
||||
}
|
||||
|
||||
async get(key: K) {
|
||||
return this.#map.get(key);
|
||||
}
|
||||
@@ -211,6 +216,10 @@ class CustomAsyncEqualityMap<K, V> implements AsyncEqualityMap<K, V> {
|
||||
this.#keyComparer = keyComparer;
|
||||
}
|
||||
|
||||
get size() {
|
||||
return this.#list.length;
|
||||
}
|
||||
|
||||
async get(key: K) {
|
||||
for (const entry of this.#list) {
|
||||
if (await this.#keyComparer(key, entry[0])) {
|
||||
|
||||
Reference in New Issue
Block a user