deno.land / x / replicache@v10.0.0-beta.0 / kv / write-impl-base.ts
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253import type {Read, Value} from './store';
export const deleteSentinel = Symbol();export type DeleteSentinel = typeof deleteSentinel;
export class WriteImplBase { protected readonly _pending: Map<string, Value | DeleteSentinel> = new Map(); private readonly _read: Read;
constructor(read: Read) { this._read = read; }
async has(key: string): Promise<boolean> { switch (this._pending.get(key)) { case undefined: return this._read.has(key); case deleteSentinel: return false; default: return true; } }
async get(key: string): Promise<Value | undefined> { const v = this._pending.get(key); switch (v) { case deleteSentinel: return undefined; case undefined: return this._read.get(key); default: return v; } }
async put(key: string, value: Value): Promise<void> { this._pending.set(key, value); }
async del(key: string): Promise<void> { this._pending.set(key, deleteSentinel); }
release(): void { this._read.release(); }
get closed(): boolean { return this._read.closed; }}
Version Info