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.3 to 2.4.0

253

dist/vue-ls.js
(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
typeof define === 'function' && define.amd ? define(factory) :
(global['vue-ls'] = factory());
(global.VueLocalStorage = factory());
}(this, (function () { 'use strict';
var ls$1 = {};
var ls = {};

@@ -17,3 +17,3 @@ var memoryStorage = {

getItem: function getItem(name) {
return name in ls$1 ? ls$1[name] : null;
return name in ls ? ls[name] : null;
},

@@ -30,3 +30,3 @@

setItem: function setItem(name, value) {
ls$1[name] = value;
ls[name] = value;

@@ -44,6 +44,6 @@ return true;

removeItem: function removeItem(name) {
var found = name in ls$1;
var found = name in ls;
if (found) {
return delete ls$1[name];
return delete ls[name];
}

@@ -61,3 +61,3 @@

clear: function clear() {
ls$1 = {};
ls = {};

@@ -75,3 +75,3 @@ return true;

key: function key(index) {
var keys = Object.keys(ls$1);
var keys = Object.keys(ls);

@@ -89,167 +89,10 @@ return typeof keys[index] !== 'undefined' ? keys[index] : null;

get: function get() {
return Object.keys(ls$1).length;
return Object.keys(ls).length;
}
});
var asyncGenerator = function () {
function AwaitValue(value) {
this.value = value;
}
var _createClass$1 = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
function AsyncGenerator(gen) {
var front, back;
function _classCallCheck$1(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
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) {
if (!(instance instanceof Constructor)) {
throw new TypeError("Cannot call a class as a function");
}
};
var createClass = function () {
function defineProperties(target, props) {
for (var i = 0; i < props.length; i++) {
var descriptor = props[i];
descriptor.enumerable = descriptor.enumerable || false;
descriptor.configurable = true;
if ("value" in descriptor) descriptor.writable = true;
Object.defineProperty(target, descriptor.key, descriptor);
}
}
return function (Constructor, protoProps, staticProps) {
if (protoProps) defineProperties(Constructor.prototype, protoProps);
if (staticProps) defineProperties(Constructor, staticProps);
return Constructor;
};
}();
var _extends = 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;
};
var listeners = {};

@@ -263,6 +106,6 @@

function _class() {
classCallCheck(this, _class);
_classCallCheck$1(this, _class);
}
createClass(_class, null, [{
_createClass$1(_class, null, [{
key: 'on',

@@ -338,5 +181,12 @@

}]);
return _class;
}();
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; };
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
/**

@@ -351,3 +201,3 @@ * Storage Bridge

function _class(storage) {
classCallCheck(this, _class);
_classCallCheck(this, _class);

@@ -366,3 +216,3 @@ this.storage = storage;

*/
get: function get$$1() {
get: function get() {
return this.storage.length;

@@ -392,3 +242,3 @@ }

createClass(_class, [{
_createClass(_class, [{
key: 'setOptions',

@@ -398,3 +248,3 @@ value: function setOptions() {

this.options = _extends(this.options, options);
this.options = _extends$1(this.options, options);
}

@@ -412,3 +262,3 @@

key: 'set',
value: function set$$1(name, value) {
value: function set(name, value) {
var expire = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;

@@ -434,3 +284,3 @@

key: 'get',
value: function get$$1(name) {
value: function get(name) {
var def = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;

@@ -542,8 +392,11 @@

}]);
return _class;
}();
var store = typeof window !== 'undefined' && 'localStorage' in window ? window.localStorage : memoryStorage;
var ls = new _class(store);
var _extends = 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; };
/**
* @type {{install: (function(Object, Object): Storage)}}
*/
var VueLocalStorage = {

@@ -557,9 +410,43 @@ /**

*/
install: function install(Vue, options) {
install: function install(Vue) {
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
var _options = _extends({}, options, {
storage: !!options.storage ? options.storage : 'local',
name: options.name || 'ls'
});
if (_options.storage && ['memory', 'local', 'session'].indexOf(_options.storage) === -1) {
throw new Error('Vue-ls: Storage "' + _options.storage + '" is not supported');
}
var store = null;
switch (_options.storage) {// eslint-disable-line
case 'local':
store = typeof window !== 'undefined' && 'localStorage' in window ? window.localStorage : null;
break;
case 'session':
store = typeof window !== 'undefined' && 'sessionStorage' in window ? window.sessionStorage : null;
break;
case 'memory':
store = memoryStorage;
break;
}
if (!store) {
store = memoryStorage;
// eslint-disable-next-line
console.error('Vue-ls: Storage "' + _options.storage + '" is not supported your system, use memory storage');
}
var ls = new _class(store);
ls.setOptions(_extends(ls.options, {
namespace: ''
}, options || {}));
}, _options || {}));
Vue.ls = ls; // eslint-disable-line
Object.defineProperty(Vue.prototype, '$ls', {
Vue[_options.name] = ls; // eslint-disable-line
Object.defineProperty(Vue.prototype, '$' + _options.name, {
/**

@@ -570,3 +457,3 @@ * Define $ls property

*/
get: function get$$1() {
get: function get() {
return ls;

@@ -573,0 +460,0 @@ }

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

!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
!function(e,n){"object"==typeof exports&&"undefined"!=typeof module?module.exports=n():"function"==typeof define&&define.amd?define(n):e.VueLocalStorage=n()}(this,function(){"use strict";var e={},n={getItem:function(n){return n in e?e[n]:null},setItem:function(n,t){return e[n]=t,!0},removeItem:function(n){return!!(n in e)&&delete e[n]},clear:function(){return e={},!0},key:function(n){var t=Object.keys(e);return void 0!==t[n]?t[n]:null}};Object.defineProperty(n,"length",{get:function(){return Object.keys(e).length}});var t=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 o={},r=function(){function e(){!function(e,n){if(!(e instanceof n))throw new TypeError("Cannot call a class as a function")}(this,e)}return t(e,null,[{key:"on",value:function(e,n){void 0===o[e]&&(o[e]=[]),o[e].push(n)}},{key:"off",value:function(e,n){o[e].length?o[e].splice(o[e].indexOf(n),1):o[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 r=o[n.key];void 0!==r&&r.forEach(function(e){e(t(n.newValue),t(n.oldValue),n.url||n.uri)})}}}]),e}(),i=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=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=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],r.emit,!1):window.attachEvent?window.attachEvent("on"+this.options.events[t],r.emit):window["on"+this.options.events[t]]=r.emit}return a(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,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){r.on(this.options.namespace+e,n)}},{key:"off",value:function(e,n){r.off(this.options.namespace+e,n)}}]),e}(),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},l={install:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},o=u({},t,{storage:t.storage?t.storage:"local",name:t.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="undefined"!=typeof window&&"localStorage"in window?window.localStorage:null;break;case"session":r="undefined"!=typeof window&&"sessionStorage"in window?window.sessionStorage:null;break;case"memory":r=n}r||(r=n,console.error('Vue-ls: Storage "'+o.storage+'" is not supported your system, use memory storage'));var i=new s(r);i.setOptions(u(i.options,{namespace:""},o||{})),e[o.name]=i,Object.defineProperty(e.prototype,"$"+o.name,{get:function(){return i}})}};return"undefined"!=typeof window&&(window.VueLocalStorage=l),l});
{
"name": "vue-ls",
"version": "2.3.3",
"version": "2.4.0",
"description": "Vue plugin for work with LocalStorage from Vue context",

@@ -13,4 +13,4 @@ "main": "dist/vue-ls.js",

"scripts": {
"build": "node_modules/.bin/gulp js",
"test": "node_modules/.bin/nyc node_modules/.bin/ava --tap --esnext",
"build": "node_modules/.bin/rollup -c ./build/rollup.config.js && NODE_ENV=production node_modules/.bin/rollup -c ./build/rollup.config.js",
"test": "NODE_ENV=test node_modules/.bin/nyc node_modules/.bin/ava",
"test:browserstack": "RUN_ON_BSTACK=true BSTACK_LOCAL=true node_modules/.bin/gulp test --env bstack_chrome_50,bstack_chrome_57,bstack_ie_9,bstack_ie_11,bstack_edge_13,bstack_edge_14,bstack_firefox_40,bstack_firefox_52,bstack_safari_8,bstack_safari_10",

@@ -35,3 +35,2 @@ "test:browserstack:chrome": "RUN_ON_BSTACK=true BSTACK_LOCAL=true node_modules/.bin/gulp test --env bstack_chrome_50,bstack_chrome_57",

},
"dependencies": {},
"keywords": [

@@ -62,12 +61,11 @@ "localstorage",

"devDependencies": {
"ava": "jamestalmage/ava#karma-ava",
"babel-core": "^6.24.0",
"ava": "^0.25.0",
"babel-core": "^6.26.0",
"babel-eslint": "^8.0.0",
"babel-loader": "^7.0.0",
"babel-plugin-external-helpers": "^6.22.0",
"babel-plugin-transform-es2015-modules-commonjs": "^6.23.0",
"babel-plugin-transform-es2015-modules-commonjs": "^6.26.0",
"babel-plugin-transform-object-assign": "^6.22.0",
"babel-polyfill": "^6.23.0",
"babel-preset-es2015": "^6.22.0",
"babel-register": "^6.23.0",
"babel-polyfill": "^6.26.0",
"babel-preset-env": "^1.6.1",
"babel-register": "^6.26.0",
"browserstack-automate": "https://github.com/browserstack/browserstack-integration-nodejs.git#master",

@@ -86,6 +84,2 @@ "chromedriver": "^2.28.0",

"gulp-nightwatch": "^0.3.2",
"gulp-rename": "^1.2.2",
"gulp-rollup": "^2.15.0",
"gulp-sourcemaps": "^2.4.1",
"gulp-uglify": "^3.0.0",
"gulp-util": "^3.0.8",

@@ -106,2 +100,3 @@ "jasmine": "^2.5.3",

"rollup-plugin-babel": "^3.0.2",
"rollup-plugin-uglify": "^3.0.0",
"selenium-server": "^3.3.1",

@@ -123,4 +118,8 @@ "serve-static": "^1.12.1",

"babel": {
"babelrc": true
"babelrc": true,
"plugins": [
"transform-es2015-modules-commonjs"
]
},
"tap": true,
"files": [

@@ -127,0 +126,0 @@ "./test/unit/ava/*.js"

import Memory from './memory';
import Storage from './storage';
const store = typeof window !== 'undefined' && 'localStorage' in window
? window.localStorage
: Memory;
const ls = new Storage(store);
/**
* @type {{install: (function(Object, Object): Storage)}}
*/
const VueLocalStorage = {

@@ -17,9 +15,46 @@ /**

*/
install(Vue, options) {
install(Vue, options = {}) {
const _options = Object.assign({}, options, {
storage: options.storage || 'local',
name: options.name || 'ls',
});
if (_options.storage && ['memory', 'local', 'session'].indexOf(_options.storage) === -1) {
throw new Error(`Vue-ls: Storage "${_options.storage}" is not supported`);
}
let store = null;
switch(_options.storage) { // eslint-disable-line
case 'local':
store = typeof window !== 'undefined' && 'localStorage' in window
? window.localStorage
: null
;
break;
case 'session':
store = typeof window !== 'undefined' && 'sessionStorage' in window
? window.sessionStorage
: null
;
break;
case 'memory': store = Memory;
break;
}
if (!store) {
store = Memory;
// eslint-disable-next-line
console.error(`Vue-ls: Storage "${_options.storage}" is not supported your system, use memory storage`);
}
const ls = new Storage(store);
ls.setOptions(Object.assign(ls.options, {
namespace: '',
}, options || {}));
}, _options || {}));
Vue.ls = ls; // eslint-disable-line
Object.defineProperty(Vue.prototype, '$ls', {
Vue[_options.name] = ls; // eslint-disable-line
Object.defineProperty(Vue.prototype, `$${_options.name}`, {
/**

@@ -26,0 +61,0 @@ * Define $ls property

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