New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@plq/use-persisted-state

Package Overview
Dependencies
Maintainers
1
Versions
27
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@plq/use-persisted-state - npm Package Compare versions

Comparing version 0.0.8 to 0.0.9

lib/utils/is-arguments.d.ts

2

CHANGELOG.md

@@ -0,1 +1,3 @@

## [0.0.9](https://github.com/Akurganow/use-persisted-state/compare/v0.0.8...v0.0.9) (2019-09-10)
## [0.0.8](https://github.com/Akurganow/use-persisted-state/compare/v0.0.7...v0.0.8) (2019-09-09)

@@ -2,0 +4,0 @@

19

lib/index.js

@@ -9,11 +9,14 @@ import * as React from 'react';

};
let initialPersist = storage.getItem(safeStorageKey);
initialPersist = initialPersist ? JSON.parse(initialPersist) : {};
const usePersistedState = (key, initialValue) => {
let initialPersist;
try {
const persist = storage.getItem(safeStorageKey);
initialPersist = persist ? JSON.parse(persist) : {};
}
catch (ignore) {
initialPersist = {};
} // eslint-disable-line no-empty
let initialOrPersistedValue = initialValue;
if (initialPersist) {
try {
initialOrPersistedValue = initialPersist[key] || initialValue;
}
catch (ignore) { } // eslint-disable-line no-empty
if (initialPersist && initialPersist[key]) {
initialOrPersistedValue = initialPersist[key] || initialValue;
}

@@ -43,3 +46,3 @@ const [state, setState] = React.useState(initialOrPersistedValue);

const newState = JSON.parse(event.newValue);
const newValue = newState ? newState[key] : initialValue;
const newValue = newState && newState[key] ? newState[key] : initialValue;
setState(newValue);

@@ -46,0 +49,0 @@ }

{
"name": "@plq/use-persisted-state",
"version": "0.0.8",
"version": "0.0.9",
"description": "Like useState hook but with persistance in storage",

@@ -17,3 +17,3 @@ "main": "lib/index.js",

"test": "jest --verbose",
"release": "release-it",
"release": "npm run build && release-it",
"examples": "npm run build:watch & parcel examples/index.html"

@@ -20,0 +20,0 @@ },

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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