local-storage-poorlyfill
v1.3.1
Published
in-memory polyfill for local storage
Downloads
15
Readme
local-storage-poorlyfill
In-memory polyfill for local storage
Add to your project:
npm i local-storage-poorlyfill
<script type="text/javascript" src="node_modules/local-storage-poorlyfill/dist/local-storage-poorlyfill.js"></script>
<script>
// use _localStorage
</script>Why?
For local files, IE and Edge do not have support for local storage
local storage can be disabled
Tested browsers
- Chrome, Firefox, Internet Explorer, Edge, Safari and Opera
Implementation details
Use browser's native implementation if supported
Mirror native functionality with an object
Implementation flaws
Not persistent
Need to use
_localStorageinstead oflocalStorage
Scripts
Lint with standard:
yarn lintTranspile with babel:
yarn buildRun unit tests:
yarn testUse _localStorage or window._localStorage instead of localStorage or window.localStorage because the browser prevents using localStorage or window.localStorage if access is denied for this document.
W3 Spec:
- https://www.w3.org/TR/webstorage/#storage
MSDN:
- https://developer.mozilla.org/en-US/docs/Web/API/Window/localStorage
- https://developer.mozilla.org/en-US/docs/Web/API/Web_Storage_API/Local_storage
