Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

vuex-persistedstate

Package Overview
Dependencies
Maintainers
1
Versions
38
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

vuex-persistedstate - npm Package Compare versions

Comparing version 2.1.2 to 2.2.0

2

dist/vuex-persistedstate.js

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

function _interopDefault(t){return t&&"object"==typeof t&&"default"in t?t.default:t}function createPersistedState(t){void 0===t&&(t={});var e=t.key;void 0===e&&(e="vuex");var r=t.paths;void 0===r&&(r=[]);var n=t.getState;void 0===n&&(n=function(t,e){var r=e.getItem(t);try{return r&&"undefined"!==r?JSON.parse(r):void 0}catch(t){return}});var i=t.setState;void 0===i&&(i=function(t,e,r){return r.setItem(t,JSON.stringify(e))});var o=t.reducer;void 0===o&&(o=defaultReducer);var a=t.storage;void 0===a&&(a=window&&window.localStorage);var u=t.filter;void 0===u&&(u=function(){return!0});var c=t.subscriber;if(void 0===c&&(c=function(t){return function(e){return t.subscribe(e)}}),!canWriteStorage(a))throw new Error("Invalid storage instance given");return function(t){var d=n(e,a);"object"==typeof d&&t.replaceState(merge({},t.state,d)),c(t)(function(t,n){u(t)&&i(e,o(n,r),a)})}}var merge=_interopDefault(require("lodash.merge")),getPath=function(t,e,r){for(void 0===r&&(r=0),e=e.split?e.split("."):e;r<e.length;r++)t=t[e[r]]||(t[e[r]]=!r&&{});return t},setPath=function(t,e,r,n,i){return e=e.split("."),n=e.pop(),(i=getPath(t,e))&&n?i[n]=r:void 0},defaultReducer=function(t,e){return 0===e.length?t:e.reduce(function(e,r){return setPath(e,r,getPath(t,r))&&e},{})},canWriteStorage=function(t){try{return t.setItem("@@",1),t.removeItem("@@"),!0}catch(t){return!1}};module.exports=createPersistedState;
function isNonNullObject(e){return!!e&&"object"==typeof e}function isSpecial(e){var r=Object.prototype.toString.call(e);return"[object RegExp]"===r||"[object Date]"===r||isReactElement(e)}function isReactElement(e){return e.$$typeof===REACT_ELEMENT_TYPE}function emptyTarget(e){return Array.isArray(e)?[]:{}}function cloneUnlessOtherwiseSpecified(e,r){var t=!r||r.clone!==!1;return t&&isMergeableObject(e)?deepmerge(emptyTarget(e),e,r):e}function defaultArrayMerge(e,r,t){return e.concat(r).map(function(e){return cloneUnlessOtherwiseSpecified(e,t)})}function mergeObject(e,r,t){var n={};return isMergeableObject(e)&&Object.keys(e).forEach(function(r){n[r]=cloneUnlessOtherwiseSpecified(e[r],t)}),Object.keys(r).forEach(function(i){isMergeableObject(r[i])&&e[i]?n[i]=deepmerge(e[i],r[i],t):n[i]=cloneUnlessOtherwiseSpecified(r[i],t)}),n}function deepmerge(e,r,t){var n=Array.isArray(r),i=Array.isArray(e),c=t||{arrayMerge:defaultArrayMerge},o=n===i;if(o){if(n){var a=c.arrayMerge||defaultArrayMerge;return a(e,r,t)}return mergeObject(e,r,t)}return cloneUnlessOtherwiseSpecified(r,t)}function createPersistedState(e){void 0===e&&(e={});var r=e.key;void 0===r&&(r="vuex");var t=e.paths;void 0===t&&(t=[]);var n=e.getState;void 0===n&&(n=function(e,r){var t=r.getItem(e);try{return t&&"undefined"!==t?JSON.parse(t):void 0}catch(e){return}});var i=e.setState;void 0===i&&(i=function(e,r,t){return t.setItem(e,JSON.stringify(r))});var c=e.reducer;void 0===c&&(c=defaultReducer);var o=e.storage;void 0===o&&(o=window&&window.localStorage);var a=e.filter;void 0===a&&(a=function(){return!0});var u=e.subscriber;if(void 0===u&&(u=function(e){return function(r){return e.subscribe(r)}}),!canWriteStorage(o))throw new Error("Invalid storage instance given");return function(e){var s=n(r,o);"object"==typeof s&&e.replaceState(deepmerge_1(e.state,s)),u(e)(function(e,n){a(e)&&i(r,c(n,t),o)})}}var isMergeableObject=function(e){return isNonNullObject(e)&&!isSpecial(e)},canUseSymbol="function"==typeof Symbol&&Symbol.for,REACT_ELEMENT_TYPE=canUseSymbol?Symbol.for("react.element"):60103;deepmerge.all=function(e,r){if(!Array.isArray(e))throw new Error("first argument should be an array");return e.reduce(function(e,t){return deepmerge(e,t,r)},{})};var deepmerge_1=deepmerge,get=function(e,r,t){return void 0===(e=(r.split?r.split("."):r).reduce(function(e,r){return e&&e[r]},e))?t:e},set=function(e,r,t){return(r=r.split?r.split("."):r).slice(0,-1).reduce(function(e,r){return e[r]=e[r]||{}},e)[r.pop()]=t},shvl={get:get,set:set},defaultReducer=function(e,r){return 0===r.length?e:r.reduce(function(r,t){return shvl.set(r,t,shvl.get(e,t))&&r},{})},canWriteStorage=function(e){try{return e.setItem("@@",1),e.removeItem("@@"),!0}catch(e){return!1}};module.exports=createPersistedState;

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

