From 2f0527addb2d5e170afb6435743fefdf75cb8884 Mon Sep 17 00:00:00 2001 From: Joost Boomkamp Date: Tue, 21 Nov 2017 08:26:12 +0100 Subject: [PATCH] fixed syntax error (#8) --- .gitignore | 3 ++- CHANGELOG.txt | 4 ++++ bower.json | 2 +- js.storage.js | 4 ++-- js.storage.min.js | 2 +- package.json | 2 +- 6 files changed, 11 insertions(+), 6 deletions(-) diff --git a/.gitignore b/.gitignore index beafa5d..3a2389b 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ +package-lock.json node_modules/ .idea/ -+*.iml \ No newline at end of file +*.iml diff --git a/CHANGELOG.txt b/CHANGELOG.txt index 154881c..623b956 100755 --- a/CHANGELOG.txt +++ b/CHANGELOG.txt @@ -1,5 +1,9 @@ +1.0.4 + Fix syntax issue + 1.0.3 Fix issue when native storage is not available neither js-cookies + 1.0.2 Fix isEmpty with false boolean diff --git a/bower.json b/bower.json index 413bee9..9345f49 100755 --- a/bower.json +++ b/bower.json @@ -1,6 +1,6 @@ { "name": "js-storage", - "version": "1.0.3", + "version": "1.0.4", "main": "js.storage.js", "description": "Plugin that simplify access to storages (HTML5) & cookies, add namespace storage and provide compatiblity for old browsers", "keywords": [ diff --git a/js.storage.js b/js.storage.js index 45a1f52..272696d 100755 --- a/js.storage.js +++ b/js.storage.js @@ -9,7 +9,7 @@ * Project home: * https://github.com/julien-maurel/js-storage * - * Version: 1.0.3 + * Version: 1.0.4 */ (function (factory) { var registeredInModuleLoader = false; @@ -418,7 +418,7 @@ // Check if storages are natively available on browser and check is js-cookie is present var storage_available = _testStorage('localStorage'); - var cookies_available = typeof Cookies !== 'undefined';* + var cookies_available = typeof Cookies !== 'undefined'; // Namespace object var storage = { diff --git a/js.storage.min.js b/js.storage.min.js index 7ad7f0a..ecf60ce 100755 --- a/js.storage.min.js +++ b/js.storage.min.js @@ -9,6 +9,6 @@ * Project home: * https://github.com/julien-maurel/js-storage * - * Version: 1.0.3 + * Version: 1.0.4 */ !function(e){var t=!1;if("function"==typeof define&&define.amd&&(define(e),t=!0),"object"==typeof exports&&(module.exports=e(),t=!0),!t){var r=window.Storages,o=window.Storages=e();o.noConflict=function(){return window.Storages=r,o}}}(function(){function e(){var e,t,r,o,n,i=this._type,s=arguments.length,a=window[i],l=arguments,f=l[0];if(1>s)throw new Error("Minimum 1 argument must be given");if(Array.isArray(f)){t={};for(o in f)if(f.hasOwnProperty(o)){e=f[o];try{t[e]=JSON.parse(a.getItem(e))}catch(u){t[e]=a.getItem(e)}}return t}if(1!=s){try{t=JSON.parse(a.getItem(f))}catch(u){throw new ReferenceError(f+" is not defined in this storage")}for(o=1;s-1>o;o++)if(t=t[l[o]],void 0===t)throw new ReferenceError([].slice.call(l,1,o+1).join(".")+" is not defined in this storage");if(Array.isArray(l[o])){r=t,t={};for(n in l[o])l[o].hasOwnProperty(n)&&(t[l[o][n]]=r[l[o][n]]);return t}return t[l[o]]}try{return JSON.parse(a.getItem(f))}catch(u){return a.getItem(f)}}function t(){var e,t,r,o,n=this._type,i=arguments.length,s=window[n],a=arguments,l=a[0],u=a[1],c=isNaN(u)?{}:[];if(1>i||!f(l)&&2>i)throw new Error("Minimum 2 arguments must be given or first parameter must be an object");if(f(l)){for(o in l)l.hasOwnProperty(o)&&(e=l[o],f(e)||this.alwaysUseJson?s.setItem(o,JSON.stringify(e)):s.setItem(o,e));return l}if(2==i)return"object"==typeof u||this.alwaysUseJson?s.setItem(l,JSON.stringify(u)):s.setItem(l,u),u;try{r=s.getItem(l),null!=r&&(c=JSON.parse(r))}catch(h){}for(r=c,o=1;i-2>o;o++)e=a[o],t=isNaN(a[o+1])?"object":"array",(!r[e]||"object"==t&&!f(r[e])||"array"==t&&!Array.isArray(r[e]))&&("array"==t?r[e]=[]:r[e]={}),r=r[e];return r[a[o]]=a[o+1],s.setItem(l,JSON.stringify(c)),c}function r(){var e,t,r,o,n=this._type,i=arguments.length,s=window[n],a=arguments,l=a[0];if(1>i)throw new Error("Minimum 1 argument must be given");if(Array.isArray(l)){for(r in l)l.hasOwnProperty(r)&&s.removeItem(l[r]);return!0}if(1==i)return s.removeItem(l),!0;try{e=t=JSON.parse(s.getItem(l))}catch(f){throw new ReferenceError(l+" is not defined in this storage")}for(r=1;i-1>r;r++)if(t=t[a[r]],void 0===t)throw new ReferenceError([].slice.call(a,1,r).join(".")+" is not defined in this storage");if(Array.isArray(a[r]))for(o in a[r])a[r].hasOwnProperty(o)&&delete t[a[r][o]];else delete t[a[r]];return s.setItem(l,JSON.stringify(e)),!0}function o(e){var t,o=s.call(this);for(t in o)o.hasOwnProperty(t)&&r.call(this,o[t]);if(e)for(t in d.namespaceStorages)d.namespaceStorages.hasOwnProperty(t)&&a(t)}function n(){var t,r=arguments.length,o=arguments,i=o[0];if(0==r)return 0==s.call(this).length;if(Array.isArray(i)){for(t=0;tr)throw new Error("Minimum 1 argument must be given");if(Array.isArray(n)){for(t=0;t0?e.apply(this,arguments):o,i&&i._cookie){var s=Cookies.get();for(var a in s)s.hasOwnProperty(a)&&""!=a&&n.push(a.replace(i._prefix,""))}else for(var l in i)i.hasOwnProperty(l)&&n.push(l);return n}function a(e){if(!e||"string"!=typeof e)throw new Error("First parameter must be a string");v?(window.localStorage.getItem(e)||window.localStorage.setItem(e,"{}"),window.sessionStorage.getItem(e)||window.sessionStorage.setItem(e,"{}")):(window.localCookieStorage.getItem(e)||window.localCookieStorage.setItem(e,"{}"),window.sessionCookieStorage.getItem(e)||window.sessionCookieStorage.setItem(e,"{}"));var t={localStorage:c({},d.localStorage,{_ns:e}),sessionStorage:c({},d.sessionStorage,{_ns:e})};return k&&(window.cookieStorage.getItem(e)||window.cookieStorage.setItem(e,"{}"),t.cookieStorage=c({},d.cookieStorage,{_ns:e})),d.namespaceStorages[e]=t,t}function l(e){var t="jsapi";try{return window[e]?(window[e].setItem(t,t),window[e].removeItem(t),!0):!1}catch(r){return!1}}function f(e){var t,r;return e&&"[object Object]"===g.call(e)?(t=y(e))?(r=w.call(t,"constructor")&&t.constructor,"function"==typeof r&&p.call(r)===m):!0:!1}function u(e){var t;for(t in e)return!1;return!0}function c(){for(var e=1,t=arguments[0];ee||!f(o)&&2>e)throw new Error("Minimum 2 arguments must be given or first parameter must be an object");if(!v&&!k)return null;if(f(o)&&this._ns){for(var n in o)o.hasOwnProperty(n)&&this._callMethod(t,[n,o[n]]);return o}var i=this._callMethod(t,r);return this._ns?i[o.split(".")[0]]:i},remove:function(){if(arguments.length<1)throw new Error("Minimum 1 argument must be given");return v||k?this._callMethod(r,arguments):null},removeAll:function(e){return v||k?this._ns?(this._callMethod(t,[{}]),!0):this._callMethod(o,[e]):null},isEmpty:function(){return v||k?this._callMethod(n,arguments):null},isSet:function(){if(arguments.length<1)throw new Error("Minimum 1 argument must be given");return v||k?this._callMethod(i,arguments):null},keys:function(){return v||k?this._callMethod(s,arguments):null}};if(k){window.name||(window.name=Math.floor(1e8*Math.random()));var I={_cookie:!0,_prefix:"",_expires:null,_path:null,_domain:null,setItem:function(e,t){Cookies.set(this._prefix+e,t,{expires:this._expires,path:this._path,domain:this._domain})},getItem:function(e){return Cookies.get(this._prefix+e)},removeItem:function(e){return Cookies.remove(this._prefix+e,{path:this._path})},clear:function(){var e=Cookies.get();for(var t in e)e.hasOwnProperty(t)&&""!=t&&(!this._prefix&&-1===t.indexOf(S)&&-1===t.indexOf(_)||this._prefix&&0===t.indexOf(this._prefix))&&Cookies.remove(t)},setExpires:function(e){return this._expires=e,this},setPath:function(e){return this._path=e,this},setDomain:function(e){return this._domain=e,this},setConf:function(e){return e.path&&(this._path=e.path),e.domain&&(this._domain=e.domain),e.expires&&(this._expires=e.expires),this},setDefaultConf:function(){this._path=this._domain=this._expires=null}};v||(window.localCookieStorage=c({},I,{_prefix:S,_expires:3650}),window.sessionCookieStorage=c({},I,{_prefix:_+window.name+"_"})),window.cookieStorage=c({},I),d.cookieStorage=c({},O,{_type:"cookieStorage",setExpires:function(e){return window.cookieStorage.setExpires(e),this},setPath:function(e){return window.cookieStorage.setPath(e),this},setDomain:function(e){return window.cookieStorage.setDomain(e),this},setConf:function(e){return window.cookieStorage.setConf(e),this},setDefaultConf:function(){return window.cookieStorage.setDefaultConf(),this}})}return d.initNamespaceStorage=function(e){return a(e)},v?(d.localStorage=c({},O,{_type:"localStorage"}),d.sessionStorage=c({},O,{_type:"sessionStorage"})):(d.localStorage=c({},O,{_type:"localCookieStorage"}),d.sessionStorage=c({},O,{_type:"sessionCookieStorage"})),d.namespaceStorages={},d.removeAllStorages=function(e){d.localStorage.removeAll(e),d.sessionStorage.removeAll(e),d.cookieStorage&&d.cookieStorage.removeAll(e),e||(d.namespaceStorages={})},d.alwaysUseJsonInStorage=function(e){O.alwaysUseJson=e,d.localStorage.alwaysUseJson=e,d.sessionStorage.alwaysUseJson=e,d.cookieStorage&&(d.cookieStorage.alwaysUseJson=e)},d}); \ No newline at end of file diff --git a/package.json b/package.json index 7a13305..d7ea2c7 100755 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "js-storage", - "version": "1.0.3", + "version": "1.0.4", "author": { "name": "Julien Maurel", "url": "https://github.com/julien-maurel"