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

vue-ls

Package Overview
Dependencies
Maintainers
1
Versions
59
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

vue-ls - npm Package Compare versions

Comparing version 4.1.0 to 4.2.0

12

dist/vue-ls.js

@@ -474,7 +474,15 @@ (function (global, factory) {

case 'local':
store = 'localStorage' in _global ? _global.localStorage : null;
try {
store = 'localStorage' in _global ? _global.localStorage : null;
} catch (e) {// In some situations the browser will throw a security exception when attempting to access
}
break;
case 'session':
store = 'sessionStorage' in _global ? _global.sessionStorage : null;
try {
store = 'sessionStorage' in _global ? _global.sessionStorage : null;
} catch (e) {// In some situations the browser will throw a security exception when attempting to access
}
break;

@@ -481,0 +489,0 @@

2

dist/vue-ls.min.js

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

!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e="undefined"!=typeof globalThis?globalThis:e||self).VueStorage=t()}(this,function(){"use strict";function o(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function r(e,t){for(var n=0;n<t.length;n++){var o=t[n];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(e,o.key,o)}}function t(e,t,n){return t&&r(e.prototype,t),n&&r(e,n),e}function n(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(t);e&&(o=o.filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable})),n.push.apply(n,o)}return n}function i(r){for(var e=1;e<arguments.length;e++){var i=null!=arguments[e]?arguments[e]:{};e%2?n(Object(i),!0).forEach(function(e){var t,n,o;t=r,o=i[n=e],n in t?Object.defineProperty(t,n,{value:o,enumerable:!0,configurable:!0,writable:!0}):t[n]=o}):Object.getOwnPropertyDescriptors?Object.defineProperties(r,Object.getOwnPropertyDescriptors(i)):n(Object(i)).forEach(function(e){Object.defineProperty(r,e,Object.getOwnPropertyDescriptor(i,e))})}return r}var s={},a=new(function(){function e(){o(this,e),Object.defineProperty(this,"length",{get:function(){return Object.keys(s).length}})}return t(e,[{key:"getItem",value:function(e){return e in s?s[e]:null}},{key:"setItem",value:function(e,t){return s[e]=t,!0}},{key:"removeItem",value:function(e){return!!(e in s)&&delete s[e]}},{key:"clear",value:function(){return s={},!0}},{key:"key",value:function(e){var t=Object.keys(s);return void 0!==t[e]?t[e]:null}}]),e}()),u={},c=function(){function e(){o(this,e)}return t(e,null,[{key:"on",value:function(e,t){void 0===u[e]&&(u[e]=[]),u[e].push(t)}},{key:"off",value:function(e,t){u[e].length?u[e].splice(u[e].indexOf(t),1):u[e]=[]}},{key:"emit",value:function(e){var t=e||window.event,n=function(t){try{return JSON.parse(t).value}catch(e){return t}};if(void 0!==t&&void 0!==t.key){var o=u[t.key];void 0!==o&&o.forEach(function(e){e(n(t.newValue),n(t.oldValue),t.url||t.uri)})}}}]),e}(),l=function(){function n(e){if(o(this,n),this.storage=e,this.options={namespace:"",events:["storage"]},Object.defineProperty(this,"length",{get:function(){return this.storage.length}}),"undefined"!=typeof window)for(var t in this.options.events)window.addEventListener?window.addEventListener(this.options.events[t],c.emit,!1):window.attachEvent?window.attachEvent("on".concat(this.options.events[t]),c.emit):window["on".concat(this.options.events[t])]=c.emit}return t(n,[{key:"setOptions",value:function(){var e=0<arguments.length&&void 0!==arguments[0]?arguments[0]:{};this.options=Object.assign(this.options,e)}},{key:"set",value:function(e,t){var n=2<arguments.length&&void 0!==arguments[2]?arguments[2]:null,o=JSON.stringify({value:t,expire:null!==n?(new Date).getTime()+n:null});this.storage.setItem(this.options.namespace+e,o)}},{key:"get",value:function(e){var t=1<arguments.length&&void 0!==arguments[1]?arguments[1]:null,n=this.storage.getItem(this.options.namespace+e);if(null!==n)try{var o=JSON.parse(n);if(null===o.expire)return o.value;if(o.expire>=(new Date).getTime())return o.value;this.remove(e)}catch(e){return t}return t}},{key:"key",value:function(e){return this.storage.key(e)}},{key:"remove",value:function(e){return this.storage.removeItem(this.options.namespace+e)}},{key:"clear",value:function(){if(0!==this.length){for(var e=[],t=0;t<this.length;t++){var n=this.storage.key(t);!1!==new RegExp("^".concat(this.options.namespace,".+"),"i").test(n)&&e.push(n)}for(var o in e)this.storage.removeItem(e[o])}}},{key:"on",value:function(e,t){c.on(this.options.namespace+e,t)}},{key:"off",value:function(e,t){c.off(this.options.namespace+e,t)}}]),n}(),f="undefined"!=typeof window?window:global||{},e={useStorage:function(e){var t=i(i({},e),{},{storage:e.storage||"local",name:e.name||"ls"});if(t.storage&&-1===["memory","local","session"].indexOf(t.storage))throw new Error('Vue-ls: Storage "'.concat(t.storage,'" is not supported'));var n=null;switch(t.storage){case"local":n="localStorage"in f?f.localStorage:null;break;case"session":n="sessionStorage"in f?f.sessionStorage:null;break;case"memory":n=a}n||(n=a,console.error('Vue-ls: Storage "'.concat(t.storage,'" is not supported your system, use memory storage')));var o=new l(n);return o.setOptions(Object.assign(o.options,{namespace:""},t||{})),{ls:o,_options:t}},install:function(e){var t=1<arguments.length&&void 0!==arguments[1]?arguments[1]:{},n=this.useStorage(t),o=n.ls,r=n._options;e[r.name]=o,Object.defineProperty(e.prototype||e.config.globalProperties,"$".concat(r.name),{get:function(){return o}})}};return f.VueStorage=e});
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e="undefined"!=typeof globalThis?globalThis:e||self).VueStorage=t()}(this,function(){"use strict";function o(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function r(e,t){for(var n=0;n<t.length;n++){var o=t[n];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(e,o.key,o)}}function t(e,t,n){return t&&r(e.prototype,t),n&&r(e,n),e}function n(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(t);e&&(o=o.filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable})),n.push.apply(n,o)}return n}function i(r){for(var e=1;e<arguments.length;e++){var i=null!=arguments[e]?arguments[e]:{};e%2?n(Object(i),!0).forEach(function(e){var t,n,o;t=r,o=i[n=e],n in t?Object.defineProperty(t,n,{value:o,enumerable:!0,configurable:!0,writable:!0}):t[n]=o}):Object.getOwnPropertyDescriptors?Object.defineProperties(r,Object.getOwnPropertyDescriptors(i)):n(Object(i)).forEach(function(e){Object.defineProperty(r,e,Object.getOwnPropertyDescriptor(i,e))})}return r}var s={},a=new(function(){function e(){o(this,e),Object.defineProperty(this,"length",{get:function(){return Object.keys(s).length}})}return t(e,[{key:"getItem",value:function(e){return e in s?s[e]:null}},{key:"setItem",value:function(e,t){return s[e]=t,!0}},{key:"removeItem",value:function(e){return!!(e in s)&&delete s[e]}},{key:"clear",value:function(){return s={},!0}},{key:"key",value:function(e){var t=Object.keys(s);return void 0!==t[e]?t[e]:null}}]),e}()),u={},c=function(){function e(){o(this,e)}return t(e,null,[{key:"on",value:function(e,t){void 0===u[e]&&(u[e]=[]),u[e].push(t)}},{key:"off",value:function(e,t){u[e].length?u[e].splice(u[e].indexOf(t),1):u[e]=[]}},{key:"emit",value:function(e){var t=e||window.event,n=function(t){try{return JSON.parse(t).value}catch(e){return t}};if(void 0!==t&&void 0!==t.key){var o=u[t.key];void 0!==o&&o.forEach(function(e){e(n(t.newValue),n(t.oldValue),t.url||t.uri)})}}}]),e}(),l=function(){function n(e){if(o(this,n),this.storage=e,this.options={namespace:"",events:["storage"]},Object.defineProperty(this,"length",{get:function(){return this.storage.length}}),"undefined"!=typeof window)for(var t in this.options.events)window.addEventListener?window.addEventListener(this.options.events[t],c.emit,!1):window.attachEvent?window.attachEvent("on".concat(this.options.events[t]),c.emit):window["on".concat(this.options.events[t])]=c.emit}return t(n,[{key:"setOptions",value:function(){var e=0<arguments.length&&void 0!==arguments[0]?arguments[0]:{};this.options=Object.assign(this.options,e)}},{key:"set",value:function(e,t){var n=2<arguments.length&&void 0!==arguments[2]?arguments[2]:null,o=JSON.stringify({value:t,expire:null!==n?(new Date).getTime()+n:null});this.storage.setItem(this.options.namespace+e,o)}},{key:"get",value:function(e){var t=1<arguments.length&&void 0!==arguments[1]?arguments[1]:null,n=this.storage.getItem(this.options.namespace+e);if(null!==n)try{var o=JSON.parse(n);if(null===o.expire)return o.value;if(o.expire>=(new Date).getTime())return o.value;this.remove(e)}catch(e){return t}return t}},{key:"key",value:function(e){return this.storage.key(e)}},{key:"remove",value:function(e){return this.storage.removeItem(this.options.namespace+e)}},{key:"clear",value:function(){if(0!==this.length){for(var e=[],t=0;t<this.length;t++){var n=this.storage.key(t);!1!==new RegExp("^".concat(this.options.namespace,".+"),"i").test(n)&&e.push(n)}for(var o in e)this.storage.removeItem(e[o])}}},{key:"on",value:function(e,t){c.on(this.options.namespace+e,t)}},{key:"off",value:function(e,t){c.off(this.options.namespace+e,t)}}]),n}(),f="undefined"!=typeof window?window:global||{},e={useStorage:function(e){var t=i(i({},e),{},{storage:e.storage||"local",name:e.name||"ls"});if(t.storage&&-1===["memory","local","session"].indexOf(t.storage))throw new Error('Vue-ls: Storage "'.concat(t.storage,'" is not supported'));var n=null;switch(t.storage){case"local":try{n="localStorage"in f?f.localStorage:null}catch(e){}break;case"session":try{n="sessionStorage"in f?f.sessionStorage:null}catch(e){}break;case"memory":n=a}n||(n=a,console.error('Vue-ls: Storage "'.concat(t.storage,'" is not supported your system, use memory storage')));var o=new l(n);return o.setOptions(Object.assign(o.options,{namespace:""},t||{})),{ls:o,_options:t}},install:function(e){var t=1<arguments.length&&void 0!==arguments[1]?arguments[1]:{},n=this.useStorage(t),o=n.ls,r=n._options;e[r.name]=o,Object.defineProperty(e.prototype||e.config.globalProperties,"$".concat(r.name),{get:function(){return o}})}};return f.VueStorage=e});
{
"name": "vue-ls",
"version": "4.1.0",
"version": "4.2.0",
"description": "Vue plugin for work with LocalStorage from Vue context",

@@ -5,0 +5,0 @@ "main": "dist/vue-ls.js",

@@ -31,13 +31,23 @@ import { MemoryStorage, WebStorage } from './storage';

case 'local':
store = 'localStorage' in _global
? _global.localStorage
: null
;
try {
store = 'localStorage' in _global
? _global.localStorage
: null
;
} catch (e) {
// In some situations the browser will
// throw a security exception when attempting to access
}
break;
case 'session':
store = 'sessionStorage' in _global
? _global.sessionStorage
: null
;
try {
store = 'sessionStorage' in _global
? _global.sessionStorage
: null
;
} catch (e) {
// In some situations the browser will
// throw a security exception when attempting to access
}
break;

@@ -44,0 +54,0 @@ case 'memory':

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