@solid/community-server
Version:
Community Solid Server: an open and modular implementation of the Solid specifications
32 lines (31 loc) • 1.28 kB
TypeScript
import type { KeyValueStorage } from './KeyValueStorage';
/**
* Abstract class to create a {@link KeyValueStorage} by wrapping around another one.
*
* Exposes abstract functions to modify the key before passing it to the the source storage.
*/
export declare abstract class PassthroughKeyValueStorage<TVal> implements KeyValueStorage<string, TVal> {
protected readonly source: KeyValueStorage<string, TVal>;
protected constructor(source: KeyValueStorage<string, TVal>);
get(key: string): Promise<TVal | undefined>;
has(key: string): Promise<boolean>;
set(key: string, value: TVal): Promise<this>;
delete(key: string): Promise<boolean>;
entries(): AsyncIterableIterator<[string, TVal]>;
/**
* This function will be called on the input key and used as a new key when calling the source.
*
* @param key - Original input key.
*
* @returns A new key to use with the source storage.
*/
protected abstract toNewKey(key: string): string;
/**
* This function is used when calling `entries()` to revert the key generated by `toNewKey()`.
*
* @param key - A key generated by `toNewKey()`
*
* @returns The original key.
*/
protected abstract toOriginalKey(key: string): string;
}