UNPKG

@worker-tools/deno-kv-storage

Version:

An implementation of the StorageArea (1,2,3) interface for Deno with an extensible system for supporting various database backends.

22 lines (18 loc) 862 B
// deno-lint-ignore-file no-explicit-any import * as dntShim from "../_dnt.shims.js"; export interface Adapter { get(key: string): Promise<string | undefined>; set(key: string, value: string): Promise<void>; delete(key: string): Promise<void>; clear(): Promise<void>; keys(): AsyncIterableIterator<string>; values(): AsyncIterableIterator<string>; entries(): AsyncIterableIterator<readonly [string, string]>; backingStore(): unknown; } export type DBProtocol = `${string}:`; export type DB_URL = `${DBProtocol}//${string}`; export type Class<T = unknown, Arguments extends any[] = any[]> = new(...arguments_: Arguments) => T; export type AdapterParams = { area: string, url: DB_URL }; export type AdapterClass = Class<Adapter, [AdapterParams]>; (<any>dntShim.dntGlobalThis).deno_storage_area__adapters ||= new Map<DBProtocol, AdapterClass>();