store.js 339 B

1234567891011121314
  1. const LOCAL_STORAGE_KEY = 'searchHistory'
  2. class Store { }
  3. Store.saveHistory = (arr) => {
  4. localStorage.setItem(LOCAL_STORAGE_KEY, JSON.stringify(arr))
  5. }
  6. Store.loadHistory = () => JSON.parse(localStorage.getItem(LOCAL_STORAGE_KEY))
  7. Store.removeAllHistory = () => { localStorage.removeItem(LOCAL_STORAGE_KEY) }
  8. module.exports = Store