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 2.3.0 to 2.3.3

184

dist/vue-ls.js

@@ -88,2 +88,119 @@ (function (global, factory) {

var asyncGenerator = function () {
function AwaitValue(value) {
this.value = value;
}
function AsyncGenerator(gen) {
var front, back;
function send(key, arg) {
return new Promise(function (resolve, reject) {
var request = {
key: key,
arg: arg,
resolve: resolve,
reject: reject,
next: null
};
if (back) {
back = back.next = request;
} else {
front = back = request;
resume(key, arg);
}
});
}
function resume(key, arg) {
try {
var result = gen[key](arg);
var value = result.value;
if (value instanceof AwaitValue) {
Promise.resolve(value.value).then(function (arg) {
resume("next", arg);
}, function (arg) {
resume("throw", arg);
});
} else {
settle(result.done ? "return" : "normal", result.value);
}
} catch (err) {
settle("throw", err);
}
}
function settle(type, value) {
switch (type) {
case "return":
front.resolve({
value: value,
done: true
});
break;
case "throw":
front.reject(value);
break;
default:
front.resolve({
value: value,
done: false
});
break;
}
front = front.next;
if (front) {
resume(front.key, front.arg);
} else {
back = null;
}
}
this._invoke = send;
if (typeof gen.return !== "function") {
this.return = undefined;
}
}
if (typeof Symbol === "function" && Symbol.asyncIterator) {
AsyncGenerator.prototype[Symbol.asyncIterator] = function () {
return this;
};
}
AsyncGenerator.prototype.next = function (arg) {
return this._invoke("next", arg);
};
AsyncGenerator.prototype.throw = function (arg) {
return this._invoke("throw", arg);
};
AsyncGenerator.prototype.return = function (arg) {
return this._invoke("return", arg);
};
return {
wrap: function (fn) {
return function () {
return new AsyncGenerator(fn.apply(this, arguments));
};
},
await: function (value) {
return new AwaitValue(value);
}
};
}();
var classCallCheck = function (instance, Constructor) {

@@ -135,3 +252,7 @@ if (!(instance instanceof Constructor)) {

var _class$2 = function () {
/**
* Event class
*/
var _class$1 = function () {
function _class() {

@@ -143,2 +264,9 @@ classCallCheck(this, _class);

key: 'on',
/**
* Add storage change event
*
* @param {string} name
* @param {Function} callback
*/
value: function on(name, callback) {

@@ -151,2 +279,10 @@ if (typeof listeners[name] === 'undefined') {

}
/**
* Remove storage change event
*
* @param {string} name
* @param {Function} callback
*/
}, {

@@ -161,2 +297,9 @@ key: 'off',

}
/**
* Emit event
*
* @param {Object} event
*/
}, {

@@ -167,17 +310,13 @@ key: 'emit',

var fire = function fire(listener) {
var newValue = void 0;
var oldValue = void 0;
var getValue = function getValue(data) {
try {
newValue = JSON.parse(e.newValue).value;
return JSON.parse(data).value;
} catch (err) {
newValue = e.newValue;
return data;
}
};
try {
oldValue = JSON.parse(e.oldValue).value;
} catch (err) {
oldValue = e.oldValue;
}
var fire = function fire(listener) {
var newValue = getValue(e.newValue);
var oldValue = getValue(e.oldValue);

@@ -205,3 +344,3 @@ listener(newValue, oldValue, e.url || e.uri);

var _class$1 = function () {
var _class = function () {
/**

@@ -233,7 +372,7 @@ * @param {Object} storage

if (window.addEventListener) {
window.addEventListener(this.options.events[i], _class$2.emit, false);
window.addEventListener(this.options.events[i], _class$1.emit, false);
} else if (window.attachEvent) {
window.attachEvent('on' + this.options.events[i], _class$2.emit);
window.attachEvent('on' + this.options.events[i], _class$1.emit);
} else {
window['on' + this.options.events[i]] = _class$2.emit;
window['on' + this.options.events[i]] = _class$1.emit;
}

@@ -272,3 +411,8 @@ }

this.storage.setItem(this.options.namespace + name, JSON.stringify({ value: value, expire: expire !== null ? new Date().getTime() + expire : null }));
var stringifyValue = JSON.stringify({
value: value,
expire: expire !== null ? new Date().getTime() + expire : null
});
this.storage.setItem(this.options.namespace + name, stringifyValue);
}

@@ -377,3 +521,3 @@

value: function on(name, callback) {
_class$2.on(this.options.namespace + name, callback);
_class$1.on(this.options.namespace + name, callback);
}

@@ -391,3 +535,3 @@

value: function off(name, callback) {
_class$2.off(this.options.namespace + name, callback);
_class$1.off(this.options.namespace + name, callback);
}

@@ -399,3 +543,3 @@ }]);

var store = typeof window !== 'undefined' && 'localStorage' in window ? window.localStorage : memoryStorage;
var ls = new _class$1(store);
var ls = new _class(store);

@@ -402,0 +546,0 @@ var VueLocalStorage = {

2

dist/vue-ls.min.js

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

!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):e["vue-ls"]=t()}(this,function(){"use strict";var e={},t={getItem:function(t){return t in e?e[t]:null},setItem:function(t,n){return e[t]=n,!0},removeItem:function(t){return!!(t in e)&&delete e[t]},clear:function(){return e={},!0},key:function(t){var n=Object.keys(e);return void 0!==n[t]?n[t]:null}};Object.defineProperty(t,"length",{get:function(){return Object.keys(e).length}});var n=function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")},o=function(){function e(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)}}return function(t,n,o){return n&&e(t.prototype,n),o&&e(t,o),t}}(),i=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var o in n)Object.prototype.hasOwnProperty.call(n,o)&&(e[o]=n[o])}return e},r={},a=function(){function e(){n(this,e)}return o(e,null,[{key:"on",value:function(e,t){void 0===r[e]&&(r[e]=[]),r[e].push(t)}},{key:"off",value:function(e,t){r[e].length?r[e].splice(r[e].indexOf(t),1):r[e]=[]}},{key:"emit",value:function(e){var t=e||window.event,n=function(e){var n=void 0,o=void 0;try{n=JSON.parse(t.newValue).value}catch(e){n=t.newValue}try{o=JSON.parse(t.oldValue).value}catch(e){o=t.oldValue}e(n,o,t.url||t.uri)};if(void 0!==t&&void 0!==t.key){var o=r[t.key];void 0!==o&&o.forEach(n)}}}]),e}(),u=new(function(){function e(t){if(n(this,e),this.storage=t,this.options={namespace:"",events:["storage"]},Object.defineProperty(this,"length",{get:function(){return this.storage.length}}),"undefined"!=typeof window)for(var o in this.options.events)window.addEventListener?window.addEventListener(this.options.events[o],a.emit,!1):window.attachEvent?window.attachEvent("on"+this.options.events[o],a.emit):window["on"+this.options.events[o]]=a.emit}return o(e,[{key:"setOptions",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};this.options=i(this.options,e)}},{key:"set",value:function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null;this.storage.setItem(this.options.namespace+e,JSON.stringify({value:t,expire:null!==n?(new Date).getTime()+n:null}))}},{key:"get",value:function(e){var t=arguments.length>1&&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("^"+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){a.on(this.options.namespace+e,t)}},{key:"off",value:function(e,t){a.off(this.options.namespace+e,t)}}]),e}())("undefined"!=typeof window&&"localStorage"in window?window.localStorage:t),s={install:function(e,t){u.setOptions(i(u.options,{namespace:""},t||{})),e.ls=u,Object.defineProperty(e.prototype,"$ls",{get:function(){return u}})}};return"undefined"!=typeof window&&(window.VueLocalStorage=s),s});
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):e["vue-ls"]=t()}(this,function(){"use strict";var e={},t={getItem:function(t){return t in e?e[t]:null},setItem:function(t,n){return e[t]=n,!0},removeItem:function(t){return!!(t in e)&&delete e[t]},clear:function(){return e={},!0},key:function(t){var n=Object.keys(e);return void 0!==n[t]?n[t]:null}};Object.defineProperty(t,"length",{get:function(){return Object.keys(e).length}});!function(){function e(e){this.value=e}function t(t){function n(e,t){return new Promise(function(n,i){var a={key:e,arg:t,resolve:n,reject:i,next:null};u?u=u.next=a:(r=u=a,o(e,t))})}function o(n,r){try{var u=t[n](r),a=u.value;a instanceof e?Promise.resolve(a.value).then(function(e){o("next",e)},function(e){o("throw",e)}):i(u.done?"return":"normal",u.value)}catch(e){i("throw",e)}}function i(e,t){switch(e){case"return":r.resolve({value:t,done:!0});break;case"throw":r.reject(t);break;default:r.resolve({value:t,done:!1})}(r=r.next)?o(r.key,r.arg):u=null}var r,u;this._invoke=n,"function"!=typeof t.return&&(this.return=void 0)}"function"==typeof Symbol&&Symbol.asyncIterator&&(t.prototype[Symbol.asyncIterator]=function(){return this}),t.prototype.next=function(e){return this._invoke("next",e)},t.prototype.throw=function(e){return this._invoke("throw",e)},t.prototype.return=function(e){return this._invoke("return",e)}}();var n=function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")},o=function(){function e(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)}}return function(t,n,o){return n&&e(t.prototype,n),o&&e(t,o),t}}(),i=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var o in n)Object.prototype.hasOwnProperty.call(n,o)&&(e[o]=n[o])}return e},r={},u=function(){function e(){n(this,e)}return o(e,null,[{key:"on",value:function(e,t){void 0===r[e]&&(r[e]=[]),r[e].push(t)}},{key:"off",value:function(e,t){r[e].length?r[e].splice(r[e].indexOf(t),1):r[e]=[]}},{key:"emit",value:function(e){var t=e||window.event,n=function(e){try{return JSON.parse(e).value}catch(t){return e}},o=function(e){e(n(t.newValue),n(t.oldValue),t.url||t.uri)};if(void 0!==t&&void 0!==t.key){var i=r[t.key];void 0!==i&&i.forEach(o)}}}]),e}(),a=new(function(){function e(t){if(n(this,e),this.storage=t,this.options={namespace:"",events:["storage"]},Object.defineProperty(this,"length",{get:function(){return this.storage.length}}),"undefined"!=typeof window)for(var o in this.options.events)window.addEventListener?window.addEventListener(this.options.events[o],u.emit,!1):window.attachEvent?window.attachEvent("on"+this.options.events[o],u.emit):window["on"+this.options.events[o]]=u.emit}return o(e,[{key:"setOptions",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};this.options=i(this.options,e)}},{key:"set",value:function(e,t){var n=arguments.length>2&&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=arguments.length>1&&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("^"+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){u.on(this.options.namespace+e,t)}},{key:"off",value:function(e,t){u.off(this.options.namespace+e,t)}}]),e}())("undefined"!=typeof window&&"localStorage"in window?window.localStorage:t),s={install:function(e,t){a.setOptions(i(a.options,{namespace:""},t||{})),e.ls=a,Object.defineProperty(e.prototype,"$ls",{get:function(){return a}})}};return"undefined"!=typeof window&&(window.VueLocalStorage=s),s});
//# sourceMappingURL=vue-ls.min.js.map
{
"name": "vue-ls",
"version": "2.3.0",
"version": "2.3.3",
"description": "Vue plugin for work with LocalStorage from Vue context",

@@ -62,3 +62,3 @@ "main": "dist/vue-ls.js",

"babel-core": "^6.24.0",
"babel-eslint": "^7.2.3",
"babel-eslint": "^8.0.0",
"babel-loader": "^7.0.0",

@@ -75,4 +75,4 @@ "babel-plugin-external-helpers": "^6.22.0",

"coveralls": "^2.11.16",
"eslint": "^4.2.0",
"eslint-config-airbnb-base": "^11.2.0",
"eslint": "^4.7.0",
"eslint-config-airbnb-base": "^12.0.0",
"eslint-plugin-import": "^2.7.0",

@@ -86,3 +86,3 @@ "eslint-plugin-node": "^5.1.1",

"gulp-rename": "^1.2.2",
"gulp-rollup": "^2.11.0",
"gulp-rollup": "^2.15.0",
"gulp-sourcemaps": "^2.4.1",

@@ -103,4 +103,4 @@ "gulp-uglify": "^3.0.0",

"remove": "^0.1.5",
"rollup": "^0.45.2",
"rollup-plugin-babel": "^2.7.1",
"rollup": "^0.50.0",
"rollup-plugin-babel": "^3.0.2",
"selenium-server": "^3.3.1",

@@ -107,0 +107,0 @@ "serve-static": "^1.12.1",

@@ -24,3 +24,5 @@ <p align="center">

<a href="https://www.npmjs.com/package/vue-ls"><img src="https://img.shields.io/npm/v/vue-ls.svg?style=flat-square"></a>
<a href="https://cdnjs.com/libraries/vue-ls"><img src="https://img.shields.io/cdnjs/v/vue-ls.svg"></a>
<a href="https://github.com/RobinCK/vue-ls/blob/master/LICENSE"><img src="https://img.shields.io/npm/l/vue-ls.svg?style=flat-square"></a>

@@ -27,0 +29,0 @@ </p>

const listeners = {};
/**
* Event class
*/
export default class {
/**
* Add storage change event
*
* @param {string} name
* @param {Function} callback
*/
static on(name, callback) {

@@ -12,2 +21,8 @@ if (typeof listeners[name] === 'undefined') {

/**
* Remove storage change event
*
* @param {string} name
* @param {Function} callback
*/
static off(name, callback) {

@@ -21,2 +36,7 @@ if (listeners[name].length) {

/**
* Emit event
*
* @param {Object} event
*/
static emit(event) {

@@ -23,0 +43,0 @@ const e = event || window.event;

@@ -6,4 +6,3 @@ import Memory from './memory';

? window.localStorage
: Memory
;
: Memory;
const ls = new Storage(store);

@@ -10,0 +9,0 @@

@@ -58,6 +58,8 @@ import StorageEvent from './event';

set(name, value, expire = null) {
this.storage.setItem(
this.options.namespace + name,
JSON.stringify({ value, expire: expire !== null ? new Date().getTime() + expire : null }),
);
const stringifyValue = JSON.stringify({
value,
expire: expire !== null ? new Date().getTime() + expire : null,
});
this.storage.setItem(this.options.namespace + name, stringifyValue);
}

@@ -64,0 +66,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