UNPKG

@ayanaware/bento

Version:

Modular runtime framework designed to solve complex tasks

36 lines (35 loc) 1.13 kB
/** * ReferenceManager associates constructors with a id */ export declare class ReferenceManager<T extends { name: string; }> { private readonly references; private readonly rewrites; /** * Resolves the name of the given entity. * If the given entity is already a string, the same string will be returned. * * @param reference Reference * @param error Throw Error on resolve failure * * @returns Entity Name or null */ resolve(reference: string | T, error?: boolean): string; /** * Registers an entity in a reference map so the type can be used instead of the entity name. * This only works if the entity has a constructor function. * * @param entity The entity to be registered */ add(entity: T, name?: string): void; /** * Removes an entity from the reference map. * This only works if the entity has a constructor function. * * @param entity The entity to be removed */ remove(entity: T): void; addRewrite(entity: string | T, rewrite: string): void; removeRewrite(entity: string | T): void; }