Comparing version 3.0.0 to 3.0.3
@@ -13,16 +13,28 @@ (function (global, factory) { | ||
var MemoryStorage = function () { | ||
function MemoryStorage() { | ||
_classCallCheck(this, MemoryStorage); | ||
var MemoryStorageInterface = function () { | ||
function MemoryStorageInterface() { | ||
_classCallCheck(this, MemoryStorageInterface); | ||
Object.defineProperty(this, 'length', { | ||
/** | ||
* Define length property | ||
* | ||
* @return {number} | ||
*/ | ||
get: function get() { | ||
return Object.keys(ls).length; | ||
} | ||
}); | ||
} | ||
_createClass(MemoryStorage, null, [{ | ||
/** | ||
* Get item | ||
* | ||
* @param {string} name | ||
* @returns {*} | ||
*/ | ||
_createClass(MemoryStorageInterface, [{ | ||
key: 'getItem', | ||
/** | ||
* Get item | ||
* | ||
* @param {string} name | ||
* @returns {*} | ||
*/ | ||
value: function getItem(name) { | ||
@@ -95,19 +107,9 @@ return name in ls ? ls[name] : null; | ||
} | ||
/** | ||
* Define length property | ||
* | ||
* @return {number} | ||
*/ | ||
}, { | ||
key: 'length', | ||
get: function get() { | ||
return Object.keys(ls).length; | ||
} | ||
}]); | ||
return MemoryStorage; | ||
return MemoryStorageInterface; | ||
}(); | ||
var MemoryStorage = new MemoryStorageInterface(); | ||
var _extends$1 = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; | ||
@@ -114,0 +116,0 @@ |
@@ -1,1 +0,1 @@ | ||
!function(e,n){"object"==typeof exports&&"undefined"!=typeof module?module.exports=n():"function"==typeof define&&define.amd?define(n):e.VueStorage=n()}(this,function(){"use strict";var e=function(){function e(e,n){for(var t=0;t<n.length;t++){var o=n[t];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(e,o.key,o)}}return function(n,t,o){return t&&e(n.prototype,t),o&&e(n,o),n}}();var n={},t=function(){function t(){!function(e,n){if(!(e instanceof n))throw new TypeError("Cannot call a class as a function")}(this,t)}return e(t,null,[{key:"getItem",value:function(e){return e in n?n[e]:null}},{key:"setItem",value:function(e,t){return n[e]=t,!0}},{key:"removeItem",value:function(e){return!!(e in n)&&delete n[e]}},{key:"clear",value:function(){return n={},!0}},{key:"key",value:function(e){var t=Object.keys(n);return void 0!==t[e]?t[e]:null}},{key:"length",get:function(){return Object.keys(n).length}}]),t}(),o=Object.assign||function(e){for(var n=1;n<arguments.length;n++){var t=arguments[n];for(var o in t)Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o])}return e},r=function(){function e(e,n){for(var t=0;t<n.length;t++){var o=n[t];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(e,o.key,o)}}return function(n,t,o){return t&&e(n.prototype,t),o&&e(n,o),n}}();var i=function(){function e(n){if(function(e,n){if(!(e instanceof n))throw new TypeError("Cannot call a class as a function")}(this,e),this.storage=n,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],u.emit,!1):window.attachEvent?window.attachEvent("on"+this.options.events[t],u.emit):window["on"+this.options.events[t]]=u.emit}return r(e,[{key:"setOptions",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};this.options=o(this.options,e)}},{key:"set",value:function(e,n){var t=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null,o=JSON.stringify({value:n,expire:null!==t?(new Date).getTime()+t:null});this.storage.setItem(this.options.namespace+e,o)}},{key:"get",value:function(e){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,t=this.storage.getItem(this.options.namespace+e);if(null!==t)try{var o=JSON.parse(t);if(null===o.expire)return o.value;if(o.expire>=(new Date).getTime())return o.value;this.remove(e)}catch(e){return n}return n}},{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=[],n=0;n<this.length;n++){var t=this.storage.key(n);!1!==new RegExp("^"+this.options.namespace+".+","i").test(t)&&e.push(t)}for(var o in e)this.storage.removeItem(e[o])}}},{key:"on",value:function(e,n){u.on(this.options.namespace+e,n)}},{key:"off",value:function(e,n){u.off(this.options.namespace+e,n)}}]),e}(),a=function(){function e(e,n){for(var t=0;t<n.length;t++){var o=n[t];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(e,o.key,o)}}return function(n,t,o){return t&&e(n.prototype,t),o&&e(n,o),n}}();var s={},u=function(){function e(){!function(e,n){if(!(e instanceof n))throw new TypeError("Cannot call a class as a function")}(this,e)}return a(e,null,[{key:"on",value:function(e,n){void 0===s[e]&&(s[e]=[]),s[e].push(n)}},{key:"off",value:function(e,n){s[e].length?s[e].splice(s[e].indexOf(n),1):s[e]=[]}},{key:"emit",value:function(e){var n=e||window.event,t=function(e){try{return JSON.parse(e).value}catch(n){return e}};if(void 0!==n&&void 0!==n.key){var o=s[n.key];void 0!==o&&o.forEach(function(e){e(t(n.newValue),t(n.oldValue),n.url||n.uri)})}}}]),e}(),l=Object.assign||function(e){for(var n=1;n<arguments.length;n++){var t=arguments[n];for(var o in t)Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o])}return e},c="undefined"!=typeof window?window:global||{},f={install:function(e){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},o=l({},n,{storage:n.storage||"local",name:n.name||"ls"});if(o.storage&&-1===["memory","local","session"].indexOf(o.storage))throw new Error('Vue-ls: Storage "'+o.storage+'" is not supported');var r=null;switch(o.storage){case"local":r="localStorage"in c?c.localStorage:null;break;case"session":r="sessionStorage"in c?c.sessionStorage:null;break;case"memory":r=t}r||(r=t,console.error('Vue-ls: Storage "'+o.storage+'" is not supported your system, use memory storage'));var a=new i(r);a.setOptions(l(a.options,{namespace:""},o||{})),e[o.name]=a,Object.defineProperty(e.prototype,"$"+o.name,{get:function(){return a}})}};return c.VueStorage=f,f}); | ||
!function(e,n){"object"==typeof exports&&"undefined"!=typeof module?module.exports=n():"function"==typeof define&&define.amd?define(n):e.VueStorage=n()}(this,function(){"use strict";var e=function(){function e(e,n){for(var t=0;t<n.length;t++){var o=n[t];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(e,o.key,o)}}return function(n,t,o){return t&&e(n.prototype,t),o&&e(n,o),n}}();var n={},t=new(function(){function t(){!function(e,n){if(!(e instanceof n))throw new TypeError("Cannot call a class as a function")}(this,t),Object.defineProperty(this,"length",{get:function(){return Object.keys(n).length}})}return e(t,[{key:"getItem",value:function(e){return e in n?n[e]:null}},{key:"setItem",value:function(e,t){return n[e]=t,!0}},{key:"removeItem",value:function(e){return!!(e in n)&&delete n[e]}},{key:"clear",value:function(){return n={},!0}},{key:"key",value:function(e){var t=Object.keys(n);return void 0!==t[e]?t[e]:null}}]),t}()),o=Object.assign||function(e){for(var n=1;n<arguments.length;n++){var t=arguments[n];for(var o in t)Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o])}return e},r=function(){function e(e,n){for(var t=0;t<n.length;t++){var o=n[t];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(e,o.key,o)}}return function(n,t,o){return t&&e(n.prototype,t),o&&e(n,o),n}}();var i=function(){function e(n){if(function(e,n){if(!(e instanceof n))throw new TypeError("Cannot call a class as a function")}(this,e),this.storage=n,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],u.emit,!1):window.attachEvent?window.attachEvent("on"+this.options.events[t],u.emit):window["on"+this.options.events[t]]=u.emit}return r(e,[{key:"setOptions",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};this.options=o(this.options,e)}},{key:"set",value:function(e,n){var t=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null,o=JSON.stringify({value:n,expire:null!==t?(new Date).getTime()+t:null});this.storage.setItem(this.options.namespace+e,o)}},{key:"get",value:function(e){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,t=this.storage.getItem(this.options.namespace+e);if(null!==t)try{var o=JSON.parse(t);if(null===o.expire)return o.value;if(o.expire>=(new Date).getTime())return o.value;this.remove(e)}catch(e){return n}return n}},{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=[],n=0;n<this.length;n++){var t=this.storage.key(n);!1!==new RegExp("^"+this.options.namespace+".+","i").test(t)&&e.push(t)}for(var o in e)this.storage.removeItem(e[o])}}},{key:"on",value:function(e,n){u.on(this.options.namespace+e,n)}},{key:"off",value:function(e,n){u.off(this.options.namespace+e,n)}}]),e}(),a=function(){function e(e,n){for(var t=0;t<n.length;t++){var o=n[t];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(e,o.key,o)}}return function(n,t,o){return t&&e(n.prototype,t),o&&e(n,o),n}}();var s={},u=function(){function e(){!function(e,n){if(!(e instanceof n))throw new TypeError("Cannot call a class as a function")}(this,e)}return a(e,null,[{key:"on",value:function(e,n){void 0===s[e]&&(s[e]=[]),s[e].push(n)}},{key:"off",value:function(e,n){s[e].length?s[e].splice(s[e].indexOf(n),1):s[e]=[]}},{key:"emit",value:function(e){var n=e||window.event,t=function(e){try{return JSON.parse(e).value}catch(n){return e}};if(void 0!==n&&void 0!==n.key){var o=s[n.key];void 0!==o&&o.forEach(function(e){e(t(n.newValue),t(n.oldValue),n.url||n.uri)})}}}]),e}(),l=Object.assign||function(e){for(var n=1;n<arguments.length;n++){var t=arguments[n];for(var o in t)Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o])}return e},c="undefined"!=typeof window?window:global||{},f={install:function(e){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},o=l({},n,{storage:n.storage||"local",name:n.name||"ls"});if(o.storage&&-1===["memory","local","session"].indexOf(o.storage))throw new Error('Vue-ls: Storage "'+o.storage+'" is not supported');var r=null;switch(o.storage){case"local":r="localStorage"in c?c.localStorage:null;break;case"session":r="sessionStorage"in c?c.sessionStorage:null;break;case"memory":r=t}r||(r=t,console.error('Vue-ls: Storage "'+o.storage+'" is not supported your system, use memory storage'));var a=new i(r);a.setOptions(l(a.options,{namespace:""},o||{})),e[o.name]=a,Object.defineProperty(e.prototype,"$"+o.name,{get:function(){return a}})}};return c.VueStorage=f,f}); |
{ | ||
"name": "vue-ls", | ||
"version": "3.0.0", | ||
"version": "3.0.3", | ||
"description": "Vue plugin for work with LocalStorage from Vue context", | ||
@@ -5,0 +5,0 @@ "main": "dist/vue-ls.js", |
@@ -1,2 +0,2 @@ | ||
import { MemoryStorageInterface, WebStorage } from './storage'; | ||
import { MemoryStorage, WebStorage } from './storage'; | ||
@@ -43,3 +43,3 @@ // eslint-disable-next-line | ||
break; | ||
case 'memory': store = MemoryStorageInterface; | ||
case 'memory': store = MemoryStorage; | ||
break; | ||
@@ -49,3 +49,3 @@ } | ||
if (!store) { | ||
store = MemoryStorageInterface; | ||
store = MemoryStorage; | ||
// eslint-disable-next-line | ||
@@ -52,0 +52,0 @@ console.error(`Vue-ls: Storage "${_options.storage}" is not supported your system, use memory storage`); |
@@ -1,2 +0,2 @@ | ||
import { MemoryStorageInterface } from './MemoryStorageInterface'; | ||
import { MemoryStorage } from './MemoryStorage'; | ||
import { WebStorage } from './WebStorage'; | ||
@@ -6,5 +6,5 @@ import { WebStorageEvent } from './WebStorageEvent'; | ||
export { | ||
MemoryStorageInterface, | ||
MemoryStorage, | ||
WebStorage, | ||
WebStorageEvent, | ||
}; |
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
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
38671
743
0