diff --git a/types/storage-map.ts b/types/storage-map.ts index 4e71abe..70a09a0 100644 --- a/types/storage-map.ts +++ b/types/storage-map.ts @@ -3,7 +3,10 @@ import { Compiler } from "../compiler/compiler.ts"; import { DX_PTR } from "../runtime/constants.ts"; import { Pointer } from "../runtime/pointers.ts"; -import { Storage } from "../storage/storage.ts"; +import { MatchOptions, Storage } from "../storage/storage.ts"; +import { Class } from "../utils/global_types.ts"; +import { MatchInput, MatchResult, match } from "../utils/match.ts"; +import { Type } from "./type.ts"; /** @@ -275,5 +278,8 @@ export class StorageMap extends StorageWeakMap { await Promise.all(promises); } + match(valueType:Class|Type, matchInput: MatchInput, options?: Options): Promise> { + return match(this as unknown as StorageMap, valueType, matchInput, options) + } } \ No newline at end of file diff --git a/utils/match.ts b/utils/match.ts index fffbea6..19c2c1b 100644 --- a/utils/match.ts +++ b/utils/match.ts @@ -2,6 +2,7 @@ import { StorageSet } from "../types/storage_set.ts"; import { Type } from "../types/type.ts"; import type { Class } from "./global_types.ts"; import { MatchInput, MatchResult, MatchOptions, Storage } from "../storage/storage.ts"; +import { StorageMap } from "../types/storage-map.ts"; export type { MatchInput, MatchOptions, MatchResult } from "../storage/storage.ts"; @@ -12,7 +13,7 @@ export type { MatchInput, MatchOptions, MatchResult } from "../storage/storage.t * @param limit * @returns */ -export async function match(inputSet: StorageSet, valueType:Class|Type, match: MatchInput, options?: Options): Promise> { +export async function match(inputSet: StorageSet|StorageMap, valueType:Class|Type, match: MatchInput, options?: Options): Promise> { options ??= {} as Options; const found = new Set(); const matchOrEntries = (match instanceof Array ? match : [match]).map(m => Object.entries(m)) as [keyof T, T[keyof T]][][];