!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t(require("lodash.merge")):"function"==typeof define&&define.amd?define(["lodash.merge"],t):e.createPersistedState=t(e.merge)}(this,function(e){function t(t){void 0===t&&(t={});var r=t.key;void 0===r&&(r="vuex");var n=t.paths;void 0===n&&(n=[]);var u=t.getState;void 0===u&&(u=function(e,t){var r=t.getItem(e);try{return r&&"undefined"!==r?JSON.parse(r):void 0}catch(e){return}});var a=t.setState;void 0===a&&(a=function(e,t,r){return r.setItem(e,JSON.stringify(t))});var d=t.reducer;void 0===d&&(d=i);var f=t.storage;void 0===f&&(f=window&&window.localStorage);var c=t.filter;void 0===c&&(c=function(){return!0});var v=t.subscriber;if(void 0===v&&(v=function(e){return function(t){return e.subscribe(t)}}),!o(f))throw new Error("Invalid storage instance given");return function(t){var i=u(r,f);"object"==typeof i&&t.replaceState(e({},t.state,i)),v(t)(function(e,t){c(e)&&a(r,d(t,n),f)})}}e="default"in e?e.default:e;var r=function(e,t,r){for(void 0===r&&(r=0),t=t.split?t.split("."):t;r<t.length;r++)e=e[t[r]]||(e[t[r]]=!r&&{});return e},n=function(e,t,n,i,o){return t=t.split("."),i=t.pop(),(o=r(e,t))&&i?o[i]=n:void 0},i=function(e,t){return 0===t.length?e:t.reduce(function(t,i){return n(t,i,r(e,i))&&t},{})},o=function(e){try{return e.setItem("@@",1),e.removeItem("@@"),!0}catch(e){return!1}};return t});
!function(r,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):r.createPersistedState=t()}(this,function(){function r(r){return!!r&&"object"==typeof r}function t(r){var t=Object.prototype.toString.call(r);return"[object RegExp]"===t||"[object Date]"===t||e(r)}function e(r){return r.$$typeof===v}function n(r){return Array.isArray(r)?[]:{}}function o(r,t){var e=!t||t.clone!==!1;return e&&f(r)?c(n(r),r,t):r}function u(r,t,e){return r.concat(t).map(function(r){return o(r,e)})}function i(r,t,e){var n={};return f(r)&&Object.keys(r).forEach(function(t){n[t]=o(r[t],e)}),Object.keys(t).forEach(function(u){f(t[u])&&r[u]?n[u]=c(r[u],t[u],e):n[u]=o(t[u],e)}),n}function c(r,t,e){var n=Array.isArray(t),c=Array.isArray(r),a=e||{arrayMerge:u},f=n===c;if(f){if(n){var s=a.arrayMerge||u;return s(r,t,e)}return i(r,t,e)}return o(t,e)}function a(r){void 0===r&&(r={});var t=r.key;void 0===t&&(t="vuex");var e=r.paths;void 0===e&&(e=[]);var n=r.getState;void 0===n&&(n=function(r,t){var e=t.getItem(r);try{return e&&"undefined"!==e?JSON.parse(e):void 0}catch(r){return}});var o=r.setState;void 0===o&&(o=function(r,t,e){return e.setItem(r,JSON.stringify(t))});var u=r.reducer;void 0===u&&(u=b);var i=r.storage;void 0===i&&(i=window&&window.localStorage);var c=r.filter;void 0===c&&(c=function(){return!0});var a=r.subscriber;if(void 0===a&&(a=function(r){return function(t){return r.subscribe(t)}}),!g(i))throw new Error("Invalid storage instance given");return function(r){var f=n(t,i);"object"==typeof f&&r.replaceState(d(r.state,f)),a(r)(function(r,n){c(r)&&o(t,u(n,e),i)})}}var f=function(e){return r(e)&&!t(e)},s="function"==typeof Symbol&&Symbol.for,v=s?Symbol.for("react.element"):60103;c.all=function(r,t){if(!Array.isArray(r))throw new Error("first argument should be an array");return r.reduce(function(r,e){return c(r,e,t)},{})};var d=c,y=function(r,t,e){return void 0===(r=(t.split?t.split("."):t).reduce(function(r,t){return r&&r[t]},r))?e:r},l=function(r,t,e){return(t=t.split?t.split("."):t).slice(0,-1).reduce(function(r,t){return r[t]=r[t]||{}},r)[t.pop()]=e},p={get:y,set:l},b=function(r,t){return 0===t.length?r:t.reduce(function(t,e){return p.set(t,e,p.get(r,e))&&t},{})},g=function(r){try{return r.setItem("@@",1),r.removeItem("@@"),!0}catch(r){return!1}};return a});
{
"name": "vuex-persistedstate",
"description": "Persist Vuex state with localStorage.",
"version": "2.1.2",
"version": "2.2.0",
"license": "MIT",

@@ -31,4 +31,4 @@ "author": "Robin van der Vleuten <robin@webstronauts.co>",

"build": "mkdir -p dist && npm run -s build:cjs && npm run -s build:umd",
"build:cjs": "rollup -c -f cjs | uglifyjs -cm -o $npm_package_main",
"build:umd": "rollup -c -f umd | uglifyjs -cm -o $npm_package_browser",
"build:cjs": "rollup -c -f cjs --no-strict | uglifyjs -cm -o $npm_package_main",
"build:umd": "rollup -c -f umd --no-strict | uglifyjs -cm -o $npm_package_browser",
"precommit": "npm run build && lint-staged",

@@ -44,8 +44,6 @@ "prepublish": "npm run build",

},
"dependencies": {
"lodash.merge": "^4.6.0"
},
"devDependencies": {
"babel-jest": "^20.0.3",
"babel-preset-env": "^1.5.2",
"deepmerge": "^2.0.1",
"dom-storage": "^2.0.2",

@@ -59,2 +57,5 @@ "eslint": "^3.11.1",

"rollup-plugin-buble": "^0.14.0",
"rollup-plugin-commonjs": "^8.2.6",
"rollup-plugin-node-resolve": "^3.0.0",
"shvl": "^1.0.0",
"uglify-js": "^2.7.3",

@@ -61,0 +62,0 @@ "vue": "^2.0.0",

@@ -1,20 +0,4 @@

import merge from 'lodash.merge';
import merge from 'deepmerge';
import shvl from 'shvl';
const getPath = (obj, key, i = 0) => {
key = key.split ? key.split('.') : key;
for (; i < key.length; i++) {
obj = obj[key[i]] || (obj[key[i]] = !i && {});
}
return obj;
};
const setPath = (obj, key, val, k, res) => {
key = key.split('.');
k = key.pop();
return (res = getPath(obj, key)) && k ? (res[k] = val) : undefined;
};
const defaultReducer = (state, paths) =>

@@ -25,3 +9,3 @@ (paths.length === 0

(substate, path) =>
setPath(substate, path, getPath(state, path)) && substate,
shvl.set(substate, path, shvl.get(state, path)) && substate,
{}

@@ -69,3 +53,3 @@ ));

if (typeof savedState === 'object') {
store.replaceState(merge({}, store.state, savedState));
store.replaceState(merge(store.state, savedState));
}

@@ -72,0 +56,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