asJsDictionary, asKeyedDictionary

This commit is contained in:
Tony Garnock-Jones 2024-03-27 16:18:34 +01:00
parent 9ecbd0bdd1
commit 7657952993
1 changed files with 10 additions and 0 deletions

View File

@ -211,6 +211,16 @@ export class DictionaryMap<T extends Embeddable = GenericEmbedded, V = Value<T>>
this.simplify();
return this.value;
}
asJsDictionary(): JsDictionary<V> {
this.simplify();
if (!this.j) throw new Error("Cannot represent general dictionary as JsDictionary");
return this.j;
}
asKeyedDictionary(): KeyedDictionary<T, Value<T>, V> {
return this.k ?? new KeyedDictionary<T, Value<T>, V>(JsDictionary.entries(this.j!));
}
}
export namespace Dictionary {