Comparing version 3.2.2 to 4.0.0
@@ -81,5 +81,3 @@ (function (global, factory) { | ||
var MemoryStorageInterface = | ||
/*#__PURE__*/ | ||
function () { | ||
var MemoryStorageInterface = /*#__PURE__*/function () { | ||
function MemoryStorageInterface() { | ||
@@ -136,3 +134,3 @@ _classCallCheck(this, MemoryStorageInterface); | ||
value: function removeItem(name) { | ||
var found = name in ls; | ||
var found = (name in ls); | ||
@@ -182,5 +180,3 @@ if (found) { | ||
var WebStorageEvent = | ||
/*#__PURE__*/ | ||
function () { | ||
var WebStorageEvent = /*#__PURE__*/function () { | ||
function WebStorageEvent() { | ||
@@ -266,5 +262,3 @@ _classCallCheck(this, WebStorageEvent); | ||
var WebStorage = | ||
/*#__PURE__*/ | ||
function () { | ||
var WebStorage = /*#__PURE__*/function () { | ||
/** | ||
@@ -505,3 +499,3 @@ * @param {Object} storage | ||
Object.defineProperty(Vue.prototype, "$".concat(_options.name), { | ||
Object.defineProperty(Vue.prototype || Vue.config.globalProperties, "$".concat(_options.name), { | ||
/** | ||
@@ -508,0 +502,0 @@ * Define $ls property |
@@ -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 a={},s=new(function(){function e(){o(this,e),Object.defineProperty(this,"length",{get:function(){return Object.keys(a).length}})}return t(e,[{key:"getItem",value:function(e){return e in a?a[e]:null}},{key:"setItem",value:function(e,t){return a[e]=t,!0}},{key:"removeItem",value:function(e){return!!(e in a)&&delete a[e]}},{key:"clear",value:function(){return a={},!0}},{key:"key",value:function(e){var t=Object.keys(a);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={install:function(e){var t=1<arguments.length&&void 0!==arguments[1]?arguments[1]:{},n=i(i({},t),{},{storage:t.storage||"local",name:t.name||"ls"});if(n.storage&&-1===["memory","local","session"].indexOf(n.storage))throw new Error('Vue-ls: Storage "'.concat(n.storage,'" is not supported'));var o=null;switch(n.storage){case"local":o="localStorage"in f?f.localStorage:null;break;case"session":o="sessionStorage"in f?f.sessionStorage:null;break;case"memory":o=s}o||(o=s,console.error('Vue-ls: Storage "'.concat(n.storage,'" is not supported your system, use memory storage')));var r=new l(o);r.setOptions(Object.assign(r.options,{namespace:""},n||{})),e[n.name]=r,Object.defineProperty(e.prototype,"$".concat(n.name),{get:function(){return r}})}};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 a={},s=new(function(){function e(){o(this,e),Object.defineProperty(this,"length",{get:function(){return Object.keys(a).length}})}return t(e,[{key:"getItem",value:function(e){return e in a?a[e]:null}},{key:"setItem",value:function(e,t){return a[e]=t,!0}},{key:"removeItem",value:function(e){return!!(e in a)&&delete a[e]}},{key:"clear",value:function(){return a={},!0}},{key:"key",value:function(e){var t=Object.keys(a);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={install:function(e){var t=1<arguments.length&&void 0!==arguments[1]?arguments[1]:{},n=i(i({},t),{},{storage:t.storage||"local",name:t.name||"ls"});if(n.storage&&-1===["memory","local","session"].indexOf(n.storage))throw new Error('Vue-ls: Storage "'.concat(n.storage,'" is not supported'));var o=null;switch(n.storage){case"local":o="localStorage"in f?f.localStorage:null;break;case"session":o="sessionStorage"in f?f.sessionStorage:null;break;case"memory":o=s}o||(o=s,console.error('Vue-ls: Storage "'.concat(n.storage,'" is not supported your system, use memory storage')));var r=new l(o);r.setOptions(Object.assign(r.options,{namespace:""},n||{})),e[n.name]=r,Object.defineProperty(e.prototype||e.config.globalProperties,"$".concat(n.name),{get:function(){return r}})}};return f.VueStorage=e}); |
{ | ||
"name": "vue-ls", | ||
"version": "3.2.2", | ||
"version": "4.0.0", | ||
"description": "Vue plugin for work with LocalStorage from Vue context", | ||
@@ -5,0 +5,0 @@ "main": "dist/vue-ls.js", |
@@ -11,3 +11,3 @@ <p align="center"> | ||
<a href="https://github.com/RobinCK/vue-ls"><img src="https://img.shields.io/badge/vuejs-2.x-brightgreen.svg?style=flat-square"></a> | ||
<a href="https://travis-ci.org/RobinCK/vue-ls"><img src="https://img.shields.io/travis/RobinCK/vue-ls.svg?style=flat-square"></a> | ||
<a href="https://github.com/RobinCK/vue-ls"><img src="https://img.shields.io/badge/vuejs-3.x-brightgreen.svg?style=flat-square"></a> | ||
<a href="https://coveralls.io/github/RobinCK/vue-ls?branch=master"><img src="https://img.shields.io/coveralls/RobinCK/vue-ls.svg?style=flat-square"></a> | ||
@@ -21,3 +21,2 @@ <a href="http://inch-ci.org/github/RobinCK/vue-ls"><img src="https://inch-ci.org/github/RobinCK/vue-ls.svg?branch=master&style=flat-squar"></a> | ||
<a href="https://www.npmjs.com/package/vue-ls"><img src="https://img.shields.io/npm/dm/vue-ls.svg?style=flat-square"></a> | ||
<a href="https://david-dm.org/robinck/vue-ls"><img src="https://img.shields.io/david/RobinCk/vue-ls.svg?style=flat-square"></a> | ||
<a href="https://www.npmjs.com/package/vue-ls"><img src="https://img.shields.io/npm/v/vue-ls.svg?style=flat-square"></a> | ||
@@ -29,7 +28,3 @@ <a href="https://cdnjs.com/libraries/vue-ls"><img src="https://img.shields.io/cdnjs/v/vue-ls.svg"></a> | ||
<p align="center"> | ||
<img src="https://app.saucelabs.com/browser-matrix/Robin_ck.svg"> | ||
</p> | ||
# vue-ls | ||
@@ -36,0 +31,0 @@ |
@@ -62,3 +62,3 @@ import { MemoryStorage, WebStorage } from './storage'; | ||
Vue[_options.name] = ls; // eslint-disable-line | ||
Object.defineProperty(Vue.prototype, `$${_options.name}`, { | ||
Object.defineProperty(Vue.prototype || Vue.config.globalProperties, `$${_options.name}`, { | ||
/** | ||
@@ -65,0 +65,0 @@ * Define $ls property |
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
39183
790
216