UNPKG

@puregram/scenes

Version:

Simple implementation of middleware-based scene management for puregram

24 lines (23 loc) 847 B
declare type CacheRepositorySortingValues<Value> = (a: Value, b: Value) => number; export declare class CacheRepository<Key, Value> { private readonly collection; keys: Key[]; values: Value[]; protected sortingValues?: CacheRepositorySortingValues<Value>; constructor({ sortingValues }?: { sortingValues?: CacheRepositorySortingValues<Value>; }); /** Checks has value by key */ has(key: Key): boolean; /** Sets value by key */ set(key: Key, value: Value): void; /** Returns value by key */ get(key: Key): Value | undefined; /** Sets value by key else error if exits */ strictSet(key: Key, value: Value): void; /** Returns value by key else error */ strictGet(key: Key): Value; /** Returns iterator */ [Symbol.iterator](): IterableIterator<[Key, Value]>; } export {};