impl map helper
This commit is contained in:
parent
2f9bb73107
commit
525c6fa954
2 changed files with 37 additions and 13 deletions
lib
12
lib/idv.ts
12
lib/idv.ts
|
@ -85,6 +85,18 @@ export class Idv {
|
|||
: parseDistinguisher(distinguisher)
|
||||
);
|
||||
}
|
||||
|
||||
public getMap<T>(
|
||||
name: string,
|
||||
parseDocument: DocumentParser<T>
|
||||
): Record<string, T> {
|
||||
return Object.fromEntries(
|
||||
(this.collections[name] ?? []).map(([distinguisher, document]) => [
|
||||
distinguisher,
|
||||
parseDocument(document),
|
||||
])
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
export const StringFromDocument = (lines: string[]) => lines.join("\n");
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue