// TODO: Create a IStorageKeyEscaped interface, which uses escaping so that any keys // are allowed. At the moment if you use keys which the underlying storage (ex, // the file system) doesn't support, it will just throw. export type IStorageSync = { get(key: string): T | undefined; set(key: string, value: T): void; remove(key: string): void; getKeys(): string[]; getValues(): T[]; getEntries(): [string, T][]; getInfo(key: string): { size: number; lastModified: number } | undefined; reset(): Promise; }; export type IStorage = { get(key: string): Promise; set(key: string, value: T): Promise; remove(key: string): Promise; getKeys(): Promise; getInfo(key: string): Promise; reset(): Promise; // Allows watching for when the storage detects and underlying changes, and resyncs all of it's data (which might watchResync?: (callback: () => void) => void; }; // NOTE: In the file system some characters are disallowed, and some characters do special things (/ makes a folder). And there are even more rules, such as lengths per folder, etc, etc. export type IStorageRaw = { get(key: string): Promise; // Reads bytes in the range [start, end) (end is exclusive, clamped to the file size). Returns undefined if the file doesn't exist. getRange(key: string, config: { start: number; end: number }): Promise; // May or may not be efficient in the underlying storage append(key: string, value: Buffer): Promise; set(key: string, value: Buffer): Promise; remove(key: string): Promise; getKeys(includeFolders?: boolean): Promise; getInfo(key: string): Promise; reset(): Promise; };