2024-02-09 04:00:45 +08:00
|
|
|
import { syscall } from "../syscall.ts";
|
2023-08-26 14:31:51 +08:00
|
|
|
|
2023-10-03 20:16:33 +08:00
|
|
|
/**
|
|
|
|
* Implements a very simple (string) key value store for the client.
|
|
|
|
* Generally should only be used to set some client-specific states, such as preferences.
|
2024-08-09 15:27:58 +08:00
|
|
|
* @module
|
2023-10-03 20:16:33 +08:00
|
|
|
*/
|
|
|
|
|
2024-08-07 19:27:25 +08:00
|
|
|
/**
|
|
|
|
* Sets a value in the client store.
|
|
|
|
* @param key the key to set
|
|
|
|
* @param value the value to set
|
|
|
|
*/
|
2023-08-26 14:31:51 +08:00
|
|
|
export function set(key: string, value: any): Promise<void> {
|
|
|
|
return syscall("clientStore.set", key, value);
|
|
|
|
}
|
|
|
|
|
2024-08-07 19:27:25 +08:00
|
|
|
/**
|
|
|
|
* Gets a value from the client store.
|
|
|
|
* @param key the key to get
|
|
|
|
* @returns the value associated with the key
|
|
|
|
*/
|
2023-08-26 14:31:51 +08:00
|
|
|
export function get(key: string): Promise<any> {
|
|
|
|
return syscall("clientStore.get", key);
|
|
|
|
}
|
|
|
|
|
2024-08-07 19:27:25 +08:00
|
|
|
/**
|
|
|
|
* Deletes a value from the client store.
|
|
|
|
* @param key the key to delete
|
|
|
|
*/
|
2023-08-26 14:31:51 +08:00
|
|
|
export function del(key: string): Promise<void> {
|
|
|
|
return syscall("clientStore.delete", key);
|
|
|
|
}
|