New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.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 2.0.1 to 2.0.2

.nyc_output/3a01ee8a9af96161a555c72814d8d285.json

25

dist/vue-ls.js

@@ -45,18 +45,2 @@ (function (global, factory) {

var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) {
return typeof obj;
} : function (obj) {
return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
};
var classCallCheck = function (instance, Constructor) {

@@ -119,3 +103,3 @@ if (!(instance instanceof Constructor)) {

if (all) {
if (typeof all !== 'undefined') {
all.forEach(emit);

@@ -125,8 +109,3 @@ }

function emit(listener) {
var item = JSON.parse(e.newValue);
var oldItem = JSON.parse(e.oldValue);
var val = (typeof item === 'undefined' ? 'undefined' : _typeof(item)) === 'object' ? item.value : item;
var oldVal = oldItem && (typeof oldItem === 'undefined' ? 'undefined' : _typeof(oldItem)) === 'object' ? oldItem.value : oldItem;
listener(val, oldVal, e.url || e.uri);
listener(JSON.parse(e.newValue).value, JSON.parse(e.oldValue).value, e.url || e.uri);
}

@@ -133,0 +112,0 @@ }

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

!function(e,n){"object"==typeof exports&&"undefined"!=typeof module?module.exports=n():"function"==typeof define&&define.amd?define(n):e["vue-ls"]=n()}(this,function(){"use strict";function e(e){function n(n){var t=JSON.parse(e.newValue),i=JSON.parse(e.oldValue),r="object"===("undefined"==typeof t?"undefined":o(t))?t.value:t,u=i&&"object"===("undefined"==typeof i?"undefined":o(i))?i.value:i;n(r,u,e.url||e.uri)}if(e||(e=window.event),"undefined"!=typeof e&&"undefined"!=typeof e.key){var t=a[e.key];t&&t.forEach(n)}}var n={},t={getItem:function(e){return e in n?n[e]:null},setItem:function(e,t){return n[e]=t,!0},removeItem:function(e){var t=e in n;return!!t&&delete n[e]},clear:function(){return n={},!0},key:function(e){var t=Object.keys(n);return"undefined"!=typeof t[e]?t[e]:null}};Object.defineProperty(t,"length",{get:function(){return Object.keys(n).length}});var o="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},i=function(e,n){if(!(e instanceof n))throw new TypeError("Cannot call a class as a function")},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}}(),u=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},a={},f=function(){function n(t,o){if(i(this,n),this.storage=t,this.options=u({namespace:"",events:["storage"]},o||{}),Object.defineProperty(this,"length",{get:function(){return this.storage.length}}),"undefined"!=typeof window)for(var r in this.options.events)window.addEventListener?window.addEventListener(this.options.events[r],e,!1):window.attachEvent?window.attachEvent("on"+this.options.events[r],e):window["on"+this.options.events[r]]=e}return r(n,[{key:"set",value:function(e,n){var t=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null;this.storage.setItem(this.options.namespace+e,JSON.stringify({value:n,expire:null!==t?(new Date).getTime()+t:null}))}},{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){var o=JSON.parse(t);if(null===o.expire)return o.value;if(o.expire>=(new Date).getTime())return o.value;this.remove(e)}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),o=new RegExp("^"+this.options.namespace+".+","i");o.test(t)!==!1&&e.push(t)}for(var i in e)this.storage.removeItem(e[i])}}},{key:"on",value:function(e,n){a[e]?a[e].push(n):a[e]=[n]}},{key:"off",value:function(e,n){var t=a[e];t.length>1?t.splice(t.indexOf(n),1):a[e]=[]}}]),n}(),s="undefined"!=typeof window&&"localStorage"in window?window.localStorage:t,l=new f(s),c={install:function(e,n){l.options=u(l.options,{namespace:""},n||{}),e.ls=l,Object.defineProperty(e.prototype,"$ls",{get:function(){return l}})}};return"undefined"!=typeof window&&(window.VueLocalStorage=c),c});
!function(e,n){"object"==typeof exports&&"undefined"!=typeof module?module.exports=n():"function"==typeof define&&define.amd?define(n):e["vue-ls"]=n()}(this,function(){"use strict";function e(e){function n(n){n(JSON.parse(e.newValue).value,JSON.parse(e.oldValue).value,e.url||e.uri)}if(e||(e=window.event),"undefined"!=typeof e&&"undefined"!=typeof e.key){var t=a[e.key];"undefined"!=typeof t&&t.forEach(n)}}var n={},t={getItem:function(e){return e in n?n[e]:null},setItem:function(e,t){return n[e]=t,!0},removeItem:function(e){var t=e in n;return!!t&&delete n[e]},clear:function(){return n={},!0},key:function(e){var t=Object.keys(n);return"undefined"!=typeof t[e]?t[e]:null}};Object.defineProperty(t,"length",{get:function(){return Object.keys(n).length}});var o=function(e,n){if(!(e instanceof n))throw new TypeError("Cannot call a class as a function")},i=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}}(),r=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},a={},u=function(){function n(t,i){if(o(this,n),this.storage=t,this.options=r({namespace:"",events:["storage"]},i||{}),Object.defineProperty(this,"length",{get:function(){return this.storage.length}}),"undefined"!=typeof window)for(var a in this.options.events)window.addEventListener?window.addEventListener(this.options.events[a],e,!1):window.attachEvent?window.attachEvent("on"+this.options.events[a],e):window["on"+this.options.events[a]]=e}return i(n,[{key:"set",value:function(e,n){var t=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null;this.storage.setItem(this.options.namespace+e,JSON.stringify({value:n,expire:null!==t?(new Date).getTime()+t:null}))}},{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){var o=JSON.parse(t);if(null===o.expire)return o.value;if(o.expire>=(new Date).getTime())return o.value;this.remove(e)}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),o=new RegExp("^"+this.options.namespace+".+","i");o.test(t)!==!1&&e.push(t)}for(var i in e)this.storage.removeItem(e[i])}}},{key:"on",value:function(e,n){a[e]?a[e].push(n):a[e]=[n]}},{key:"off",value:function(e,n){var t=a[e];t.length>1?t.splice(t.indexOf(n),1):a[e]=[]}}]),n}(),s="undefined"!=typeof window&&"localStorage"in window?window.localStorage:t,f=new u(s),l={install:function(e,n){f.options=r(f.options,{namespace:""},n||{}),e.ls=f,Object.defineProperty(e.prototype,"$ls",{get:function(){return f}})}};return"undefined"!=typeof window&&(window.VueLocalStorage=l),l});
//# sourceMappingURL=vue-ls.min.js.map
{
"name": "vue-ls",
"version": "2.0.1",
"version": "2.0.2",
"description": "Vue plugin for work with LocalStorage from Vue context",

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

@@ -14,3 +14,3 @@ const eventListeners = {};

if (all) {
if (typeof all !== 'undefined') {
all.forEach(emit);

@@ -20,8 +20,3 @@ }

function emit (listener) {
let item = JSON.parse(e.newValue);
let oldItem = JSON.parse(e.oldValue);
let val = typeof item === 'object' ? item.value : item;
let oldVal = oldItem && typeof oldItem === 'object' ? oldItem.value : oldItem;
listener(val, oldVal, e.url || e.uri);
listener(JSON.parse(e.newValue).value, JSON.parse(e.oldValue).value, e.url || e.uri);
}

@@ -28,0 +23,0 @@ }

@@ -7,8 +7,4 @@ import test from 'ava';

const namespace = 'test__';
Vue.use(Ls);
Vue.use(Ls, {
namespace: namespace
});
test.beforeEach(() => {

@@ -32,5 +28,6 @@ window.localStorage.clear();

change({key: 'item_three_test', newValue: JSON.stringify('val'), oldValue: JSON.stringify('old_val')});
change({key: 'item_three_test', newValue: JSON.stringify({value: 'val', expire: null}), oldValue: JSON.stringify({value: 'old_val', expire: null})});
change({key: 'item_undefined_test', newValue: JSON.stringify({value: 'val', expire: null}), oldValue: JSON.stringify({value: 'old_val', expire: null})});
change();
});

@@ -33,2 +33,4 @@ import test from 'ava';

test('Get key by index', t => {
t.plan(2);
Vue.ls.set('key_item_one_test', 'val_one');

@@ -38,2 +40,3 @@ Vue.ls.set('key_item_two_test', 'val_two');

t.is(Vue.ls.key(1), `${namespace}key_item_two_test`);
t.is(Vue.ls.key(100), null);
});

@@ -40,0 +43,0 @@

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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