Async LocalStorage
Async implemented localStorage library for javascript and typescript.
Why?
Since localStorage API is a synchronous and took so long to get or set value which is pretty annoying. Using Async LocalStorage will helps you deal with race condition.
Installation
// using
> npm install @wit03/async-localstorage
> yarn add @wit03/async-localstorage
Getting Started
- ES6
import { setItem, getItem } from '@wit03/async-localstorage'
//setItem
setItem(key, data).then(()=> {
//value has been set
})
//getItem
getItem(key).then((value)=> {
//return value data
})
- Module
const asyncLocalStorage = '@wit03/async-localstorage'
//setItem
asyncLocalStorage.setItem(key, data).then(()=> {
//value has been set
})
//getItem
asyncLocalStorage.getItem(key).then((value)=> {
//return value data
})
Contributions
feel free to create PR and also issues~