JSPM

has-localstorage

1.0.1
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 6973
  • Score
    100M100P100Q117814F
  • License MIT

returns true if localStorage is supported _and_ persistent

Package Exports

  • has-localstorage

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (has-localstorage) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

has-localstorage

returns true if localStorage is supported and persistent

Build Status

returns true or false depending on whether localStorage is supported or not. Beware that some browsers like Safari do not support localStorage in private mode.

Downlaod or Installation

  • Download has-localstorage.js
  • or: install via Bower: bower install --save has-localstorage
  • or: install via npm: npm install --save has-localstorage

Usage

if (hasLocalStorage()) {
  // localStorage can be used, all data gets persisted
} else {
  // localStorage is not available, or changes are not persisted
}

Help wanted!

The current test setup is very simple: it only tests in latest Firefox using Selenium and Sauce Labs. Unfortunately, Sauce Labs has no support to start browsers in private mode, which would be necessary, as localStorage behaves different if in private mode in Safari, probably in other browsers as well.

If anynone has an idea to for that, ping me at https://github.com/gr2m/has-localstorage/issues/1

Acknowledgement

hasLocalStorage() has been inspired by this Cappuccino commit: https://github.com/cappuccino/cappuccino/commit/063b05d9643c35b303568a28809e4eb3224f71ec

License

MIT