学习?学个屁 06c63c15cc 初始化提交 3 周之前
..
.npmignore 06c63c15cc 初始化提交 3 周之前
LICENSE 06c63c15cc 初始化提交 3 周之前
README.md 06c63c15cc 初始化提交 3 周之前
localStorage.js 06c63c15cc 初始化提交 3 周之前
localStorage.spec.js 06c63c15cc 初始化提交 3 周之前
package.json 06c63c15cc 初始化提交 3 周之前

README.md

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.