@darcas/keyplex
Version:
A versatile and modular library for managing namespaced key-value storage, with built-in support for localStorage and sessionStorage, and the ability to easily extend for custom storage solutions.
31 lines • 1.22 kB
TypeScript
/**
* @author Dario Casertano <dario@casertano.name>
* @copyright Copyright (c) 2024-present Casertano Dario – All rights reserved.
* @license MIT
*/
export declare abstract class KeyPlex {
protected readonly dbname: string;
constructor(dbname?: string);
get<T = unknown>(key: string, def?: T | null): T;
set<T = unknown>(key: string, value: T): void;
del(key: string): void;
has(key: string): boolean;
abstract keys(): string[];
protected getPath(key: string): string;
protected abstract getItem(key: string): string | null;
protected abstract setItem(key: string, value: string): void;
protected abstract removeItem(key: string): void;
}
export declare class LocalPlex extends KeyPlex {
keys: () => string[];
protected getItem: (key: string) => string | null;
protected setItem: (key: string, value: string) => void;
protected removeItem: (key: string) => void;
}
export declare class SessionPlex extends KeyPlex {
keys: () => string[];
protected getItem: (key: string) => string | null;
protected setItem: (key: string, value: string) => void;
protected removeItem: (key: string) => void;
}
//# sourceMappingURL=index.d.ts.map