@civ-clone/core-registry
Version:
This component is used to create other registries that contain object data. This is a stub that contains all the shared methods that other classes will extend replacing the constructor with a call to the parent passing in the supported types that can be s
25 lines (22 loc) • 1.01 kB
text/typescript
export type IConstructor<T = any> = new (...args: any[]) => T;
export type IRegistryIterator<T> = (item: T, i: number) => boolean;
export interface IRegistry<T> {
readonly length: number;
accepts(entity: T | IConstructor<T>): boolean;
entries(): (T | IConstructor<T>)[];
every(iterator: IRegistryIterator<T | IConstructor<T>>): boolean;
filter(
iterator: IRegistryIterator<T | IConstructor<T>>
): (T | IConstructor<T>)[];
forEach(iterator: (item: T | IConstructor<T>, i: number) => void): void;
getBy<K extends keyof T>(
key: K,
value: T[K] extends (...args: any[]) => any ? ReturnType<T[K]> : T[K]
): (T | IConstructor<T>)[];
includes(item: T | IConstructor<T>): boolean;
indexOf(item: T | IConstructor<T>): number;
map(iterator: (item: T | IConstructor<T>, i: number) => any): any[];
register(...entities: (T | IConstructor<T>)[]): void;
some(iterator: IRegistryIterator<T | IConstructor<T>>): boolean;
unregister(...entities: (T | IConstructor<T>)[]): void;
}