storage-manager-ts
Advanced tools
Comparing version 0.0.7 to 0.0.8
{ | ||
"name": "storage-manager-ts", | ||
"version": "0.0.7", | ||
"version": "0.0.8", | ||
"description": "A storage manager that supports storage managing with local and Redis storages", | ||
@@ -5,0 +5,0 @@ "main": "lib/index.js", |
# storage-manager-ts | ||
A storage manager that supports storage managing in localStorage and Redis | ||
A storage manager that supports storage managing in local-storage and redis | ||
## Initialize your storage manager: | ||
``` | ||
import { StorageManager } from 'wide-storage-manager'; | ||
const storage: StorageManager = new StorageManager('local'); | ||
import { LocalStorage } from 'storage-manager-ts'; | ||
const storage = new LocalStorage(); | ||
``` | ||
@@ -24,9 +24,9 @@ | ||
``` | ||
//Set a string as value | ||
//Set a key with string as value | ||
storage.set('myKey', 'myValue'); | ||
//Set a number as value | ||
//Set a key with number as value | ||
storage.set('myKey', 5); | ||
//Set a json as value | ||
//Set a key with JSON as value | ||
storage.set('myKey', { 'arg1': 'value1' }); | ||
@@ -41,3 +41,3 @@ ``` | ||
## Filter unique pattern key names: | ||
## Filtering keys by regex: | ||
``` | ||
@@ -49,6 +49,6 @@ storage.set('myKey1', '1'); | ||
//Getting all of the key names starting with 'myKey' | ||
const keys: string[] = storage.filterKeys('*myKey'); | ||
const keys: string[] = storage.filterKeys({start: 'myKey'}); | ||
``` | ||
## Getting the values of keys: | ||
## Getting key values by list: | ||
``` | ||
@@ -58,16 +58,14 @@ storage.set('myKey1', '1'); | ||
storage.set('myKey3', '3'); | ||
//use * to mention a start of the key | ||
//Getting all of the key names starting with 'myKey' | ||
const keys: string[] = storage.filterKeys('*myKey'); | ||
const keys: string[] = storage.filterKeys({start: 'myKey'}); | ||
//Getting all of their values | ||
const values: any[] = storage.getValuesByKeys(keys); | ||
const values: any[] = storage.getKeysByList(keys); | ||
``` | ||
## comparing keys by regex: | ||
## Comparing keys by regex: | ||
``` | ||
storage.set('myKey1', '1'); | ||
storage.set('myBoy', 'yay'); | ||
//use * to mention a start of the key | ||
//Getting all of the key names starting with 'my' | ||
const keys: string[] = storage.filterKeys('*my'); | ||
const keys: string[] = storage.filterKeys({ start: 'my'}); | ||
const regex: string = '*myKey'; | ||
@@ -77,11 +75,8 @@ //printing all of the comparisons of the keys to the second regex | ||
//checking which keys starting with 'my' also start with 'myKey' | ||
const comparison: boolean = storage.compareKeys(regex, keys[i]); | ||
console.log(`key ${keys[i]} comparison for regex ${regex} is ${comparison}`); | ||
const comparison: boolean = storage.compareKeys({start: 'myKey'}, keys[i]); | ||
console.log(`key ${keys[i]} comparison for regex {start: 'myKey'} is ${comparison}`); | ||
} | ||
``` | ||
results: | ||
1. key myKey1 comparison for regex *myKey is true | ||
2. key myBoy1 comparison for regex *myKey is false | ||
![Unit testing](https://github.com/danitseitlin/storage-manager-ts/workflows/Unit%20testing/badge.svg) |
25608
78