2019-10-02 20:12:55 +00:00
|
|
|
tk-storage
|
|
|
|
==========
|
|
|
|
|
|
|
|
[![pipeline status](https://gitlab.com/thunderk/tk-storage/badges/master/pipeline.svg)](https://gitlab.com/thunderk/tk-storage/commits/master)
|
|
|
|
[![coverage report](https://gitlab.com/thunderk/tk-storage/badges/master/coverage.svg)](https://gitlab.com/thunderk/tk-storage/commits/master)
|
|
|
|
[![npm version](https://img.shields.io/npm/v/tk-storage.svg)](https://npmjs.com/tk-storage)
|
|
|
|
[![npm size](https://img.shields.io/bundlephobia/min/tk-storage.svg)](https://bundlephobia.com/result?p=tk-storage)
|
|
|
|
|
|
|
|
About
|
|
|
|
-----
|
|
|
|
|
|
|
|
Javascript/Typescript persistent storage, with key-value stores as foundation.
|
|
|
|
|
|
|
|
Typescript definitions are included.
|
|
|
|
|
|
|
|
Issues can be reported on [GitLab](https://gitlab.com/thunderk/tk-storage/issues).
|
|
|
|
|
|
|
|
Install
|
|
|
|
-------
|
|
|
|
|
|
|
|
Import in node:
|
|
|
|
|
|
|
|
```shell
|
|
|
|
npm install tk-storage
|
|
|
|
```
|
|
|
|
|
|
|
|
```javascript
|
|
|
|
import { getLocalStorage } from "tk-storage";
|
2019-11-07 21:33:23 +00:00
|
|
|
const storage = getLocalStorage("myapp");
|
2019-10-02 20:12:55 +00:00
|
|
|
```
|
|
|
|
|
|
|
|
Import in browser:
|
|
|
|
|
|
|
|
```html
|
|
|
|
<script src="https://unpkg.com/tk-storage"></script>
|
|
|
|
```
|
|
|
|
|
|
|
|
```javascript
|
2019-11-07 21:33:23 +00:00
|
|
|
const storage = tkStorage.getLocalStorage("myapp");
|
2019-10-02 20:12:55 +00:00
|
|
|
```
|
|
|
|
|
|
|
|
Use
|
|
|
|
---
|
|
|
|
|
|
|
|
```javascript
|
2019-11-07 21:33:23 +00:00
|
|
|
const storage = getLocalStorage("myapp");
|
2019-10-02 20:12:55 +00:00
|
|
|
await storage.get("key"); // => null
|
|
|
|
await storage.set("key", "value");
|
|
|
|
await storage.get("key"); // => "value"
|
|
|
|
```
|