import { SID_of } from '@strut/sid'; import { nullthrows } from '@strut/utils'; import { IModel } from './INode.js'; export default class ImmutableHeteroModelMap { protected map: Map, IModel | null> = new Map(); get, D extends {}>(id: SID_of): T | null { const ret = this.map.get(id); if (ret == null) { return null; } return ret as T; } getx, D extends {}>(id: SID_of): T { return nullthrows(this.map.get(id)) as T; } } export class MutableHeteroModelMap extends ImmutableHeteroModelMap { set, D extends {}>(id: SID_of, n: T | null): void { this.map.set(id, n); } }