fallbackstorage
TypeScript icon, indicating that this package has built-in type declarations

0.0.2 • Public • Published

Fallback Storage Build Status

NPM

A fallback chain for localStorage/sessionStorage/memoryStorage.

Usage

import {getSafeStorage} from 'fallbackstorage'

getSafeStorage check for availability and returns window.localStorage, or window.sessionStorage if they are available. Otherwise, it returns the manually implemented MemoryStorage instance.

The MemoryStorage implementation follows the specification defined at whatwg.

Why this package

In safari's private mode, or when the user has disabled local storage, the window.localStorage object is available (i.e., not null) but does not allow using storage.setItem. Therefore, the availability check is not straightforward as it seems to be.

Versions

Current Tags

  • Version
    Downloads (Last 7 Days)
    • Tag
  • 0.0.2
    0
    • latest

Version History

  • Version
    Downloads (Last 7 Days)
    • Published
  • 0.0.2
    0
  • 0.0.1
    1

Package Sidebar

Install

npm i fallbackstorage

Weekly Downloads

1

Version

0.0.2

License

MIT

Unpacked Size

4.93 kB

Total Files

5

Last publish

Collaborators

  • tranvansang