UNPKG

@clickup/ent-framework

Version:

A PostgreSQL graph-database-alike library with microsharding and row-level security

12 lines (10 loc) 245 B
export class DefaultMap<K, V> extends Map<K, V> { getOrAdd(k: K, DefConstructor: new () => V): V { if (!this.has(k)) { const def = new DefConstructor(); this.set(k, def); return def; } return this.get(k)!; } }