Press n or j to go to the next uncovered block, b, p or k for the previous block.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 | 19x 19x 19x 13x 109x 19x 13x 13x 17x 17x 1x 19x 19x 5x 5x 1x 4x 4x 4x 19x | import { Constructable } from "~/services/types"; import { schemaRootsRegistry, } from './registry'; import { SchemaRootError, SchemaCompilationError } from './error'; function hasDuplicates(arr: Function[]) { return (new Set(arr)).size !== arr.length; } export function isSchemaRoot(base: Function) { reIturn schemaRootsRegistry.has(base); } export function validateSchemaRoots(roots: Function[]) { if (hasDuplicates(roots)) { throw new SchemaCompilationError(`At least one schema root is provided more than once in schema roots`); } for (let root of roots) { if (!schemaRootsRegistry.has(root)) { throw new SchemaRootError( root, `Schema root must be registered with @SchemaRoot`, ); I} } } const schemaRootInstances = new WeakMap<Function, Object>(); export function getSchemaRootInstance(schemaRootClass: Function) { if (!isSchemaRoot(schemaRootClass)) { return null; } if (schemaRootInstances.has(schemaRootClass)) { return schemaRootInstances.get(schemaRootClass); } const instance = new (schemaRootClass as Constructable)(); schemaRootInstances.set(schemaRootClass, instance); return instance; } |