UNPKG

@obsidize/rx-map

Version:

ES6 Map with rxjs extensions for change detection

22 lines (21 loc) 595 B
import { castArray } from '../common/utility'; /** * Simple cache container used to relate a single id to a set of foreign keys. * Allows for fast lookup times of one-to-many projections. */ export class OneToManyContext { constructor(id) { this.id = id; this.foreignKeySet = new Set(); } clear() { this.foreignKeySet.clear(); } getForeignKeys() { return Array.from(this.foreignKeySet); } setForeignKeys(keys) { this.clear(); castArray(keys).forEach(key => this.foreignKeySet.add(key)); } }