Key/value storage, local or remote
Find a file
2019-11-27 22:51:27 +01:00
.vscode Added remote storage based on rest server 2019-11-27 22:51:27 +01:00
dist Added remote storage based on rest server 2019-11-27 22:51:27 +01:00
src Added remote storage based on rest server 2019-11-27 22:51:27 +01:00
.dockerignore Added remote storage based on rest server 2019-11-27 22:51:27 +01:00
.editorconfig Initial pre-version with only browser local storage 2019-10-02 22:12:55 +02:00
.gitignore Initial pre-version with only browser local storage 2019-10-02 22:12:55 +02:00
.gitlab-ci.yml Initial pre-version with only browser local storage 2019-10-02 22:12:55 +02:00
activate_node Added node.js directory storage 2019-11-07 22:33:23 +01:00
Dockerfile Added remote storage based on rest server 2019-11-27 22:51:27 +01:00
jest.config.js Added node.js directory storage 2019-11-07 22:33:23 +01:00
package-lock.json Added remote storage based on rest server 2019-11-27 22:51:27 +01:00
package.json Added remote storage based on rest server 2019-11-27 22:51:27 +01:00
README.md Added remote storage based on rest server 2019-11-27 22:51:27 +01:00
tsconfig.json Added node.js directory storage 2019-11-07 22:33:23 +01:00

tk-storage

pipeline status coverage report npm version npm size

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"