Socket
Socket
Sign inDemoInstall

react-localstorage-ts

Package Overview
Dependencies
Maintainers
2
Versions
44
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-localstorage-ts - npm Package Compare versions

Comparing version 2.0.0-beta.13 to 2.0.0-beta.14

9

package.json
{
"name": "react-localstorage-ts",
"version": "2.0.0-beta.13",
"version": "2.0.0-beta.14",
"description": "A small library to wrap browser's localstorage in a functional fashion.",

@@ -26,10 +26,7 @@ "main": "index.js",

],
"peerDependencies": {
"io-ts": "^2.2.16"
},
"dependencies": {
"fp-ts": "^2.9.5",
"io-ts": "^2.2.16",
"localvalue-ts": "^1.1.0-beta.7",
"monocle-ts": "2.3.5",
"localvalue-ts": "^2.0.0-beta.2",
"monocle-ts": "^2.3.5",
"newtype-ts": "^0.3.4"

@@ -36,0 +33,0 @@ },

@@ -41,13 +41,17 @@ "use strict";

var LV = __importStar(require("./LocalValue"));
var isLocalStorageEvent = function (e) {
var _a;
return typeof ((_a = e === null || e === void 0 ? void 0 : e.detail) === null || _a === void 0 ? void 0 : _a.key) === "string";
};
var makeUseLocalItem = function (key, codec, options) {
return (function () {
var _a = React.useState(localvalue_ts_1.getLocalValue(key, codec, options)), item = _a[0], setItem = _a[1];
var _a = React.useState(localvalue_ts_1.getLocalValue(key, codec, options)()), item = _a[0], setItem = _a[1];
var setItemMemo = React.useMemo(function () {
return function (i) {
return function_1.pipe(i, LV.fold2(function () {
localvalue_ts_1.removeLocalValue(key, options);
setItem(localvalue_ts_1.getLocalValue(key, codec, options));
localvalue_ts_1.removeLocalValue(key, options)();
setItem(localvalue_ts_1.getLocalValue(key, codec, options)());
}, function (newValue) {
localvalue_ts_1.setLocalValue(key, codec, newValue, options);
setItem(localvalue_ts_1.getLocalValue(key, codec, options));
localvalue_ts_1.setLocalValue(key, codec, newValue, options)();
setItem(localvalue_ts_1.getLocalValue(key, codec, options)());
}));

@@ -57,5 +61,5 @@ };

var onLocalStorageChange = function (event) {
if (localStorageProxy_1.isLocalStorageEvent(event)) {
if (isLocalStorageEvent(event)) {
if (event.detail.key === key) {
setItem(localvalue_ts_1.getLocalValue(key, codec, options));
setItem(localvalue_ts_1.getLocalValue(key, codec, options)());
}

@@ -65,3 +69,3 @@ }

if (event.key === key) {
setItem(localvalue_ts_1.getLocalValue(key, codec, options));
setItem(localvalue_ts_1.getLocalValue(key, codec, options)());
}

@@ -104,11 +108,11 @@ }

return (function () {
var _a = React.useState(v.getValue()), item = _a[0], setItem = _a[1];
var _a = React.useState(v.get()), item = _a[0], setItem = _a[1];
var setItemMemo = React.useMemo(function () {
return function (i) {
return function_1.pipe(i, LV.fold2(function () {
v.removeValue();
setItem(v.getValue());
v.remove();
setItem(v.get());
}, function (newValue) {
v.setValue(newValue);
setItem(v.getValue());
v.set(newValue)();
setItem(v.get());
}));

@@ -118,5 +122,5 @@ };

var onLocalStorageChange = function (event) {
if (localStorageProxy_1.isLocalStorageEvent(event)) {
if (isLocalStorageEvent(event)) {
if (event.detail.key === key) {
setItem(v.getValue());
setItem(v.get());
}

@@ -126,3 +130,3 @@ }

if (event.key === key) {
setItem(v.getValue());
setItem(v.get());
}

@@ -129,0 +133,0 @@ }

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc