uni-ticket-system/node_modules/localstorage-polyfill
2023-12-05 10:11:10 +08:00
..
.npmignore submit 2023-12-05 10:11:10 +08:00
LICENSE submit 2023-12-05 10:11:10 +08:00
localStorage.js submit 2023-12-05 10:11:10 +08:00
localStorage.spec.js submit 2023-12-05 10:11:10 +08:00
package.json submit 2023-12-05 10:11:10 +08:00
README.md submit 2023-12-05 10:11:10 +08:00

localstorage-polyfill

in memory localStorage polyfill for node.js utilizing ES6 proxies

Installation

npm i localstorage-polyfill -D

Saving for development, because primarily this package is meant for unit testing browser in node.js.

Usage

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

localStorage.c = 1

They only shim the methods of localStorage object, they don't imitate it's behaviour fully.