A wrapper of localStorage in order to support expiration time and asynchronous execution.
localStore.clear();
// store data for an hour.
localStore.setItem('testKey', {name: 'yannxiao'}, 1000 * 60 * 60, function(err) {
if (err.name === 'QuotaExceededError') {
// todo sth when exceeded the quota.
}
});
// same as native
localStore.setItem('testKey', {name: 'yannxiao'}, function(err) {
if (err.name === 'QuotaExceededError') {
// todo sth when exceeded the quota.
}
});
localStore.getItem('testKey', function(data) {
// to do sth.
});
localStore.removeItem('testKey1 testKey2');
var key = localStore.key(0);
var len = localStore.getLength();