Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/patkub/local-storage-poorlyfill
in-memory polyfill for local storage
https://github.com/patkub/local-storage-poorlyfill
localstorage polyfill
Last synced: 10 days ago
JSON representation
in-memory polyfill for local storage
- Host: GitHub
- URL: https://github.com/patkub/local-storage-poorlyfill
- Owner: patkub
- License: mit
- Created: 2019-10-06T03:09:47.000Z (about 5 years ago)
- Default Branch: master
- Last Pushed: 2023-01-04T22:25:47.000Z (almost 2 years ago)
- Last Synced: 2024-04-24T00:44:40.736Z (7 months ago)
- Topics: localstorage, polyfill
- Language: JavaScript
- Size: 2.97 MB
- Stars: 1
- Watchers: 0
- Forks: 0
- Open Issues: 20
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# local-storage-poorlyfill
[![example workflow](https://github.com/patkub/local-storage-poorlyfill/actions/workflows/node.js.yml/badge.svg?branch=master)](https://github.com/patkub/local-storage-poorlyfill/actions/workflows/node.js.yml?branch=master)
[![Known Vulnerabilities](https://snyk.io/test/github/patkub/local-storage-poorlyfill/badge.svg?targetFile=package.json)](https://snyk.io/test/github/patkub/local-storage-poorlyfill?targetFile=package.json)
[![js-standard-style](https://img.shields.io/badge/code%20style-standard-brightgreen.svg)](http://standardjs.com)
[![semantic-release](https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg)](https://github.com/semantic-release/semantic-release)In-memory polyfill for local storage
Add to your project:
`npm i local-storage-poorlyfill`
```html
// use _localStorage
```
### 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 `_localStorage` instead of `localStorage`
### Scripts
Lint with standard:
```
yarn lint
```Transpile with babel:
```
yarn build
```Run unit tests:
```
yarn test
```Use `_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/#storageMSDN:
- 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