import type { KVStorageBackend } from './types' ; import { Some , None } from 'ts-results' ; export function createInMemoryKVStorageBackend ( onChange , beforeAutoSync = Promise . resolve ( ) ) { const storage = new Map < string , any > ( ) ; return { beforeAutoSync , async getValue ( key ) { if ( storage . has ( key ) ) return Some ( storage . get ( key ) ) ; return None ; } , async setValue ( key , value ) { storage . set ( key , value ) ; onChange ( key , value ) ; } , } ; }