npm install node-keep
# or
yarn add node-keep
const keep = new Keep();
// Node Keep must be initialized before it is used
await keep.init();
keep.
Method | Description |
---|---|
constructor | Constructs a new instance of the Keep class |
init() | Initializes the storage directory. Note: This must be called before any other methods |
setItem(key, value) | Stores (or updates) a key-value pair in the storage directory. |
getItem(key) | Retrieves the value of the specified key or undefined if the key is not found. |
removeItem(key) | Removes a key-value pair from the storage directory. |
data() | Returns the data stored in the storage directory. |
keys() | Returns the keys of the data stored in the storage directory. |
values() | Returns the values of the data stored in the storage directory. |
length() | Returns the number of key-value pairs in the storage directory. |
clear() | Removes all key-value pairs from the storage directory. |
constructor(config?: Partial<Config>);
See Config
export interface Config {
/**
* The directory to store the data in.
* @defaultValue ".keep/storage"
*/
dir: string;
/**
* A function to log errors to (or false to disable).
* @defaultValue console.log
*/
log: ((...args: any[]) => void) | false;
}