https://github.com/capaj/localstorage-polyfill
in memory localStorage polyfill for node.js utilizing ES6 proxies
https://github.com/capaj/localstorage-polyfill
Last synced: 12 months ago
JSON representation
in memory localStorage polyfill for node.js utilizing ES6 proxies
- Host: GitHub
- URL: https://github.com/capaj/localstorage-polyfill
- Owner: capaj
- License: mit
- Created: 2016-08-18T08:55:20.000Z (almost 10 years ago)
- Default Branch: master
- Last Pushed: 2016-11-14T11:15:10.000Z (over 9 years ago)
- Last Synced: 2025-07-03T01:18:05.766Z (about 1 year ago)
- Language: JavaScript
- Homepage:
- Size: 6.84 KB
- Stars: 66
- Watchers: 3
- Forks: 4
- Open Issues: 4
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# localstorage-polyfill
in memory localStorage polyfill for node.js utilizing ES6 proxies(requires node.js 6 at least)
## Installation
```
npm i localstorage-polyfill -D
```
Saving for development, because primarily this package is meant for unit testing browser in node.js.
## Usage
```javascript
require('localstorage-polyfill')
// or
import 'localstorage-polyfill'
global.localStorage // now has your in memory localStorage
```
For API doc, refer to MDN.
There are other packages like node-localStorage, but none of them work properly when you do
```javascript
localStorage.c = 1
```
They only shim the methods of localStorage object, they don't imitate it's behaviour fully.