mirror of
https://github.com/ragestudio/relic.git
synced 2025-06-09 10:34:18 +00:00
27 lines
480 B
TypeScript
27 lines
480 B
TypeScript
import { Adapter, SyncAdapter } from '../core/Low.js'
|
|
|
|
export class Memory<T> implements Adapter<T> {
|
|
#data: T | null = null
|
|
|
|
read(): Promise<T | null> {
|
|
return Promise.resolve(this.#data)
|
|
}
|
|
|
|
write(obj: T): Promise<void> {
|
|
this.#data = obj
|
|
return Promise.resolve()
|
|
}
|
|
}
|
|
|
|
export class MemorySync<T> implements SyncAdapter<T> {
|
|
#data: T | null = null
|
|
|
|
read(): T | null {
|
|
return this.#data || null
|
|
}
|
|
|
|
write(obj: T): void {
|
|
this.#data = obj
|
|
}
|
|
}
|