const ls = window.localStorage

export default {
  get: (key: string) => ls.getItem(key),

  set: (key: string, value: string) => ls.setItem(key, value),

  toggle: (key: string, force?: boolean) => {
    if (typeof force === 'undefined') {
      force = !ls.getItem(key)
    }

    if (force) {
      ls.setItem(key, '1')
    } else {
      ls.removeItem(key)
    }

    return force
  },
}
