vue-web-storage
Advanced tools
Comparing version
# Changelog | ||
## [3.0.0](https://github.com/ankurk91/vue-web-storage/compare/2.1.0...3.0.0) (breaking) | ||
## [4.0.0](https://github.com/ankurk91/vue-web-storage/compare/3.0.0...4.0.0) | ||
* Add: ES6 named imports, allows you to consume package in a non Vue.js project | ||
- `import { StorageWithEvents } from 'vue-web-storage'` | ||
## [3.0.0](https://github.com/ankurk91/vue-web-storage/compare/2.1.0...3.0.0) | ||
* Add: allow multiple drivers, [#4](https://github.com/ankurk91/vue-web-storage/issues/4) | ||
@@ -5,0 +9,0 @@ - Read the [upgrade](UPGRADING.md) guide to restore old behaviour |
@@ -108,3 +108,5 @@ (function webpackUniversalModuleDefinition(root, factory) { | ||
return JSON.parse(value); | ||
} catch (e) /*istanbul ignore next*/{ | ||
} catch (e) | ||
/*istanbul ignore next*/ | ||
{ | ||
console.error(e); | ||
@@ -121,9 +123,13 @@ return value; | ||
// CONCATENATED MODULE: ./src/storage.js | ||
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"); } } | ||
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); } } | ||
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } | ||
var storage_Storage = function () { | ||
var storage_Storage = | ||
/*#__PURE__*/ | ||
function () { | ||
function Storage() { | ||
@@ -136,7 +142,7 @@ var prefix = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'app_'; | ||
this.prefix = prefix; | ||
this.storage = window[String(driver) + 'Storage']; | ||
this.storage = window["".concat(String(driver), "Storage")]; | ||
} | ||
_createClass(Storage, [{ | ||
key: 'prefixKey', | ||
key: "prefixKey", | ||
value: function prefixKey(key) { | ||
@@ -146,3 +152,3 @@ return this.prefix + String(key); | ||
}, { | ||
key: 'set', | ||
key: "set", | ||
value: function set(key, value) { | ||
@@ -152,3 +158,5 @@ try { | ||
return true; | ||
} catch (e) /*istanbul ignore next*/{ | ||
} catch (e) | ||
/*istanbul ignore next*/ | ||
{ | ||
console.error(e); | ||
@@ -159,14 +167,15 @@ return false; | ||
}, { | ||
key: 'get', | ||
key: "get", | ||
value: function get(key) { | ||
var defaultValue = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null; | ||
var storedValue = this.storage.getItem(this.prefixKey(key)); | ||
var storedValue = this.storage.getItem(this.prefixKey(key)); | ||
if (storedValue !== null) { | ||
return parseJSON(storedValue); | ||
} | ||
return defaultValue; | ||
} | ||
}, { | ||
key: 'remove', | ||
key: "remove", | ||
value: function remove(key) { | ||
@@ -176,3 +185,3 @@ return this.storage.removeItem(this.prefixKey(key)); | ||
}, { | ||
key: 'clear', | ||
key: "clear", | ||
value: function clear() { | ||
@@ -192,3 +201,3 @@ var _this = this; | ||
}, { | ||
key: 'keys', | ||
key: "keys", | ||
value: function keys() { | ||
@@ -198,6 +207,4 @@ var _this2 = this; | ||
var withPrefix = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false; | ||
var keys = []; // Loop through all storage keys | ||
var keys = []; | ||
// Loop through all storage keys | ||
Object.keys(this.storage).forEach(function (keyName, index) { | ||
@@ -209,7 +216,6 @@ /* istanbul ignore else */ | ||
}); | ||
return keys; | ||
} | ||
}, { | ||
key: 'hasKey', | ||
key: "hasKey", | ||
value: function hasKey(key) { | ||
@@ -219,3 +225,3 @@ return this.keys().indexOf(key) !== -1; | ||
}, { | ||
key: 'length', | ||
key: "length", | ||
value: function length() { | ||
@@ -231,11 +237,14 @@ return this.keys().length; | ||
// CONCATENATED MODULE: ./src/events.js | ||
var events_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 events_classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } | ||
function events_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); } } | ||
function events_createClass(Constructor, protoProps, staticProps) { if (protoProps) events_defineProperties(Constructor.prototype, protoProps); if (staticProps) events_defineProperties(Constructor, staticProps); return Constructor; } | ||
var _listeners = {}; | ||
var events_Events = function () { | ||
var events_Events = | ||
/*#__PURE__*/ | ||
function () { | ||
function Events() { | ||
@@ -255,6 +264,6 @@ events_classCallCheck(this, Events); | ||
/*istanbul ignore else*/ | ||
if (methods) { | ||
var newValue = parseJSON(event.newValue); | ||
var oldValue = parseJSON(event.oldValue); | ||
methods.map(function (method) { | ||
@@ -278,2 +287,3 @@ method.call(_this, newValue, oldValue, event.url); | ||
var methods = _listeners[key]; | ||
if (methods && methods.length > 1) { | ||
@@ -306,17 +316,31 @@ methods.splice(methods.indexOf(fn), 1); | ||
// CONCATENATED MODULE: ./src/storageWithEvents.js | ||
var storageWithEvents_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 _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } | ||
function storageWithEvents_classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } | ||
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } | ||
function storageWithEvents_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); } } | ||
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } | ||
function storageWithEvents_createClass(Constructor, protoProps, staticProps) { if (protoProps) storageWithEvents_defineProperties(Constructor.prototype, protoProps); if (staticProps) storageWithEvents_defineProperties(Constructor, staticProps); return Constructor; } | ||
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } | ||
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } | ||
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } | ||
var storageWithEvents_StorageWithEvents = function (_Storage) { | ||
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } | ||
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } | ||
var storageWithEvents_StorageWithEvents = | ||
/*#__PURE__*/ | ||
function (_Storage) { | ||
_inherits(StorageWithEvents, _Storage); | ||
function StorageWithEvents() { | ||
var _this; | ||
var prefix = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'app_'; | ||
@@ -327,4 +351,3 @@ var driver = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'local'; | ||
var _this = _possibleConstructorReturn(this, (StorageWithEvents.__proto__ || Object.getPrototypeOf(StorageWithEvents)).call(this, prefix, driver)); | ||
_this = _possibleConstructorReturn(this, _getPrototypeOf(StorageWithEvents).call(this, prefix, driver)); | ||
_this.events = new events(); | ||
@@ -335,3 +358,3 @@ return _this; | ||
storageWithEvents_createClass(StorageWithEvents, [{ | ||
key: 'on', | ||
key: "on", | ||
value: function on(key, fn) { | ||
@@ -342,3 +365,3 @@ this.events.on(this.prefixKey(key), fn); | ||
}, { | ||
key: 'off', | ||
key: "off", | ||
value: function off(key, fn) { | ||
@@ -349,3 +372,3 @@ this.events.off(this.prefixKey(key), fn); | ||
}, { | ||
key: 'clearEvents', | ||
key: "clearEvents", | ||
value: function clearEvents(key) { | ||
@@ -364,5 +387,5 @@ var mayBeKey = key ? this.prefixKey(key) : false; | ||
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Plugin", function() { return src_Plugin; }); | ||
/* concated harmony reexport */__webpack_require__.d(__webpack_exports__, "Storage", function() { return storage; }); | ||
/* concated harmony reexport */__webpack_require__.d(__webpack_exports__, "StorageWithEvents", function() { return storageWithEvents; }); | ||
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; }; | ||
/* concated harmony reexport Storage */__webpack_require__.d(__webpack_exports__, "Storage", function() { return storage; }); | ||
/* concated harmony reexport StorageWithEvents */__webpack_require__.d(__webpack_exports__, "StorageWithEvents", function() { return storageWithEvents; }); | ||
function _extends() { _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; }; return _extends.apply(this, arguments); } | ||
@@ -376,3 +399,2 @@ | ||
var apiName = '$' + String(driver) + 'Storage'; | ||
Vue[apiName] = instance; | ||
@@ -385,3 +407,2 @@ Vue.prototype[apiName] = instance; | ||
var safeOptions = _extends({}, { | ||
@@ -401,3 +422,3 @@ prefix: 'app_', | ||
/***/ }) | ||
/******/ ])["default"]; | ||
/******/ ]); | ||
}); |
@@ -1,1 +0,1 @@ | ||
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define("VueWebStorage",[],t):"object"==typeof exports?exports.VueWebStorage=t():e.VueWebStorage=t()}("undefined"!=typeof self?self:this,function(){return function(e){var t={};function n(r){if(t[r])return t[r].exports;var o=t[r]={i:r,l:!1,exports:{}};return e[r].call(o.exports,o,o.exports,n),o.l=!0,o.exports}return n.m=e,n.c=t,n.d=function(e,t,r){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)n.d(r,o,function(t){return e[t]}.bind(null,o));return r},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=0)}([function(e,t,n){"use strict";n.r(t);var r=function(e){try{return JSON.parse(e)}catch(t){return e}},o=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}(),i=function(){function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"app_",n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"local";!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.prefix=t,this.storage=window[String(n)+"Storage"]}return o(e,[{key:"prefixKey",value:function(e){return this.prefix+String(e)}},{key:"set",value:function(e,t){try{return this.storage.setItem(this.prefixKey(e),JSON.stringify(t)),!0}catch(e){return!1}}},{key:"get",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,n=this.storage.getItem(this.prefixKey(e));return null!==n?r(n):t}},{key:"remove",value:function(e){return this.storage.removeItem(this.prefixKey(e))}},{key:"clear",value:function(){var e=this;arguments.length>0&&void 0!==arguments[0]&&arguments[0]?this.storage.clear():this.keys(!0).map(function(t){e.storage.removeItem(t)})}},{key:"keys",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]&&arguments[0],n=[];return Object.keys(this.storage).forEach(function(r,o){r.substr(0,e.prefix.length)===e.prefix&&n.push(t?r:r.substring(e.prefix.length))}),n}},{key:"hasKey",value:function(e){return-1!==this.keys().indexOf(e)}},{key:"length",value:function(){return this.keys().length}}]),e}(),u=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}(),a={},f=function(){function e(){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),window.addEventListener("storage",this._onChange,!1)}return u(e,[{key:"_onChange",value:function(e){var t=this,n=a[e.key];if(n){var o=r(e.newValue),i=r(e.oldValue);n.map(function(n){n.call(t,o,i,e.url)})}}},{key:"on",value:function(e,t){a[e]?a[e].push(t):a[e]=[t]}},{key:"off",value:function(e,t){var n=a[e];n&&n.length>1?n.splice(n.indexOf(t),1):delete a[e]}},{key:"clear",value:function(e){e?delete a[e]:a={}}},{key:"listeners",value:function(){return a}}]),e}(),c=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}(),l=function(e){function t(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"app_",n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"local";!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t);var r=function(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e,n));return r.events=new f,r}return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}(t,i),c(t,[{key:"on",value:function(e,t){return this.events.on(this.prefixKey(e),t),this}},{key:"off",value:function(e,t){return this.events.off(this.prefixKey(e),t),this}},{key:"clearEvents",value:function(e){var t=!!e&&this.prefixKey(e);return this.events.clear(t),this}}]),t}();n.d(t,"Plugin",function(){return p}),n.d(t,"Storage",function(){return i}),n.d(t,"StorageWithEvents",function(){return l});var s=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},p=function(e){var t,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=s({},{prefix:"app_",drivers:"local"},n);(t=r.drivers,t instanceof Array?t:[t]).map(function(t){!function(e,t,n){var r=new l(n,t),o="$"+String(t)+"Storage";e[o]=r,e.prototype[o]=r}(e,t,r.prefix)})};t.default=p}]).default}); | ||
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define("VueWebStorage",[],t):"object"==typeof exports?exports.VueWebStorage=t():e.VueWebStorage=t()}("undefined"!=typeof self?self:this,function(){return function(e){var t={};function n(r){if(t[r])return t[r].exports;var o=t[r]={i:r,l:!1,exports:{}};return e[r].call(o.exports,o,o.exports,n),o.l=!0,o.exports}return n.m=e,n.c=t,n.d=function(e,t,r){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)n.d(r,o,function(t){return e[t]}.bind(null,o));return r},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=0)}([function(e,t,n){"use strict";n.r(t);var r=function(e){try{return JSON.parse(e)}catch(t){return e}};function o(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}var i=function(){function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"app_",n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"local";!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.prefix=t,this.storage=window["".concat(String(n),"Storage")]}var t,n,i;return t=e,(n=[{key:"prefixKey",value:function(e){return this.prefix+String(e)}},{key:"set",value:function(e,t){try{return this.storage.setItem(this.prefixKey(e),JSON.stringify(t)),!0}catch(e){return!1}}},{key:"get",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,n=this.storage.getItem(this.prefixKey(e));return null!==n?r(n):t}},{key:"remove",value:function(e){return this.storage.removeItem(this.prefixKey(e))}},{key:"clear",value:function(){var e=this;arguments.length>0&&void 0!==arguments[0]&&arguments[0]?this.storage.clear():this.keys(!0).map(function(t){e.storage.removeItem(t)})}},{key:"keys",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]&&arguments[0],n=[];return Object.keys(this.storage).forEach(function(r,o){r.substr(0,e.prefix.length)===e.prefix&&n.push(t?r:r.substring(e.prefix.length))}),n}},{key:"hasKey",value:function(e){return-1!==this.keys().indexOf(e)}},{key:"length",value:function(){return this.keys().length}}])&&o(t.prototype,n),i&&o(t,i),e}();function u(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}var a={},f=function(){function e(){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),window.addEventListener("storage",this._onChange,!1)}var t,n,o;return t=e,(n=[{key:"_onChange",value:function(e){var t=this,n=a[e.key];if(n){var o=r(e.newValue),i=r(e.oldValue);n.map(function(n){n.call(t,o,i,e.url)})}}},{key:"on",value:function(e,t){a[e]?a[e].push(t):a[e]=[t]}},{key:"off",value:function(e,t){var n=a[e];n&&n.length>1?n.splice(n.indexOf(t),1):delete a[e]}},{key:"clear",value:function(e){e?delete a[e]:a={}}},{key:"listeners",value:function(){return a}}])&&u(t.prototype,n),o&&u(t,o),e}();function c(e){return(c="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})(e)}function l(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function s(e,t){return!t||"object"!==c(t)&&"function"!=typeof t?function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e):t}function p(e){return(p=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function y(e,t){return(y=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}var v=function(e){function t(){var e,n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"app_",r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"local";return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t),(e=s(this,p(t).call(this,n,r))).events=new f,e}var n,r,o;return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&y(e,t)}(t,i),n=t,(r=[{key:"on",value:function(e,t){return this.events.on(this.prefixKey(e),t),this}},{key:"off",value:function(e,t){return this.events.off(this.prefixKey(e),t),this}},{key:"clearEvents",value:function(e){var t=!!e&&this.prefixKey(e);return this.events.clear(t),this}}])&&l(n.prototype,r),o&&l(n,o),t}();function h(){return(h=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e}).apply(this,arguments)}n.d(t,"Plugin",function(){return b}),n.d(t,"Storage",function(){return i}),n.d(t,"StorageWithEvents",function(){return v});var b=function(e){var t,n=h({},{prefix:"app_",drivers:"local"},arguments.length>1&&void 0!==arguments[1]?arguments[1]:{});(t=n.drivers,t instanceof Array?t:[t]).map(function(t){!function(e,t,n){var r=new v(n,t),o="$"+String(t)+"Storage";e[o]=r,e.prototype[o]=r}(e,t,n.prefix)})};t.default=b}])}); |
{ | ||
"name": "vue-web-storage", | ||
"version": "3.0.0", | ||
"version": "4.0.0", | ||
"description": "Vue.js plugin for localStorage and sessionStorage", | ||
@@ -29,20 +29,19 @@ "main": "dist/vue-web-storage.js", | ||
"test": "jest", | ||
"test:watch": "npm run test -- --watch --onlyChanged --notify", | ||
"test:watch": "yarn run test --watch --notify", | ||
"build": "cross-env NODE_ENV=production webpack --progress --mode production", | ||
"prepublishOnly": "npm run test && npm run build" | ||
"prepublishOnly": "yarn run test && yarn run build" | ||
}, | ||
"devDependencies": { | ||
"babel-core": "^6.25.0", | ||
"babel-jest": "^23.4.2", | ||
"babel-loader": "^7.1.5", | ||
"babel-plugin-transform-object-assign": "^6.22.0", | ||
"babel-preset-env": "^1.6.0", | ||
"clean-webpack-plugin": "^0.1.18", | ||
"@babel/core": "^7.2.2", | ||
"@babel/plugin-transform-object-assign": "^7.2.0", | ||
"@babel/preset-env": "^7.3.1", | ||
"babel-jest": "^24.1.0", | ||
"babel-loader": "^8.0.5", | ||
"clean-webpack-plugin": "^1.0.1", | ||
"cross-env": "^5.2.0", | ||
"jest": "^23.4.2", | ||
"jest-localstorage-mock": "^2.2.0", | ||
"jest": "^24.1.0", | ||
"unminified-webpack-plugin": "^2.0.0", | ||
"vue": "^2.5.13", | ||
"webpack": "^4.16.3", | ||
"webpack-command": "^0.4.1" | ||
"vue": "^2.6.6", | ||
"webpack": "^4.29.3", | ||
"webpack-cli": "^3.2.3" | ||
}, | ||
@@ -61,7 +60,6 @@ "peerDependencies": { | ||
"setupFiles": [ | ||
"jest-localstorage-mock", | ||
"<rootDir>/__test__/setup.js" | ||
], | ||
"transform": { | ||
"^.+\\.js$": "<rootDir>/node_modules/babel-jest" | ||
"^.+\\.js$": "babel-jest" | ||
}, | ||
@@ -74,3 +72,4 @@ "testURL": "http://localhost", | ||
"npm": ">=3.10.0" | ||
} | ||
}, | ||
"dependencies": {} | ||
} |
# Vue Web Storage | ||
[](https://vuejs.org/) | ||
[](http://npm-stats.com/~packages/vue-web-storage) | ||
@@ -121,8 +120,8 @@ [](https://www.npmjs.com/package/vue-web-storage) | ||
<!-- Vue js --> | ||
<script src="https://cdn.jsdelivr.net/npm/vue@2.5"></script> | ||
<script src="https://cdn.jsdelivr.net/npm/vue@2.6"></script> | ||
<!-- Lastly add this package --> | ||
<script src="https://cdn.jsdelivr.net/npm/vue-web-storage@3"></script> | ||
<script src="https://cdn.jsdelivr.net/npm/vue-web-storage@4"></script> | ||
<!-- Init the plugin --> | ||
<script> | ||
Vue.use(VueWebStorage) | ||
Vue.use(VueWebStorage.default) | ||
</script> | ||
@@ -138,3 +137,3 @@ ``` | ||
* [Web Storage API](https://developer.mozilla.org/en-US/docs/Web/API/Web_Storage_API) | ||
* [Browser support status](https://caniuse.com/#feat=namevalue-storage), [Chrome](https://www.chromestatus.com/feature/5345825534246912), [Edge](https://developer.microsoft.com/en-us/microsoft-edge/platform/status/webstorage/) | ||
* [Browser support status](https://caniuse.com/#feat=namevalue-storage) | ||
* [Web Storage Quota](https://www.html5rocks.com/en/tutorials/offline/quota-research/) | ||
@@ -141,0 +140,0 @@ * [Storage Event Example](https://html5demos.com/storage-events/) |
@@ -1,2 +0,2 @@ | ||
import {parseJSON} from "./util"; | ||
import {parseJSON} from './util'; | ||
@@ -3,0 +3,0 @@ let listeners = {}; |
33319
3.04%12
-7.69%499
3.74%145
-0.68%