export interface PoolKeyMap { [key: string]: T; } /** * Pool of entities. */ export interface Pool = PoolKeyMap> { /** * Checks if pool contains item with given key. * * @param key */ has(key: keyof M | string): boolean; /** * Returns item from pool by given key. * * @param key */ get(key: K): K extends keyof M ? M[K] : T; /** * Adds item to pool by given key. Should throw if item with given key is already added to pool, unless * 'replace' argument is set to true. * * @param key * @param item * @param replace */ add(key: K, item: K extends keyof M ? M[K] : T, replace?: boolean): void; /** * Removes item with given key from pool. * * @param key */ remove(key: keyof M | string): void; /** * Returns all keys, added to pool. */ keys(): (keyof M | string)[]; /** * Returns array of all items in pool. */ items(): T[]; }