text: import { saveCache, getCache } from "./localCache"
  
  function inertArray(arr, val, compare, maxLen) {
    const index = arr.findIndex(compare)
    if (index === 0) {
      return
    }
    if (index > 0) {
      arr.splice(index, 1)
    }
    arr.unshift(val)
    if (maxLen && arr.length > maxLen) {
      arr.pop()
    }
  }
  
  function deleteFromArray(arr, compare) {
    const index = arr.findIndex(compare)
    if (index > -1) {
      arr.splice(index, 1)
    }
  }
  
  export function save(key, item, compare, maxLen) {
    const items = getCache(key)
    inertArray(items, item, compare, maxLen)
    saveCache(key, items)
    return items
  }
  
  export function remove(key, compare) {
    const items = getCache(key)
    deleteFromArray(items, compare)
    saveCache(key, items)
    return items
  }
  
  export function load(key) {
    return getCache(key)
  }
  
  export function saveAll(items, key) {
    saveCache(key, items)
  }
  