Updated documentation
This commit is contained in:
parent
a567e3782c
commit
f70be6a45f
20
README.md
20
README.md
@ -6,10 +6,10 @@
|
|||||||
<img src="https://git.zakscode.com/repo-avatars/89f6c36caf75762ed9f7f98b69044b7db30da5230be7c5cea54f8a1158f1669a" alt="Logo" width="200" height="200">
|
<img src="https://git.zakscode.com/repo-avatars/89f6c36caf75762ed9f7f98b69044b7db30da5230be7c5cea54f8a1158f1669a" alt="Logo" width="200" height="200">
|
||||||
|
|
||||||
<!-- Title -->
|
<!-- Title -->
|
||||||
### Persist
|
### var-persist
|
||||||
|
|
||||||
<!-- Description -->
|
<!-- Description -->
|
||||||
Typescript Library to Sync Variables with LocalStorage
|
TypeScript: Sync variables with localStorage
|
||||||
|
|
||||||
<!-- Repo badges -->
|
<!-- Repo badges -->
|
||||||
[![Version](https://img.shields.io/badge/dynamic/json.svg?label=Version&style=for-the-badge&url=https://git.zakscode.com/api/v1/repos/ztimson/persist/tags&query=$[0].name)](https://git.zakscode.com/ztimson/persist/tags)
|
[![Version](https://img.shields.io/badge/dynamic/json.svg?label=Version&style=for-the-badge&url=https://git.zakscode.com/api/v1/repos/ztimson/persist/tags&query=$[0].name)](https://git.zakscode.com/ztimson/persist/tags)
|
||||||
@ -29,7 +29,7 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
## Table of Contents
|
## Table of Contents
|
||||||
- [Persist](#top)
|
- [var-persist](#top)
|
||||||
- [About](#about)
|
- [About](#about)
|
||||||
- [Examples](#examples)
|
- [Examples](#examples)
|
||||||
- [Built With](#built-with)
|
- [Built With](#built-with)
|
||||||
@ -44,7 +44,7 @@
|
|||||||
|
|
||||||
## About
|
## About
|
||||||
|
|
||||||
Persist is an updated version of [webstorage-decorators](https://git.zakscode.com/ztimson/webstorage-decorators), a library which saves variables to local or session storage.
|
Var-Persist is an updated version of [webstorage-decorators](https://git.zakscode.com/ztimson/webstorage-decorators), a library which saves variables to local or session storage.
|
||||||
|
|
||||||
This library aims to improve upon the original's limitations by using the new [Proxy Object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Proxy). Improvements include:
|
This library aims to improve upon the original's limitations by using the new [Proxy Object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Proxy). Improvements include:
|
||||||
- Supports both OOP & Decorator patterns
|
- Supports both OOP & Decorator patterns
|
||||||
@ -57,7 +57,7 @@ This library aims to improve upon the original's limitations by using the new [P
|
|||||||
|
|
||||||
Using objects:
|
Using objects:
|
||||||
```ts
|
```ts
|
||||||
import {Persist} from 'ztimson/persist';
|
import {Persist} from 'var-persist';
|
||||||
|
|
||||||
// Proxy Object (Always access/modify using `.value`):
|
// Proxy Object (Always access/modify using `.value`):
|
||||||
let theme = new Persist<string>('theme', {default: 'os'});
|
let theme = new Persist<string>('theme', {default: 'os'});
|
||||||
@ -68,7 +68,7 @@ theme.value = 'light'; // Changes will be synced to localStorage['theme'];
|
|||||||
|
|
||||||
Using decorators:
|
Using decorators:
|
||||||
```ts
|
```ts
|
||||||
import {persist} from 'ztimson/persist';
|
import {persist} from 'var-persist';
|
||||||
|
|
||||||
// Using decorators
|
// Using decorators
|
||||||
class Theme {
|
class Theme {
|
||||||
@ -83,7 +83,7 @@ theme.current = 'dark'; // You can ommit `.value` when using the decorator
|
|||||||
Advanced uses:
|
Advanced uses:
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
import {Persist} from 'ztimson/persist';
|
import {Persist} from 'var-persist';
|
||||||
|
|
||||||
// Options are the same for both the persist decorator and object:
|
// Options are the same for both the persist decorator and object:
|
||||||
let example = new Persist<string[]>('example', {
|
let example = new Persist<string[]>('example', {
|
||||||
@ -117,7 +117,7 @@ example.value.pop(); // Impure changes are saved
|
|||||||
- [Node.js](https://nodejs.org/en/download)
|
- [Node.js](https://nodejs.org/en/download)
|
||||||
|
|
||||||
#### Instructions
|
#### Instructions
|
||||||
1. Install persist: `npm i ztimson/persist`
|
1. Install persist: `npm i var-persist`
|
||||||
2. Enable decorators inside `tsconfig.json`:
|
2. Enable decorators inside `tsconfig.json`:
|
||||||
```json
|
```json
|
||||||
{
|
{
|
||||||
@ -165,7 +165,7 @@ Your data is stored under the `value` property and should always be accessed/mod
|
|||||||
#### Example
|
#### Example
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
import {Persist} from 'ztimson/persist'
|
import {Persist} from 'var-persist'
|
||||||
|
|
||||||
const theme = new Persist('theme.current', {default: 'os'});
|
const theme = new Persist('theme.current', {default: 'os'});
|
||||||
|
|
||||||
@ -266,6 +266,8 @@ Your data is stored under the value property and should always be accessed/modif
|
|||||||
#### Example
|
#### Example
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
|
import {Persist} from 'var-persist';
|
||||||
|
|
||||||
class Theme {
|
class Theme {
|
||||||
// This property will automatically sync with localStorage
|
// This property will automatically sync with localStorage
|
||||||
@Persist({default: 'os'}) current!: string;
|
@Persist({default: 'os'}) current!: string;
|
||||||
|
@ -1,8 +1,11 @@
|
|||||||
{
|
{
|
||||||
"name": "persist",
|
"name": "var-persist",
|
||||||
"version": "1.0.3",
|
"version": "1.0.0",
|
||||||
"description": "Sync variables with the local/session storage using proxy objects & decorators",
|
"description": "Sync variables with the local/session storage using proxy objects & decorators",
|
||||||
"repository": "https://git.zakscode.com/ztimson/persistance",
|
"repository": {
|
||||||
|
"type": "git",
|
||||||
|
"url": "https://git.zakscode.com/ztimson/var-persist"
|
||||||
|
},
|
||||||
"author": "Zak Timson",
|
"author": "Zak Timson",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"main": "dist/index.js",
|
"main": "dist/index.js",
|
||||||
|
Loading…
Reference in New Issue
Block a user