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

next-persist

Package Overview
Dependencies
Maintainers
1
Versions
36
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

next-persist - npm Package Compare versions

Comparing version 1.0.0 to 1.0.1

2

package.json
{
"name": "next-persist",
"version": "1.0.0",
"version": "1.0.1",
"description": "Bridging the gap between client-side persistence and server-side rendering",

@@ -5,0 +5,0 @@ "main": "src/next-persist.js",

const nextPersist = {};
// writes to storage
// writes to local storage
nextPersist.writeStorage = (state) => {
localStorage.setItem('state', JSON.stringify(state));
if (typeof Window !== 'undefined') {
localStorage.setItem('state', JSON.stringify(state));
} else {
return state;
}
};

@@ -10,20 +14,24 @@

nextPersist.getStorage = (persistConfig, state) => {
const clientState = localStorage.getItem('state');
if (typeof Window !== 'undefined') {
const clientState = localStorage.getItem('state');
if (clientState) {
const { allowList } = persistConfig;
const parsedClientState = JSON.parse(clientState);
const newState = allowList.reduce((acc, cur) => {
acc[cur] = parsedClientState[cur];
return acc;
}, {});
return {
...state,
...newState,
};
};
if (clientState) {
const { allowList } = persistConfig;
const parsedClientState = JSON.parse(clientState);
const newState = allowList.reduce((acc, cur) => {
acc[cur] = parsedClientState[cur];
return acc;
}, {});
return {
...state,
...newState,
};
}
}
return state;
};
module.exports = nextPersist;
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