UNPKG

cbp-lib

Version:

Libraries for cbp

31 lines (22 loc) 587 B
'use strict' let _ = typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : {}; export class WebStorage { constructor(options) { this.store = options.store || _.localStorage } setItem(key, value) { if (typeof value === 'object') { value = JSON.stringify(value) } this.store.setItem(key, value) } getItem(key) { return this.store.getItem(key) } removeItem(name) { return this.store.removeItem(name) } removeAll() { return this.store.clear() } }