npm.io
1.1.1 • Published 3 years agoCLI

hc_localstorage_plus

Licence
ISC
Version
1.1.1
Deps
0
Size
184 kB
Vulns
0
Weekly
0

How

npm i hc_localstorage_plus

What

避免了繁琐的手动存储操作,并提供了更高的数据访问和修改安全性。 这使得代码更加简洁易读,易于维护和扩展。

why?

Former: JSON.parse(localStorage.getItem(${key})) || {};

optimization: myLocalStorage.${key}

Example

const key = "myObject";
const initialData = {
    initData: "newData",
};

const myLocalStorage = new ProxiedLocalStorage(key, initialData);
// set it = localStorage.setItem(${key}, ${value})
myLocalStorage.initData = "change";
// get it = localStorage.getItem(${key}, ${value})
console.log(myLocalStorage.initData)
Effect

effct

Keywords