import TypeDef from "./typedef" ; import { InternetObjectError } from "../errors/io-error" ; import ErrorCodes from "../errors/io-error-codes" ; const defsList = [ ] ; const defs = { } ; export class TypedefRegistry { param type param typeDef public static register ( type , typeDef ) { if ( defs [ type ] === undefined ) { defs [ type ] = typeDef ; defsList . push ( type ) ; } } param type public static unregister ( type ) { if ( defs [ type ] !== undefined ) { delete defs [ type ] ; const index = defsList . indexOf ( type ) ; defsList . splice ( index , 1 ) ; } } /**
     * Gets the array of registered type names.
     */ public static get types ( ) : string [ ] { return [ ... defsList ] ; } param type public static get ( type ) { const typeDef = defs [ type ] ; if ( typeDef === undefined ) { throw new InternetObjectError ( ErrorCodes . invalidType , type ) ; } return typeDef ; } public static isRegisteredType ( typeName ) { return typeName in defs ; } }