ajore
v0.5.0
Published
a async js local storage
Downloads
5
Maintainers
Readme
what is ajore
ajore is a mini storage bliud on the async queue, and it and run on the web and wechat mini program(a popular app in China). It is faster and easy to use.
- faster
- object storage enable
- async queue
how to install
$ npm i ajore --save
how to use
use webpack or parcel so on.
// or use a commonjs moudle
const ajore = require("ajore")
// or use a ES6 moudle
import ajore from "ajore"
or script
<script src="pathToProject/node_module/ajore/dist/ajore.js">
then
let myTestStore = ajore.connect('test')
myTestStore.a = 5
// now you can use myTestStore as a localStorage and it is more powerful
ajore VS localStorage
what's wrong with localStorage
localStorage.a = 1
localStorage.a += 3
console.log(localStorage.a) // error!! "13" but not 4
localStorage.b = { xx: 2 }
console.log(localStorage.b) // error!! "[object Object]" but not { xx: 2 }
how to avoid it with localStorage
localStorage.a = 1
localStorage.a = +localStorage.a + 3
console.log(localStorage.a) // good!! It is 4
localStorage.b = JSON.stringify({ xx: 2 })
console.log(JSON.parse(localStorage.b)) // good!! It is { xx: 2 }
when use ajore
in ajore, you don't need to do that, and it can run faster with the async queue
let storage = ajore.connect()
storage.a = 1
storage.a += 3
console.log(storage.a) // good!! It is 4
let b = ajore.connect('b')
b.xx = 2
console.table(b) // good!! It is { xx: 2 }
// Warning!! Don't write a object as a value like this, it may not to be storage
let storage = ajore.connect('mystore')
storage.b = { xx: 2 } // Don't do this!!!
// you should by this
let b = ajore.connect('b')
b.xx = 2
ajore in wechat mini program
wechat is a chinese app, if you want to see more about it, please see the README_zh.md