finesse-toolkit
Version:
useful tools for finesse phone system
36 lines (27 loc) • 586 B
text/typescript
export interface IStoreObject<T> {
[id: string]: T;
}
export default class Store<T> {
private _store: IStoreObject<T> = {};
add (id: string, data): void {
this._store[id] = data;
}
remove (id: string): void {
delete this._store[id];
}
get (id: string): T {
return this._store[id];
}
exists (id: string): boolean {
return !!this._store[id];
}
count (): number {
return Object.keys(this._store).length;
}
getAllKeys (): string[] {
return Object.keys(this._store);
}
getAll (): IStoreObject<T> {
return this._store;
}
};