14 lines
555 B
TypeScript
14 lines
555 B
TypeScript
export interface IStorageManagerLike {
|
|
get?(key: string): Promise<string | null>;
|
|
set?(key: string, value: string): Promise<void>;
|
|
list?(prefix: string): Promise<string[]>;
|
|
delete?(key: string): Promise<void>;
|
|
}
|
|
|
|
export function hasStorageManagerMethods<T extends keyof IStorageManagerLike>(
|
|
storageManager: IStorageManagerLike | undefined,
|
|
methods: T[],
|
|
): storageManager is IStorageManagerLike & Required<Pick<IStorageManagerLike, T>> {
|
|
return !!storageManager && methods.every((method) => typeof storageManager[method] === 'function');
|
|
}
|