You can store Objects directly like `{a: 1, b: '1'}`, `1`, `'true'`, `true`
Before store, this module will stringify the value you set (use `JSON.stringify`). Before return, it will parse(use `JSON.parse`) the value which you want get
Value:var useCookieWhenDegrading = !!1
var KEY = 'STORAGE_TEST'
var storage = new Storage.Storage(useCookieWhenDegrading)
function setStorage() {
var input = getEl('#input')[0]
if (input.value) {
storage.set(KEY, input.value)
alert('Value of KEY `' + KEY + '` Set success!')
} else {
alert('Warn: Please input something')
}
}
function getStorage() {
var value = storage.get(KEY)
alert('KEY `' + KEY + '` value: ' + value)
}
`get`: `(key) => [Number, String, Object, Boolean]`
`set`: `(key,value:[Number, String, Object, Boolean]) => void`
`delete`: `(key) => void`
`clear`: `() => void`
`has`: `(key) => Boolean`
`keys`: `() => Array<String>`
`values`: `() => Array<Number, String, Object, Boolean>`
`entries`: `() => Array<{key, value}>`
`forEach`: `(callback:(key, value, instance|class) => void) => void`
`addHandler`: `(handler: ({event, key, oldValue, newValue}) => any) => wrappedHandler`
`removeHandler`: `(handlers: Array<wrappedHandler>) => void`
`get`: `(key) => [Number, String, Object, Boolean]`
`set`: `(key,value:[Number, String, Object, Boolean]) => void`
`delete`: `(key) => void`
`clear`: `() => void`
`has`: `(key) => Boolean`
`keys`: `() => Array<String>`
`values`: `() => Array<Number, String, Object, Boolean>`
`entries`: `() => Array<{key, value}>`
`forEach`: `(callback:(key, value, instance|class) => void) => void`