react-localstorage-ts
Advanced tools
Comparing version 2.0.0-beta.13 to 2.0.0-beta.14
{ | ||
"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 @@ } |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
5
18952
10
227
+ Addedlocalvalue-ts@2.2.2(transitive)
+ Addedmonocle-ts@2.3.13(transitive)
- Removedlocalvalue-ts@1.1.0-beta.7(transitive)
- Removedmonocle-ts@2.3.5(transitive)
Updatedlocalvalue-ts@^2.0.0-beta.2
Updatedmonocle-ts@^2.3.5