Key/value storage, local or remote
.vscode | ||
dist | ||
src | ||
.dockerignore | ||
.editorconfig | ||
.gitignore | ||
.gitlab-ci.yml | ||
activate_node | ||
Dockerfile | ||
jest.config.js | ||
package-lock.json | ||
package.json | ||
README.md | ||
tsconfig.json |
tk-storage
About
Javascript/Typescript persistent storage, with key-value stores as foundation.
Typescript definitions are included.
Issues can be reported on GitLab.
Install
Import in node:
npm install tk-storage
import { getLocalStorage } from "tk-storage";
const storage = getLocalStorage("myapp");
Import in browser:
<script src="https://unpkg.com/tk-storage"></script>
const storage = tkStorage.getLocalStorage("myapp");
Use
To get a storage locally persistent (saved in browser data or on disk for Node.js):
const storage = getLocalStorage("myapp");
await storage.get("key"); // => null
await storage.set("key", "value");
await storage.get("key"); // => "value"
To get a storage remotely persistent (saved on a compliant server):
const storage = getRemoteStorage("myapp", "https://tk-storage.example.io/", { shared: true });
await storage.get("key"); // => null
await storage.set("key", "value");
await storage.get("key"); // => "value"