UNPKG

json-schema-describes-subset

Version:

Tools for static JSON schema analysis, including functions to determine if one schema describes a subset of another or if a schema describes the empty set or to convert a schema to its disjunctive normal form (DNF).

32 lines 895 B
export class InstancesByConstructor { #map = new Map(); constructor(instances) { if (instances !== undefined) { this.push(...instances); } } push(...instances) { for (const instance of instances) { const mappedInstances = this.#map.get(instance.constructor); if (mappedInstances === undefined) { this.#map.set(instance.constructor, [instance]); } else { mappedInstances.push(instance); } } } get(constructor) { return (this.#map.get(constructor) ?? []); } has(constructor) { return this.#map.has(constructor); } delete(constructor) { return this.#map.delete(constructor); } getConstructors() { return this.#map.keys(); } } //# sourceMappingURL=instances-by-constructor.js.map