@ctrlc/storage
v1.2.6
Published
网页缓存封装
Downloads
6
Maintainers
Readme
@ctrlc/storage
网页Storage封装,支持
localStorage
、sessionStorage
、cookie
、内存四种存储对象,支持null
、undefined
、boolean
、object
、number
、string
、date
、map
、set
、object
多种格式。
Usage
import Storage from "@ctrlc/storage";
const storage = new Storage({
namespace: 'app',
version: '1.0.0'
});
// set
storage.setItem('test', 'test');
storage.setItem('test', 'test', {
type: 'local',
namespace: 'app'
});
storage.setCookie('test', 'test');
// get
storage.getItem('test');
storage.getItem('test', {
type: 'local',
namespace: 'app'
});
storage.getCookie('test');
// remove
storage.removeItem('test');
storage.removeItem('test', {
type: 'local',
namespace: 'app'
});
storage.removeCookie('test');
// clear
storage.clear();
storage.clear({
type: 'local'
});
storage.clearCookie();