vue2-storage
Advanced tools
Comparing version 3.3.0 to 3.4.0
@@ -8,2 +8,6 @@ /*! | ||
function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; } | ||
var objectAssign = _interopDefault(require('object-assign')); | ||
/* */ | ||
@@ -89,3 +93,3 @@ | ||
var options = Object.assign({ | ||
var options = objectAssign({ | ||
prefix: 'app_', | ||
@@ -92,0 +96,0 @@ driver: 'local', |
@@ -7,7 +7,9 @@ /*! | ||
(function (global, factory) { | ||
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() : | ||
typeof define === 'function' && define.amd ? define(factory) : | ||
(global.Vue2Storage = factory()); | ||
}(this, (function () { 'use strict'; | ||
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory(require('object-assign')) : | ||
typeof define === 'function' && define.amd ? define(['object-assign'], factory) : | ||
(global.Vue2Storage = factory(global.objectAssign)); | ||
}(this, (function (objectAssign) { 'use strict'; | ||
objectAssign = 'default' in objectAssign ? objectAssign['default'] : objectAssign; | ||
/* */ | ||
@@ -93,3 +95,3 @@ | ||
var options = Object.assign({ | ||
var options = objectAssign({ | ||
prefix: 'app_', | ||
@@ -96,0 +98,0 @@ driver: 'local', |
@@ -6,2 +6,2 @@ /*! | ||
*/ | ||
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):t.Vue2Storage=e()}(this,function(){"use strict";function t(t,e){var r=new n(e);t.$storage=r,t.prototype.$storage=r}var e={},r=function(){},o={length:{},storage:{}};o.length.get=function(){return Object.keys(this.storage).length},o.storage.get=function(){return e},r.prototype.getItem=function(t){return t in this.storage?this.storage[t]:null},r.prototype.setItem=function(t,e){this.storage[t]=e},r.prototype.removeItem=function(t){t in this.storage&&delete this.storage[t]},r.prototype.clear=function(){var t=this;for(var e in this.storage)delete t.storage[e]},Object.defineProperties(r.prototype,o);var i=new r,n=function(t){void 0===t&&(t={}),this.setOptions(t)},s={name:{},version:{},length:{},driver:{}};return s.name.get=function(){return"vue2-storage[v3.3.0]"},s.version.get=function(){return"3.3.0"},s.length.get=function(){return this.keys().length},s.driver.get=function(){switch(this.options.driver){case"local":default:return"undefined"!=typeof window?window.localStorage:i;case"session":return"undefined"!=typeof window?window.sessionStorage:i;case"memory":return i}},n.prototype.setOptions=function(t){void 0===t&&(t={});var e=Object.assign({prefix:"app_",driver:"local",ttl:864e5},t);this.options=Object.freeze(e)},n.prototype.printError=function(t){console.error(this.name+": "+t.stack)},n.prototype.addPrefix=function(t){return""+(this.options.prefix||"")+t},n.prototype.removePrefix=function(t){var e=new RegExp("^"+(this.options.prefix||""));return t.replace(e,"")},n.prototype.toJSON=function(t,e){void 0===e&&(e={});var r="ttl"in e?e.ttl:this.options.ttl;return JSON.stringify({value:t,ttl:Date.now()+r})},n.prototype.fromJSON=function(t){try{var e=JSON.parse(this.driver.getItem(t));return null!==e?"ttl"in e&&Number(e.ttl)<Date.now()?(this.remove(this.removePrefix(t)),null):"value"in e?e.value:e:null}catch(t){return null}},n.prototype.get=function(t,e){void 0===e&&(e=null);try{var r=this.fromJSON(this.addPrefix(t));return null===r?e:r}catch(t){this.printError(t)}},n.prototype.set=function(t,e,r){void 0===r&&(r={});try{this.driver.setItem(this.addPrefix(t),this.toJSON(e,r))}catch(t){this.printError(t)}},n.prototype.remove=function(t){try{this.driver.removeItem(this.addPrefix(t))}catch(t){this.printError(t)}},n.prototype.clear=function(t){var e=this;void 0===t&&(t=!1);try{if(t)this.driver.clear();else{this.keys().filter(function(t){return t.startsWith(e.options.prefix||"")}).forEach(function(t){return e.remove(e.removePrefix(t))})}}catch(t){this.printError(t)}},n.prototype.has=function(t){return"memory"!==this.options.driver?this.addPrefix(t)in this.driver:this.addPrefix(t)in this.driver.storage},n.prototype.key=function(t){try{var e=this.keys()[t];return this.get(this.removePrefix(e))}catch(t){this.printError(t)}},n.prototype.keys=function(){return"memory"!==this.options.driver?Object.keys(this.driver):Object.keys(this.driver.storage)},Object.defineProperties(n.prototype,s),window.Vue2Storage=t,t}); | ||
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e(require("object-assign")):"function"==typeof define&&define.amd?define(["object-assign"],e):t.Vue2Storage=e(t.objectAssign)}(this,function(t){"use strict";function e(t,e){var r=new s(e);t.$storage=r,t.prototype.$storage=r}t="default"in t?t.default:t;var r={},o=function(){},i={length:{},storage:{}};i.length.get=function(){return Object.keys(this.storage).length},i.storage.get=function(){return r},o.prototype.getItem=function(t){return t in this.storage?this.storage[t]:null},o.prototype.setItem=function(t,e){this.storage[t]=e},o.prototype.removeItem=function(t){t in this.storage&&delete this.storage[t]},o.prototype.clear=function(){var t=this;for(var e in this.storage)delete t.storage[e]},Object.defineProperties(o.prototype,i);var n=new o,s=function(t){void 0===t&&(t={}),this.setOptions(t)},u={name:{},version:{},length:{},driver:{}};return u.name.get=function(){return"vue2-storage[v3.3.0]"},u.version.get=function(){return"3.3.0"},u.length.get=function(){return this.keys().length},u.driver.get=function(){switch(this.options.driver){case"local":default:return"undefined"!=typeof window?window.localStorage:n;case"session":return"undefined"!=typeof window?window.sessionStorage:n;case"memory":return n}},s.prototype.setOptions=function(e){void 0===e&&(e={});var r=t({prefix:"app_",driver:"local",ttl:864e5},e);this.options=Object.freeze(r)},s.prototype.printError=function(t){console.error(this.name+": "+t.stack)},s.prototype.addPrefix=function(t){return""+(this.options.prefix||"")+t},s.prototype.removePrefix=function(t){var e=new RegExp("^"+(this.options.prefix||""));return t.replace(e,"")},s.prototype.toJSON=function(t,e){void 0===e&&(e={});var r="ttl"in e?e.ttl:this.options.ttl;return JSON.stringify({value:t,ttl:Date.now()+r})},s.prototype.fromJSON=function(t){try{var e=JSON.parse(this.driver.getItem(t));return null!==e?"ttl"in e&&Number(e.ttl)<Date.now()?(this.remove(this.removePrefix(t)),null):"value"in e?e.value:e:null}catch(t){return null}},s.prototype.get=function(t,e){void 0===e&&(e=null);try{var r=this.fromJSON(this.addPrefix(t));return null===r?e:r}catch(t){this.printError(t)}},s.prototype.set=function(t,e,r){void 0===r&&(r={});try{this.driver.setItem(this.addPrefix(t),this.toJSON(e,r))}catch(t){this.printError(t)}},s.prototype.remove=function(t){try{this.driver.removeItem(this.addPrefix(t))}catch(t){this.printError(t)}},s.prototype.clear=function(t){var e=this;void 0===t&&(t=!1);try{if(t)this.driver.clear();else{this.keys().filter(function(t){return t.startsWith(e.options.prefix||"")}).forEach(function(t){return e.remove(e.removePrefix(t))})}}catch(t){this.printError(t)}},s.prototype.has=function(t){return"memory"!==this.options.driver?this.addPrefix(t)in this.driver:this.addPrefix(t)in this.driver.storage},s.prototype.key=function(t){try{var e=this.keys()[t];return this.get(this.removePrefix(e))}catch(t){this.printError(t)}},s.prototype.keys=function(){return"memory"!==this.options.driver?Object.keys(this.driver):Object.keys(this.driver.storage)},Object.defineProperties(s.prototype,u),window.Vue2Storage=e,e}); |
{ | ||
"name": "vue2-storage", | ||
"description": "Browser storage for Vue.js app", | ||
"version": "3.3.0", | ||
"version": "3.4.0", | ||
"author": { | ||
@@ -59,3 +59,2 @@ "name": "Yarkov Aleksey", | ||
"babel-preset-env": "^1.6.1", | ||
"babel-preset-es2015": "^6.22.0", | ||
"babel-preset-flow-vue": "^1.0.0", | ||
@@ -103,3 +102,6 @@ "babel-preset-power-assert": "^1.0.0", | ||
"node": ">= 6.0" | ||
}, | ||
"dependencies": { | ||
"object-assign": "^4.1.1" | ||
} | ||
} |
/* @flow */ | ||
import objectAssign from 'object-assign' | ||
import MemoryStorage from './MemoryStorage' | ||
@@ -37,3 +38,3 @@ | ||
setOptions (config: StorageOptions = {}): void { | ||
const options = Object.assign({ | ||
const options = objectAssign({ | ||
prefix: 'app_', | ||
@@ -40,0 +41,0 @@ driver: 'local', |
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
Minified code
QualityThis package contains minified code. This may be harmless in some cases where minified code is included in packaged libraries, however packages on npm should not minify code.
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
25403
46
537
1
1
+ Addedobject-assign@^4.1.1
+ Addedobject-assign@4.1.1(transitive)