localforage
Advanced tools
Comparing version 0.9.1 to 0.9.2
{ | ||
"name": "localforage", | ||
"version": "0.9.1", | ||
"version": "0.9.2", | ||
"main": [ | ||
@@ -5,0 +5,0 @@ "dist/localforage.min.js" |
@@ -6,4 +6,8 @@ # About this CHANGELOG | ||
### [Next Version](https://github.com/mozilla/localForage/) | ||
### Next Version | ||
* `setDriver` now accepts an array of drivers to be used, in order of preference, instead of simply a string. The string option is still supported. (eg. now one can use `setDriver(['WebSQL', 'localStorage'])` instead of `setDriver('WebSQL')`) | ||
### [0.9](https://github.com/mozilla/localForage/releases/tag/0.9.1) | ||
This release drops support for some legacy browsers, though not actually the | ||
@@ -18,4 +22,6 @@ ones you might think. localForage's new policy is to support the current | ||
* Switch to Mocha tests and test on [Sauce Labs](https://saucelabs.com/). | ||
* Add a `keys()` method. ([#180](https://github.com/mozilla/localForage/pull/180)) | ||
* Check for localStorage instead of assuming it's available. ([#183](https://github.com/mozilla/localForage/pull/183)) | ||
### [Version 0.8.0](https://github.com/mozilla/localForage/releases/tag/0.8.0) | ||
### [Version 0.8](https://github.com/mozilla/localForage/releases/tag/0.8.1) | ||
@@ -35,7 +41,7 @@ * Add support for web workers. ([#144](https://github.com/mozilla/localForage/pull/144), [#147](https://github.com/mozilla/localForage/pull/147)). | ||
### [Version 0.4.0](https://github.com/mozilla/localForage/releases/tag/0.4.0) | ||
### [Version 0.4](https://github.com/mozilla/localForage/releases/tag/0.4.0) | ||
* Built versions of localForage are now in the top-level directory. ([2d11c90](https://github.com/mozilla/localForage/commit/2d11c90)) | ||
### [Version 0.3.0](https://github.com/mozilla/localForage/releases/tag/0.3.0) | ||
### [Version 0.3](https://github.com/mozilla/localForage/releases/tag/0.3.0) | ||
@@ -42,0 +48,0 @@ * Check code quality in test suite ([#124](https://github.com/mozilla/localForage/pull/124)) |
{ | ||
"name": "localforage", | ||
"version": "0.9.1", | ||
"version": "0.9.2", | ||
"dependencies": { | ||
"then/promise": "4.0.0" | ||
"then/promise": "5.0.0" | ||
}, | ||
@@ -7,0 +7,0 @@ "scripts": [ |
@@ -1,1 +0,1 @@ | ||
!function(){var a,b,c,d;!function(){var e={},f={};a=function(a,b,c){e[a]={deps:b,callback:c}},d=c=b=function(a){function c(b){if("."!==b.charAt(0))return b;for(var c=b.split("/"),d=a.split("/").slice(0,-1),e=0,f=c.length;f>e;e++){var g=c[e];if(".."===g)d.pop();else{if("."===g)continue;d.push(g)}}return d.join("/")}if(d._eak_seen=e,f[a])return f[a];if(f[a]={},!e[a])throw new Error("Could not find module "+a);for(var g,h=e[a],i=h.deps,j=h.callback,k=[],l=0,m=i.length;m>l;l++)k.push("exports"===i[l]?g={}:b(c(i[l])));var n=j.apply(this,k);return f[a]=g||n}}(),a("promise/all",["./utils","exports"],function(a,b){"use strict";function c(a){var b=this;if(!d(a))throw new TypeError("You must pass an array to all.");return new b(function(b,c){function d(a){return function(b){f(a,b)}}function f(a,c){h[a]=c,0===--i&&b(h)}var g,h=[],i=a.length;0===i&&b([]);for(var j=0;j<a.length;j++)g=a[j],g&&e(g.then)?g.then(d(j),c):f(j,g)})}var d=a.isArray,e=a.isFunction;b.all=c}),a("promise/asap",["exports"],function(a){"use strict";function b(){return function(){process.nextTick(e)}}function c(){var a=0,b=new i(e),c=document.createTextNode("");return b.observe(c,{characterData:!0}),function(){c.data=a=++a%2}}function d(){return function(){j.setTimeout(e,1)}}function e(){for(var a=0;a<k.length;a++){var b=k[a],c=b[0],d=b[1];c(d)}k=[]}function f(a,b){var c=k.push([a,b]);1===c&&g()}var g,h="undefined"!=typeof window?window:{},i=h.MutationObserver||h.WebKitMutationObserver,j="undefined"!=typeof global?global:void 0===this?window:this,k=[];g="undefined"!=typeof process&&"[object process]"==={}.toString.call(process)?b():i?c():d(),a.asap=f}),a("promise/config",["exports"],function(a){"use strict";function b(a,b){return 2!==arguments.length?c[a]:void(c[a]=b)}var c={instrument:!1};a.config=c,a.configure=b}),a("promise/polyfill",["./promise","./utils","exports"],function(a,b,c){"use strict";function d(){var a;a="undefined"!=typeof global?global:"undefined"!=typeof window&&window.document?window:self;var b="Promise"in a&&"resolve"in a.Promise&&"reject"in a.Promise&&"all"in a.Promise&&"race"in a.Promise&&function(){var b;return new a.Promise(function(a){b=a}),f(b)}();b||(a.Promise=e)}var e=a.Promise,f=b.isFunction;c.polyfill=d}),a("promise/promise",["./config","./utils","./all","./race","./resolve","./reject","./asap","exports"],function(a,b,c,d,e,f,g,h){"use strict";function i(a){if(!v(a))throw new TypeError("You must pass a resolver function as the first argument to the promise constructor");if(!(this instanceof i))throw new TypeError("Failed to construct 'Promise': Please use the 'new' operator, this object constructor cannot be called as a function.");this._subscribers=[],j(a,this)}function j(a,b){function c(a){o(b,a)}function d(a){q(b,a)}try{a(c,d)}catch(e){d(e)}}function k(a,b,c,d){var e,f,g,h,i=v(c);if(i)try{e=c(d),g=!0}catch(j){h=!0,f=j}else e=d,g=!0;n(b,e)||(i&&g?o(b,e):h?q(b,f):a===D?o(b,e):a===E&&q(b,e))}function l(a,b,c,d){var e=a._subscribers,f=e.length;e[f]=b,e[f+D]=c,e[f+E]=d}function m(a,b){for(var c,d,e=a._subscribers,f=a._detail,g=0;g<e.length;g+=3)c=e[g],d=e[g+b],k(b,c,d,f);a._subscribers=null}function n(a,b){var c,d=null;try{if(a===b)throw new TypeError("A promises callback cannot return that same promise.");if(u(b)&&(d=b.then,v(d)))return d.call(b,function(d){return c?!0:(c=!0,void(b!==d?o(a,d):p(a,d)))},function(b){return c?!0:(c=!0,void q(a,b))}),!0}catch(e){return c?!0:(q(a,e),!0)}return!1}function o(a,b){a===b?p(a,b):n(a,b)||p(a,b)}function p(a,b){a._state===B&&(a._state=C,a._detail=b,t.async(r,a))}function q(a,b){a._state===B&&(a._state=C,a._detail=b,t.async(s,a))}function r(a){m(a,a._state=D)}function s(a){m(a,a._state=E)}var t=a.config,u=(a.configure,b.objectOrFunction),v=b.isFunction,w=(b.now,c.all),x=d.race,y=e.resolve,z=f.reject,A=g.asap;t.async=A;var B=void 0,C=0,D=1,E=2;i.prototype={constructor:i,_state:void 0,_detail:void 0,_subscribers:void 0,then:function(a,b){var c=this,d=new this.constructor(function(){});if(this._state){var e=arguments;t.async(function(){k(c._state,d,e[c._state-1],c._detail)})}else l(this,d,a,b);return d},"catch":function(a){return this.then(null,a)}},i.all=w,i.race=x,i.resolve=y,i.reject=z,h.Promise=i}),a("promise/race",["./utils","exports"],function(a,b){"use strict";function c(a){var b=this;if(!d(a))throw new TypeError("You must pass an array to race.");return new b(function(b,c){for(var d,e=0;e<a.length;e++)d=a[e],d&&"function"==typeof d.then?d.then(b,c):b(d)})}var d=a.isArray;b.race=c}),a("promise/reject",["exports"],function(a){"use strict";function b(a){var b=this;return new b(function(b,c){c(a)})}a.reject=b}),a("promise/resolve",["exports"],function(a){"use strict";function b(a){if(a&&"object"==typeof a&&a.constructor===this)return a;var b=this;return new b(function(b){b(a)})}a.resolve=b}),a("promise/utils",["exports"],function(a){"use strict";function b(a){return c(a)||"object"==typeof a&&null!==a}function c(a){return"function"==typeof a}function d(a){return"[object Array]"===Object.prototype.toString.call(a)}var e=Date.now||function(){return(new Date).getTime()};a.objectOrFunction=b,a.isFunction=c,a.isArray=d,a.now=e}),b("promise/polyfill").polyfill()}(),function(){"use strict";function a(a){if(a)for(var b in a)l[b]=a[b];return new j(function(a,b){var c=m.open(l.name,l.version);c.onerror=function(){b(c.error)},c.onupgradeneeded=function(){c.result.createObjectStore(l.storeName)},c.onsuccess=function(){k=c.result,a()}})}function b(a,b){var c=this;return new j(function(d,e){c.ready().then(function(){var c=k.transaction(l.storeName,"readonly").objectStore(l.storeName),f=c.get(a);f.onsuccess=function(){var a=f.result;void 0===a&&(a=null),i(b,a),d(a)},f.onerror=function(){b&&b(null,f.error),e(f.error)}},function(a){e(a)})})}function c(a,b,c){var d=this;return new j(function(e,f){d.ready().then(function(){var d=k.transaction(l.storeName,"readwrite").objectStore(l.storeName);null===b&&(b=void 0);var g=d.put(b,a);g.onsuccess=function(){void 0===b&&(b=null),i(c,b),e(b)},g.onerror=function(){c&&c(null,g.error),f(g.error)}},function(a){f(a)})})}function d(a,b){var c=this;return new j(function(d,e){c.ready().then(function(){var c=k.transaction(l.storeName,"readwrite").objectStore(l.storeName),f=c["delete"](a);f.onsuccess=function(){i(b),d()},f.onerror=function(){b&&b(f.error),e(f.error)},f.onabort=function(a){var c=a.target.error;"QuotaExceededError"===c&&(b&&b(c),e(c))}},function(a){e(a)})})}function e(a){var b=this;return new j(function(c,d){b.ready().then(function(){var b=k.transaction(l.storeName,"readwrite").objectStore(l.storeName),e=b.clear();e.onsuccess=function(){i(a),c()},e.onerror=function(){a&&a(null,e.error),d(e.error)}},function(a){d(a)})})}function f(a){var b=this;return new j(function(c,d){b.ready().then(function(){var b=k.transaction(l.storeName,"readonly").objectStore(l.storeName),e=b.count();e.onsuccess=function(){a&&a(e.result),c(e.result)},e.onerror=function(){a&&a(null,e.error),d(e.error)}},function(a){d(a)})})}function g(a,b){var c=this;return new j(function(d,e){return 0>a?(b&&b(null),void d(null)):void c.ready().then(function(){var c=k.transaction(l.storeName,"readonly").objectStore(l.storeName),f=!1,g=c.openCursor();g.onsuccess=function(){var c=g.result;return c?void(0===a?(b&&b(c.key),d(c.key)):f?(b&&b(c.key),d(c.key)):(f=!0,c.advance(a))):(b&&b(null),void d(null))},g.onerror=function(){b&&b(null,g.error),e(g.error)}},function(a){e(a)})})}function h(a){var b=this;return new j(function(c,d){b.ready().then(function(){var b=k.transaction(l.storeName,"readonly").objectStore(l.storeName),e=b.openCursor(),f=[];e.onsuccess=function(){var b=e.result;return b?(f.push(b.key),void b.continue()):(a&&a(f),void c(f))},e.onerror=function(){a&&a(null,e.error),d(e.error)}},function(a){d(a)})})}function i(a,b){return a?setTimeout(function(){return a(b)},0):void 0}var j="undefined"!=typeof module&&module.exports?require("promise"):this.Promise,k=null,l={},m=m||this.indexedDB||this.webkitIndexedDB||this.mozIndexedDB||this.OIndexedDB||this.msIndexedDB;if(m){var n={_driver:"asyncStorage",_initStorage:a,getItem:b,setItem:c,removeItem:d,clear:e,length:f,key:g,keys:h};"function"==typeof define&&define.amd?define("asyncStorage",function(){return n}):"undefined"!=typeof module&&module.exports?module.exports=n:this.asyncStorage=n}}.call(this),function(){"use strict";function a(a){if(a)for(var b in a)m[b]=a[b];return l=m.name+"/",n.resolve()}function b(a){var b=this;return new n(function(c){b.ready().then(function(){o.clear(),a&&a(),c()})})}function c(a,b){var c=this;return new n(function(d,e){c.ready().then(function(){try{var c=o.getItem(l+a);c&&(c=h(c)),b&&b(c),d(c)}catch(f){b&&b(null,f),e(f)}})})}function d(a,b){var c=this;return new n(function(d){c.ready().then(function(){var c;try{c=o.key(a)}catch(e){c=null}c&&(c=c.substring(l.length)),b&&b(c),d(c)})})}function e(a){var b=this;return new n(function(c){b.ready().then(function(){for(var b=o.length,d=[],e=0;b>e;e++)d.push(o.key(e).substring(l.length));a&&a(d),c(d)})})}function f(a){var b=this;return new n(function(c){b.ready().then(function(){var b=o.length;a&&a(b),c(b)})})}function g(a,b){var c=this;return new n(function(d){c.ready().then(function(){o.removeItem(l+a),b&&b(),d()})})}function h(a){if(a.substring(0,r)!==q)return JSON.parse(a);for(var b=a.substring(D),c=a.substring(r,D),d=new ArrayBuffer(2*b.length),e=new Uint16Array(d),f=b.length-1;f>=0;f--)e[f]=b.charCodeAt(f);switch(c){case s:return d;case t:return new Blob([d]);case u:return new Int8Array(d);case v:return new Uint8Array(d);case w:return new Uint8ClampedArray(d);case x:return new Int16Array(d);case z:return new Uint16Array(d);case y:return new Int32Array(d);case A:return new Uint32Array(d);case B:return new Float32Array(d);case C:return new Float64Array(d);default:throw new Error("Unkown type: "+c)}}function i(a){var b="",c=new Uint16Array(a);try{b=String.fromCharCode.apply(null,c)}catch(d){for(var e=0;e<c.length;e++)b+=String.fromCharCode(c[e])}return b}function j(a,b){var c="";if(a&&(c=a.toString()),a&&("[object ArrayBuffer]"===a.toString()||a.buffer&&"[object ArrayBuffer]"===a.buffer.toString())){var d,e=q;a instanceof ArrayBuffer?(d=a,e+=s):(d=a.buffer,"[object Int8Array]"===c?e+=u:"[object Uint8Array]"===c?e+=v:"[object Uint8ClampedArray]"===c?e+=w:"[object Int16Array]"===c?e+=x:"[object Uint16Array]"===c?e+=z:"[object Int32Array]"===c?e+=y:"[object Uint32Array]"===c?e+=A:"[object Float32Array]"===c?e+=B:"[object Float64Array]"===c?e+=C:b(new Error("Failed to get type for BinaryArray"))),b(e+i(d))}else if("[object Blob]"===c){var f=new FileReader;f.onload=function(){var a=i(this.result);b(q+t+a)},f.readAsArrayBuffer(a)}else try{b(JSON.stringify(a))}catch(g){this.console&&this.console.error&&this.console.error("Couldn't convert value into a JSON string: ",a),b(null,g)}}function k(a,b,c){var d=this;return new n(function(e,f){d.ready().then(function(){void 0===b&&(b=null);var d=b;j(b,function(b,g){if(g)c&&c(null,g),f(g);else{try{o.setItem(l+a,b)}catch(h){("QuotaExceededError"===h.name||"NS_ERROR_DOM_QUOTA_REACHED"===h.name)&&(c&&c(null,h),f(h))}c&&c(d),e(d)}})})})}var l="",m={},n="undefined"!=typeof module&&module.exports?require("promise"):this.Promise,o=null;try{if(!(this.localStorage&&"setItem"in this.localStorage))return;o=this.localStorage}catch(p){return}var q="__lfsc__:",r=q.length,s="arbf",t="blob",u="si08",v="ui08",w="uic8",x="si16",y="si32",z="ur16",A="ui32",B="fl32",C="fl64",D=r+s.length,E={_driver:"localStorageWrapper",_initStorage:a,getItem:c,setItem:k,removeItem:g,clear:b,length:f,key:d,keys:e};"function"==typeof define&&define.amd?define("localStorageWrapper",function(){return E}):"undefined"!=typeof module&&module.exports?module.exports=E:this.localStorageWrapper=E}.call(this),function(){"use strict";function a(a){var b=this;if(a)for(var c in a)p[c]="string"!=typeof a[c]?a[c].toString():a[c];return new m(function(a){try{o=n(p.name,p.version,p.description,p.size)}catch(c){return b.setDriver("localStorageWrapper").then(a)}o.transaction(function(b){b.executeSql("CREATE TABLE IF NOT EXISTS "+p.storeName+" (id INTEGER PRIMARY KEY, key unique, value)",[],function(){a()},null)})})}function b(a,b){var c=this;return new m(function(d,e){c.ready().then(function(){o.transaction(function(c){c.executeSql("SELECT * FROM "+p.storeName+" WHERE key = ? LIMIT 1",[a],function(a,c){var e=c.rows.length?c.rows.item(0).value:null;e&&(e=j(e)),b&&b(e),d(e)},function(a,c){b&&b(null,c),e(c)})})})})}function c(a,b,c){var d=this;return new m(function(e,f){d.ready().then(function(){void 0===b&&(b=null);var d=b;k(b,function(b,g){g?f(g):o.transaction(function(g){g.executeSql("INSERT OR REPLACE INTO "+p.storeName+" (key, value) VALUES (?, ?)",[a,b],function(){c&&c(d),e(d)},function(a,b){c&&c(null,b),f(b)})},function(a){a.code===a.QUOTA_ERR&&(c&&c(null,a),f(a))})})})})}function d(a,b){var c=this;return new m(function(d,e){c.ready().then(function(){o.transaction(function(c){c.executeSql("DELETE FROM "+p.storeName+" WHERE key = ?",[a],function(){b&&b(),d()},function(a,c){b&&b(c),e(c)})})})})}function e(a){var b=this;return new m(function(c,d){b.ready().then(function(){o.transaction(function(b){b.executeSql("DELETE FROM "+p.storeName,[],function(){a&&a(),c()},function(b,c){a&&a(c),d(c)})})})})}function f(a){var b=this;return new m(function(c,d){b.ready().then(function(){o.transaction(function(b){b.executeSql("SELECT COUNT(key) as c FROM "+p.storeName,[],function(b,d){var e=d.rows.item(0).c;a&&a(e),c(e)},function(b,c){a&&a(null,c),d(c)})})})})}function g(a,b){var c=this;return new m(function(d,e){c.ready().then(function(){o.transaction(function(c){c.executeSql("SELECT key FROM "+p.storeName+" WHERE id = ? LIMIT 1",[a+1],function(a,c){var e=c.rows.length?c.rows.item(0).key:null;b&&b(e),d(e)},function(a,c){b&&b(null,c),e(c)})})})})}function h(a){var b=this;return new m(function(c,d){b.ready().then(function(){o.transaction(function(b){b.executeSql("SELECT key FROM "+p.storeName,[],function(b,d){for(var e=d.rows.length,f=[],g=0;e>g;g++)f.push(d.rows.item(g).key);a&&a(f),c(f)},function(b,c){a&&a(null,c),d(c)})})})})}function i(a){var b,c=new Uint8Array(a),d="";for(b=0;b<c.length;b+=3)d+=l[c[b]>>2],d+=l[(3&c[b])<<4|c[b+1]>>4],d+=l[(15&c[b+1])<<2|c[b+2]>>6],d+=l[63&c[b+2]];return c.length%3===2?d=d.substring(0,d.length-1)+"=":c.length%3===1&&(d=d.substring(0,d.length-2)+"=="),d}function j(a){if(a.substring(0,r)!==q)return JSON.parse(a);var b,c,d,e,f,g=a.substring(D),h=a.substring(r,D),i=.75*g.length,j=g.length,k=0;"="===g[g.length-1]&&(i--,"="===g[g.length-2]&&i--);var m=new ArrayBuffer(i),n=new Uint8Array(m);for(b=0;j>b;b+=4)c=l.indexOf(g[b]),d=l.indexOf(g[b+1]),e=l.indexOf(g[b+2]),f=l.indexOf(g[b+3]),n[k++]=c<<2|d>>4,n[k++]=(15&d)<<4|e>>2,n[k++]=(3&e)<<6|63&f;switch(h){case s:return m;case t:return new Blob([m]);case u:return new Int8Array(m);case v:return new Uint8Array(m);case w:return new Uint8ClampedArray(m);case x:return new Int16Array(m);case z:return new Uint16Array(m);case y:return new Int32Array(m);case A:return new Uint32Array(m);case B:return new Float32Array(m);case C:return new Float64Array(m);default:throw new Error("Unkown type: "+h)}}function k(a,b){var c="";if(a&&(c=a.toString()),a&&("[object ArrayBuffer]"===a.toString()||a.buffer&&"[object ArrayBuffer]"===a.buffer.toString())){var d,e=q;a instanceof ArrayBuffer?(d=a,e+=s):(d=a.buffer,"[object Int8Array]"===c?e+=u:"[object Uint8Array]"===c?e+=v:"[object Uint8ClampedArray]"===c?e+=w:"[object Int16Array]"===c?e+=x:"[object Uint16Array]"===c?e+=z:"[object Int32Array]"===c?e+=y:"[object Uint32Array]"===c?e+=A:"[object Float32Array]"===c?e+=B:"[object Float64Array]"===c?e+=C:b(new Error("Failed to get type for BinaryArray"))),b(e+i(d))}else if("[object Blob]"===c){var f=new FileReader;f.onload=function(){var a=i(this.result);b(q+t+a)},f.readAsArrayBuffer(a)}else try{b(JSON.stringify(a))}catch(g){this.console&&this.console.error&&this.console.error("Couldn't convert value into a JSON string: ",a),b(null,g)}}var l="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",m="undefined"!=typeof module&&module.exports?require("promise"):this.Promise,n=this.openDatabase,o=null,p={},q="__lfsc__:",r=q.length,s="arbf",t="blob",u="si08",v="ui08",w="uic8",x="si16",y="si32",z="ur16",A="ui32",B="fl32",C="fl64",D=r+s.length;if(n){var E={_driver:"webSQLStorage",_initStorage:a,getItem:b,setItem:c,removeItem:d,clear:e,length:f,key:g,keys:h};"function"==typeof define&&define.amd?define("webSQLStorage",function(){return E}):"undefined"!=typeof module&&module.exports?module.exports=E:this.webSQLStorage=E}}.call(this),function(){"use strict";var a="undefined"!=typeof module&&module.exports?require("promise"):this.Promise,b=1,c=2,d=3,e=d;"function"==typeof define&&define.amd?e=b:"undefined"!=typeof module&&module.exports&&(e=c);var f,g=g||this.indexedDB||this.webkitIndexedDB||this.mozIndexedDB||this.OIndexedDB||this.msIndexedDB,h=g&&"function"==typeof g.open&&null===g.open("_localforage_spec_test",1).onupgradeneeded,i=this.openDatabase,j=function(){try{return localStorage&&"function"==typeof localStorage.setItem}catch(a){return!1}}(),k=this,l={INDEXEDDB:"asyncStorage",LOCALSTORAGE:"localStorageWrapper",WEBSQL:"webSQLStorage",_config:{description:"",name:"localforage",size:4980736,storeName:"keyvaluepairs",version:1},config:function(a){if("object"==typeof a){if(this._ready)return new Error("Can't call config() after localforage has been used.");for(var b in a)this._config[b]=a[b];return!0}return"string"==typeof a?this._config[a]:this._config},driver:function(){return this._driver||null},_ready:!1,_driverSet:null,setDriver:function(d,f,g){var m=this;return this._driverSet=new a(function(a,n){if(!h&&d===l.INDEXEDDB||!i&&d===l.WEBSQL||!j&&d===l.LOCALSTORAGE)return g&&g(),void n(l);if(m._ready=null,e===b)return void require([d],function(b){m._extend(b),f&&f(),a()});if(e===c){var o;switch(d){case m.INDEXEDDB:o=require("./drivers/indexeddb");break;case m.LOCALSTORAGE:o=require("./drivers/localstorage");break;case m.WEBSQL:o=require("./drivers/websql")}m._extend(o)}else m._extend(k[d]);f&&f(),a()}),this._driverSet},ready:function(b){var c=new a(function(a){l._driverSet.then(function(){null===l._ready&&(l._ready=l._initStorage(l._config)),l._ready.then(a)})});return c.then(b,b),c},_extend:function(a){for(var b in a)a.hasOwnProperty(b)&&(this[b]=a[b])}};h?f=l.INDEXEDDB:i?f=l.WEBSQL:j&&(f=l.LOCALSTORAGE),this.localForageConfig&&(l.config=this.localForageConfig),f?l.setDriver(f):l._ready=a.reject(new Error("No available storage method found.")),e===b?define(function(){return l}):e===c?module.exports=l:this.localforage=l}.call(this); | ||
!function(){var a,b,c,d;!function(){var e={},f={};a=function(a,b,c){e[a]={deps:b,callback:c}},d=c=b=function(a){function c(b){if("."!==b.charAt(0))return b;for(var c=b.split("/"),d=a.split("/").slice(0,-1),e=0,f=c.length;f>e;e++){var g=c[e];if(".."===g)d.pop();else{if("."===g)continue;d.push(g)}}return d.join("/")}if(d._eak_seen=e,f[a])return f[a];if(f[a]={},!e[a])throw new Error("Could not find module "+a);for(var g,h=e[a],i=h.deps,j=h.callback,k=[],l=0,m=i.length;m>l;l++)k.push("exports"===i[l]?g={}:b(c(i[l])));var n=j.apply(this,k);return f[a]=g||n}}(),a("promise/all",["./utils","exports"],function(a,b){"use strict";function c(a){var b=this;if(!d(a))throw new TypeError("You must pass an array to all.");return new b(function(b,c){function d(a){return function(b){f(a,b)}}function f(a,c){h[a]=c,0===--i&&b(h)}var g,h=[],i=a.length;0===i&&b([]);for(var j=0;j<a.length;j++)g=a[j],g&&e(g.then)?g.then(d(j),c):f(j,g)})}var d=a.isArray,e=a.isFunction;b.all=c}),a("promise/asap",["exports"],function(a){"use strict";function b(){return function(){process.nextTick(e)}}function c(){var a=0,b=new i(e),c=document.createTextNode("");return b.observe(c,{characterData:!0}),function(){c.data=a=++a%2}}function d(){return function(){j.setTimeout(e,1)}}function e(){for(var a=0;a<k.length;a++){var b=k[a],c=b[0],d=b[1];c(d)}k=[]}function f(a,b){var c=k.push([a,b]);1===c&&g()}var g,h="undefined"!=typeof window?window:{},i=h.MutationObserver||h.WebKitMutationObserver,j="undefined"!=typeof global?global:void 0===this?window:this,k=[];g="undefined"!=typeof process&&"[object process]"==={}.toString.call(process)?b():i?c():d(),a.asap=f}),a("promise/config",["exports"],function(a){"use strict";function b(a,b){return 2!==arguments.length?c[a]:void(c[a]=b)}var c={instrument:!1};a.config=c,a.configure=b}),a("promise/polyfill",["./promise","./utils","exports"],function(a,b,c){"use strict";function d(){var a;a="undefined"!=typeof global?global:"undefined"!=typeof window&&window.document?window:self;var b="Promise"in a&&"resolve"in a.Promise&&"reject"in a.Promise&&"all"in a.Promise&&"race"in a.Promise&&function(){var b;return new a.Promise(function(a){b=a}),f(b)}();b||(a.Promise=e)}var e=a.Promise,f=b.isFunction;c.polyfill=d}),a("promise/promise",["./config","./utils","./all","./race","./resolve","./reject","./asap","exports"],function(a,b,c,d,e,f,g,h){"use strict";function i(a){if(!v(a))throw new TypeError("You must pass a resolver function as the first argument to the promise constructor");if(!(this instanceof i))throw new TypeError("Failed to construct 'Promise': Please use the 'new' operator, this object constructor cannot be called as a function.");this._subscribers=[],j(a,this)}function j(a,b){function c(a){o(b,a)}function d(a){q(b,a)}try{a(c,d)}catch(e){d(e)}}function k(a,b,c,d){var e,f,g,h,i=v(c);if(i)try{e=c(d),g=!0}catch(j){h=!0,f=j}else e=d,g=!0;n(b,e)||(i&&g?o(b,e):h?q(b,f):a===D?o(b,e):a===E&&q(b,e))}function l(a,b,c,d){var e=a._subscribers,f=e.length;e[f]=b,e[f+D]=c,e[f+E]=d}function m(a,b){for(var c,d,e=a._subscribers,f=a._detail,g=0;g<e.length;g+=3)c=e[g],d=e[g+b],k(b,c,d,f);a._subscribers=null}function n(a,b){var c,d=null;try{if(a===b)throw new TypeError("A promises callback cannot return that same promise.");if(u(b)&&(d=b.then,v(d)))return d.call(b,function(d){return c?!0:(c=!0,void(b!==d?o(a,d):p(a,d)))},function(b){return c?!0:(c=!0,void q(a,b))}),!0}catch(e){return c?!0:(q(a,e),!0)}return!1}function o(a,b){a===b?p(a,b):n(a,b)||p(a,b)}function p(a,b){a._state===B&&(a._state=C,a._detail=b,t.async(r,a))}function q(a,b){a._state===B&&(a._state=C,a._detail=b,t.async(s,a))}function r(a){m(a,a._state=D)}function s(a){m(a,a._state=E)}var t=a.config,u=(a.configure,b.objectOrFunction),v=b.isFunction,w=(b.now,c.all),x=d.race,y=e.resolve,z=f.reject,A=g.asap;t.async=A;var B=void 0,C=0,D=1,E=2;i.prototype={constructor:i,_state:void 0,_detail:void 0,_subscribers:void 0,then:function(a,b){var c=this,d=new this.constructor(function(){});if(this._state){var e=arguments;t.async(function(){k(c._state,d,e[c._state-1],c._detail)})}else l(this,d,a,b);return d},"catch":function(a){return this.then(null,a)}},i.all=w,i.race=x,i.resolve=y,i.reject=z,h.Promise=i}),a("promise/race",["./utils","exports"],function(a,b){"use strict";function c(a){var b=this;if(!d(a))throw new TypeError("You must pass an array to race.");return new b(function(b,c){for(var d,e=0;e<a.length;e++)d=a[e],d&&"function"==typeof d.then?d.then(b,c):b(d)})}var d=a.isArray;b.race=c}),a("promise/reject",["exports"],function(a){"use strict";function b(a){var b=this;return new b(function(b,c){c(a)})}a.reject=b}),a("promise/resolve",["exports"],function(a){"use strict";function b(a){if(a&&"object"==typeof a&&a.constructor===this)return a;var b=this;return new b(function(b){b(a)})}a.resolve=b}),a("promise/utils",["exports"],function(a){"use strict";function b(a){return c(a)||"object"==typeof a&&null!==a}function c(a){return"function"==typeof a}function d(a){return"[object Array]"===Object.prototype.toString.call(a)}var e=Date.now||function(){return(new Date).getTime()};a.objectOrFunction=b,a.isFunction=c,a.isArray=d,a.now=e}),b("promise/polyfill").polyfill()}(),function(){"use strict";function a(a){if(a)for(var b in a)l[b]=a[b];return new j(function(a,b){var c=m.open(l.name,l.version);c.onerror=function(){b(c.error)},c.onupgradeneeded=function(){c.result.createObjectStore(l.storeName)},c.onsuccess=function(){k=c.result,a()}})}function b(a,b){var c=this;return new j(function(d,e){c.ready().then(function(){var c=k.transaction(l.storeName,"readonly").objectStore(l.storeName),f=c.get(a);f.onsuccess=function(){var a=f.result;void 0===a&&(a=null),i(b,a),d(a)},f.onerror=function(){b&&b(null,f.error),e(f.error)}},e)})}function c(a,b,c){var d=this;return new j(function(e,f){d.ready().then(function(){var d=k.transaction(l.storeName,"readwrite").objectStore(l.storeName);null===b&&(b=void 0);var g=d.put(b,a);g.onsuccess=function(){void 0===b&&(b=null),i(c,b),e(b)},g.onerror=function(){c&&c(null,g.error),f(g.error)}},f)})}function d(a,b){var c=this;return new j(function(d,e){c.ready().then(function(){var c=k.transaction(l.storeName,"readwrite").objectStore(l.storeName),f=c["delete"](a);f.onsuccess=function(){i(b),d()},f.onerror=function(){b&&b(f.error),e(f.error)},f.onabort=function(a){var c=a.target.error;"QuotaExceededError"===c&&(b&&b(c),e(c))}},e)})}function e(a){var b=this;return new j(function(c,d){b.ready().then(function(){var b=k.transaction(l.storeName,"readwrite").objectStore(l.storeName),e=b.clear();e.onsuccess=function(){i(a),c()},e.onerror=function(){a&&a(null,e.error),d(e.error)}},d)})}function f(a){var b=this;return new j(function(c,d){b.ready().then(function(){var b=k.transaction(l.storeName,"readonly").objectStore(l.storeName),e=b.count();e.onsuccess=function(){a&&a(e.result),c(e.result)},e.onerror=function(){a&&a(null,e.error),d(e.error)}},d)})}function g(a,b){var c=this;return new j(function(d,e){return 0>a?(b&&b(null),void d(null)):void c.ready().then(function(){var c=k.transaction(l.storeName,"readonly").objectStore(l.storeName),f=!1,g=c.openCursor();g.onsuccess=function(){var c=g.result;return c?void(0===a?(b&&b(c.key),d(c.key)):f?(b&&b(c.key),d(c.key)):(f=!0,c.advance(a))):(b&&b(null),void d(null))},g.onerror=function(){b&&b(null,g.error),e(g.error)}},e)})}function h(a){var b=this;return new j(function(c,d){b.ready().then(function(){var b=k.transaction(l.storeName,"readonly").objectStore(l.storeName),e=b.openCursor(),f=[];e.onsuccess=function(){var b=e.result;return b?(f.push(b.key),void b["continue"]()):(a&&a(f),void c(f))},e.onerror=function(){a&&a(null,e.error),d(e.error)}},d)})}function i(a,b){return a?setTimeout(function(){return a(b)},0):void 0}var j="undefined"!=typeof module&&module.exports?require("promise"):this.Promise,k=null,l={},m=m||this.indexedDB||this.webkitIndexedDB||this.mozIndexedDB||this.OIndexedDB||this.msIndexedDB;if(m){var n={_driver:"asyncStorage",_initStorage:a,getItem:b,setItem:c,removeItem:d,clear:e,length:f,key:g,keys:h};"function"==typeof define&&define.amd?define("asyncStorage",function(){return n}):"undefined"!=typeof module&&module.exports?module.exports=n:this.asyncStorage=n}}.call(this),function(){"use strict";function a(a){if(a)for(var b in a)m[b]=a[b];return l=m.name+"/",n.resolve()}function b(a){var b=this;return new n(function(c,d){b.ready().then(function(){o.clear(),a&&a(),c()},d)})}function c(a,b){var c=this;return new n(function(d,e){c.ready().then(function(){try{var c=o.getItem(l+a);c&&(c=h(c)),b&&b(c),d(c)}catch(f){b&&b(null,f),e(f)}},e)})}function d(a,b){var c=this;return new n(function(d,e){c.ready().then(function(){var c;try{c=o.key(a)}catch(e){c=null}c&&(c=c.substring(l.length)),b&&b(c),d(c)},e)})}function e(a){var b=this;return new n(function(c,d){b.ready().then(function(){for(var b=o.length,d=[],e=0;b>e;e++)d.push(o.key(e).substring(l.length));a&&a(d),c(d)},d)})}function f(a){var b=this;return new n(function(c,d){b.ready().then(function(){var b=o.length;a&&a(b),c(b)},d)})}function g(a,b){var c=this;return new n(function(d,e){c.ready().then(function(){o.removeItem(l+a),b&&b(),d()},e)})}function h(a){if(a.substring(0,r)!==q)return JSON.parse(a);for(var b=a.substring(D),c=a.substring(r,D),d=new ArrayBuffer(2*b.length),e=new Uint16Array(d),f=b.length-1;f>=0;f--)e[f]=b.charCodeAt(f);switch(c){case s:return d;case t:return new Blob([d]);case u:return new Int8Array(d);case v:return new Uint8Array(d);case w:return new Uint8ClampedArray(d);case x:return new Int16Array(d);case z:return new Uint16Array(d);case y:return new Int32Array(d);case A:return new Uint32Array(d);case B:return new Float32Array(d);case C:return new Float64Array(d);default:throw new Error("Unkown type: "+c)}}function i(a){var b="",c=new Uint16Array(a);try{b=String.fromCharCode.apply(null,c)}catch(d){for(var e=0;e<c.length;e++)b+=String.fromCharCode(c[e])}return b}function j(a,b){var c="";if(a&&(c=a.toString()),a&&("[object ArrayBuffer]"===a.toString()||a.buffer&&"[object ArrayBuffer]"===a.buffer.toString())){var d,e=q;a instanceof ArrayBuffer?(d=a,e+=s):(d=a.buffer,"[object Int8Array]"===c?e+=u:"[object Uint8Array]"===c?e+=v:"[object Uint8ClampedArray]"===c?e+=w:"[object Int16Array]"===c?e+=x:"[object Uint16Array]"===c?e+=z:"[object Int32Array]"===c?e+=y:"[object Uint32Array]"===c?e+=A:"[object Float32Array]"===c?e+=B:"[object Float64Array]"===c?e+=C:b(new Error("Failed to get type for BinaryArray"))),b(e+i(d))}else if("[object Blob]"===c){var f=new FileReader;f.onload=function(){var a=i(this.result);b(q+t+a)},f.readAsArrayBuffer(a)}else try{b(JSON.stringify(a))}catch(g){this.console&&this.console.error&&this.console.error("Couldn't convert value into a JSON string: ",a),b(null,g)}}function k(a,b,c){var d=this;return new n(function(e,f){d.ready().then(function(){void 0===b&&(b=null);var d=b;j(b,function(b,g){if(g)c&&c(null,g),f(g);else{try{o.setItem(l+a,b)}catch(h){("QuotaExceededError"===h.name||"NS_ERROR_DOM_QUOTA_REACHED"===h.name)&&(c&&c(null,h),f(h))}c&&c(d),e(d)}})},f)})}var l="",m={},n="undefined"!=typeof module&&module.exports?require("promise"):this.Promise,o=null;try{if(!(this.localStorage&&"setItem"in this.localStorage))return;o=this.localStorage}catch(p){return}var q="__lfsc__:",r=q.length,s="arbf",t="blob",u="si08",v="ui08",w="uic8",x="si16",y="si32",z="ur16",A="ui32",B="fl32",C="fl64",D=r+s.length,E={_driver:"localStorageWrapper",_initStorage:a,getItem:c,setItem:k,removeItem:g,clear:b,length:f,key:d,keys:e};"function"==typeof define&&define.amd?define("localStorageWrapper",function(){return E}):"undefined"!=typeof module&&module.exports?module.exports=E:this.localStorageWrapper=E}.call(this),function(){"use strict";function a(a){var b=this;if(a)for(var c in a)p[c]="string"!=typeof a[c]?a[c].toString():a[c];return new m(function(a,c){try{o=n(p.name,p.version,p.description,p.size)}catch(d){return b.setDriver("localStorageWrapper").then(a,c)}o.transaction(function(b){b.executeSql("CREATE TABLE IF NOT EXISTS "+p.storeName+" (id INTEGER PRIMARY KEY, key unique, value)",[],function(){a()},function(a,b){c(b)})})})}function b(a,b){var c=this;return new m(function(d,e){c.ready().then(function(){o.transaction(function(c){c.executeSql("SELECT * FROM "+p.storeName+" WHERE key = ? LIMIT 1",[a],function(a,c){var e=c.rows.length?c.rows.item(0).value:null;e&&(e=j(e)),b&&b(e),d(e)},function(a,c){b&&b(null,c),e(c)})})},e)})}function c(a,b,c){var d=this;return new m(function(e,f){d.ready().then(function(){void 0===b&&(b=null);var d=b;k(b,function(b,g){g?f(g):o.transaction(function(g){g.executeSql("INSERT OR REPLACE INTO "+p.storeName+" (key, value) VALUES (?, ?)",[a,b],function(){c&&c(d),e(d)},function(a,b){c&&c(null,b),f(b)})},function(a){a.code===a.QUOTA_ERR&&(c&&c(null,a),f(a))})})},f)})}function d(a,b){var c=this;return new m(function(d,e){c.ready().then(function(){o.transaction(function(c){c.executeSql("DELETE FROM "+p.storeName+" WHERE key = ?",[a],function(){b&&b(),d()},function(a,c){b&&b(c),e(c)})})},e)})}function e(a){var b=this;return new m(function(c,d){b.ready().then(function(){o.transaction(function(b){b.executeSql("DELETE FROM "+p.storeName,[],function(){a&&a(),c()},function(b,c){a&&a(c),d(c)})})},d)})}function f(a){var b=this;return new m(function(c,d){b.ready().then(function(){o.transaction(function(b){b.executeSql("SELECT COUNT(key) as c FROM "+p.storeName,[],function(b,d){var e=d.rows.item(0).c;a&&a(e),c(e)},function(b,c){a&&a(null,c),d(c)})})},d)})}function g(a,b){var c=this;return new m(function(d,e){c.ready().then(function(){o.transaction(function(c){c.executeSql("SELECT key FROM "+p.storeName+" WHERE id = ? LIMIT 1",[a+1],function(a,c){var e=c.rows.length?c.rows.item(0).key:null;b&&b(e),d(e)},function(a,c){b&&b(null,c),e(c)})})},e)})}function h(a){var b=this;return new m(function(c,d){b.ready().then(function(){o.transaction(function(b){b.executeSql("SELECT key FROM "+p.storeName,[],function(b,d){for(var e=d.rows.length,f=[],g=0;e>g;g++)f.push(d.rows.item(g).key);a&&a(f),c(f)},function(b,c){a&&a(null,c),d(c)})})},d)})}function i(a){var b,c=new Uint8Array(a),d="";for(b=0;b<c.length;b+=3)d+=l[c[b]>>2],d+=l[(3&c[b])<<4|c[b+1]>>4],d+=l[(15&c[b+1])<<2|c[b+2]>>6],d+=l[63&c[b+2]];return c.length%3===2?d=d.substring(0,d.length-1)+"=":c.length%3===1&&(d=d.substring(0,d.length-2)+"=="),d}function j(a){if(a.substring(0,r)!==q)return JSON.parse(a);var b,c,d,e,f,g=a.substring(D),h=a.substring(r,D),i=.75*g.length,j=g.length,k=0;"="===g[g.length-1]&&(i--,"="===g[g.length-2]&&i--);var m=new ArrayBuffer(i),n=new Uint8Array(m);for(b=0;j>b;b+=4)c=l.indexOf(g[b]),d=l.indexOf(g[b+1]),e=l.indexOf(g[b+2]),f=l.indexOf(g[b+3]),n[k++]=c<<2|d>>4,n[k++]=(15&d)<<4|e>>2,n[k++]=(3&e)<<6|63&f;switch(h){case s:return m;case t:return new Blob([m]);case u:return new Int8Array(m);case v:return new Uint8Array(m);case w:return new Uint8ClampedArray(m);case x:return new Int16Array(m);case z:return new Uint16Array(m);case y:return new Int32Array(m);case A:return new Uint32Array(m);case B:return new Float32Array(m);case C:return new Float64Array(m);default:throw new Error("Unkown type: "+h)}}function k(a,b){var c="";if(a&&(c=a.toString()),a&&("[object ArrayBuffer]"===a.toString()||a.buffer&&"[object ArrayBuffer]"===a.buffer.toString())){var d,e=q;a instanceof ArrayBuffer?(d=a,e+=s):(d=a.buffer,"[object Int8Array]"===c?e+=u:"[object Uint8Array]"===c?e+=v:"[object Uint8ClampedArray]"===c?e+=w:"[object Int16Array]"===c?e+=x:"[object Uint16Array]"===c?e+=z:"[object Int32Array]"===c?e+=y:"[object Uint32Array]"===c?e+=A:"[object Float32Array]"===c?e+=B:"[object Float64Array]"===c?e+=C:b(new Error("Failed to get type for BinaryArray"))),b(e+i(d))}else if("[object Blob]"===c){var f=new FileReader;f.onload=function(){var a=i(this.result);b(q+t+a)},f.readAsArrayBuffer(a)}else try{b(JSON.stringify(a))}catch(g){this.console&&this.console.error&&this.console.error("Couldn't convert value into a JSON string: ",a),b(null,g)}}var l="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",m="undefined"!=typeof module&&module.exports?require("promise"):this.Promise,n=this.openDatabase,o=null,p={},q="__lfsc__:",r=q.length,s="arbf",t="blob",u="si08",v="ui08",w="uic8",x="si16",y="si32",z="ur16",A="ui32",B="fl32",C="fl64",D=r+s.length;if(n){var E={_driver:"webSQLStorage",_initStorage:a,getItem:b,setItem:c,removeItem:d,clear:e,length:f,key:g,keys:h};"function"==typeof define&&define.amd?define("webSQLStorage",function(){return E}):"undefined"!=typeof module&&module.exports?module.exports=E:this.webSQLStorage=E}}.call(this),function(){"use strict";var a="undefined"!=typeof module&&module.exports?require("promise"):this.Promise,b=1,c=2,d=3,e=d;"function"==typeof define&&define.amd?e=b:"undefined"!=typeof module&&module.exports&&(e=c);var f=this,g={INDEXEDDB:"asyncStorage",LOCALSTORAGE:"localStorageWrapper",WEBSQL:"webSQLStorage",_config:{description:"",name:"localforage",size:4980736,storeName:"keyvaluepairs",version:1},config:function(a){if("object"==typeof a){if(this._ready)return new Error("Can't call config() after localforage has been used.");for(var b in a)this._config[b]=a[b];return!0}return"string"==typeof a?this._config[a]:this._config},driver:function(){return this._driver||null},_ready:!1,_driverSet:null,setDriver:function(d,g,h){var i=this,j=Array.isArray||function(a){return"[object Array]"===Object.prototype.toString.call(a)};return j(d)||"string"!=typeof d||(d=[d]),this._driverSet=new a(function(j,k){var l=i._getFirstSupportedDriver(d);if(!l){var m=new Error("No available storage method found.");return i._driverSet=a.reject(m),h&&h(m),void k(m)}if(i._ready=null,e===b)return void require([l],function(a){i._extend(a),g&&g(),j()});if(e===c){var n;switch(l){case i.INDEXEDDB:n=require("./drivers/indexeddb");break;case i.LOCALSTORAGE:n=require("./drivers/localstorage");break;case i.WEBSQL:n=require("./drivers/websql")}i._extend(n)}else i._extend(f[l]);g&&g(),j()}),this._driverSet},_getFirstSupportedDriver:function(a){if(a)for(var b=0;b<a.length;b++){var c=a[b];if(this.supports(c))return c}return null},supports:function(a){return!!h[a]},ready:function(b){var c=new a(function(a,b){g._driverSet.then(function(){null===g._ready&&(g._ready=g._initStorage(g._config)),g._ready.then(a,b)},b)});return c.then(b,b),c},_extend:function(a){for(var b in a)a.hasOwnProperty(b)&&(this[b]=a[b])}},h=function(a){var b=b||a.indexedDB||a.webkitIndexedDB||a.mozIndexedDB||a.OIndexedDB||a.msIndexedDB,c={};return c[g.WEBSQL]=!!a.openDatabase,c[g.INDEXEDDB]=!(!b||"function"!=typeof b.open||null!==b.open("_localforage_spec_test",1).onupgradeneeded),c[g.LOCALSTORAGE]=!!function(){try{return localStorage&&"function"==typeof localStorage.setItem}catch(a){return!1}}(),c}(this),i=[g.INDEXEDDB,g.WEBSQL,g.LOCALSTORAGE];g.setDriver(i),e===b?define(function(){return g}):e===c?module.exports=g:this.localforage=g}.call(this); |
/*! | ||
localForage -- Offline Storage, Improved | ||
Version 0.9.1 | ||
Version 0.9.2 | ||
http://mozilla.github.io/localForage | ||
@@ -82,5 +82,3 @@ (c) 2013-2014 Mozilla, Apache License 2.0 | ||
}; | ||
}, function(err) { | ||
reject(err) ; | ||
}); | ||
}, reject); | ||
}); | ||
@@ -127,5 +125,3 @@ } | ||
}; | ||
}, function(err) { | ||
reject(err) ; | ||
}); | ||
}, reject); | ||
}); | ||
@@ -141,10 +137,8 @@ } | ||
// We use `['delete']` instead of `.delete` because IE 8 will | ||
// throw a fit if it sees the reserved word "delete" in this | ||
// scenario. | ||
// See: https://github.com/mozilla/localForage/pull/67 | ||
// | ||
// This can be removed once we no longer care about IE 8, for | ||
// what that's worth. | ||
var req = store['delete'](key); | ||
// We use a Grunt task to make this safe for IE and some | ||
// versions of Android (including those used by Cordova). | ||
// Normally IE won't like `.delete()` and will insist on | ||
// using `['delete']()`, but we have a build step that | ||
// fixes this for us now. | ||
var req = store["delete"](key); | ||
req.onsuccess = function() { | ||
@@ -178,5 +172,3 @@ | ||
}; | ||
}, function(err) { | ||
reject(err) ; | ||
}); | ||
}, reject); | ||
}); | ||
@@ -206,5 +198,3 @@ } | ||
}; | ||
}, function(err) { | ||
reject(err) ; | ||
}); | ||
}, reject); | ||
}); | ||
@@ -236,5 +226,3 @@ } | ||
}; | ||
}, function(err) { | ||
reject(err) ; | ||
}); | ||
}, reject); | ||
}); | ||
@@ -307,5 +295,3 @@ } | ||
}; | ||
}, function(err) { | ||
reject(err) ; | ||
}); | ||
}, reject); | ||
}); | ||
@@ -338,3 +324,3 @@ } | ||
keys.push(cursor.key); | ||
cursor.continue(); | ||
cursor["continue"](); | ||
}; | ||
@@ -349,5 +335,3 @@ | ||
}; | ||
}, function(err) { | ||
reject(err) ; | ||
}); | ||
}, reject); | ||
}); | ||
@@ -458,3 +442,3 @@ } | ||
var _this = this; | ||
return new Promise(function(resolve) { | ||
return new Promise(function(resolve, reject) { | ||
_this.ready().then(function() { | ||
@@ -468,3 +452,3 @@ localStorage.clear(); | ||
resolve(); | ||
}); | ||
}, reject); | ||
}); | ||
@@ -503,3 +487,3 @@ } | ||
} | ||
}); | ||
}, reject); | ||
}); | ||
@@ -511,3 +495,3 @@ } | ||
var _this = this; | ||
return new Promise(function(resolve) { | ||
return new Promise(function(resolve, reject) { | ||
_this.ready().then(function() { | ||
@@ -530,3 +514,3 @@ var result; | ||
resolve(result); | ||
}); | ||
}, reject); | ||
}); | ||
@@ -537,3 +521,3 @@ } | ||
var _this = this; | ||
return new Promise(function(resolve) { | ||
return new Promise(function(resolve, reject) { | ||
_this.ready().then(function() { | ||
@@ -552,3 +536,3 @@ var length = localStorage.length; | ||
resolve(keys); | ||
}); | ||
}, reject); | ||
}); | ||
@@ -560,3 +544,3 @@ } | ||
var _this = this; | ||
return new Promise(function(resolve) { | ||
return new Promise(function(resolve, reject) { | ||
_this.ready().then(function() { | ||
@@ -570,3 +554,3 @@ var result = localStorage.length; | ||
resolve(result); | ||
}); | ||
}, reject); | ||
}); | ||
@@ -578,3 +562,3 @@ } | ||
var _this = this; | ||
return new Promise(function(resolve) { | ||
return new Promise(function(resolve, reject) { | ||
_this.ready().then(function() { | ||
@@ -588,3 +572,3 @@ localStorage.removeItem(keyPrefix + key); | ||
resolve(); | ||
}); | ||
}, reject); | ||
}); | ||
@@ -795,3 +779,3 @@ } | ||
}); | ||
}); | ||
}, reject); | ||
}); | ||
@@ -881,3 +865,3 @@ } | ||
return new Promise(function(resolve) { | ||
return new Promise(function(resolve, reject) { | ||
// Open the database; the openDatabase API will automatically | ||
@@ -889,3 +873,3 @@ // create it for us if it doesn't exist. | ||
} catch (e) { | ||
return _this.setDriver('localStorageWrapper').then(resolve); | ||
return _this.setDriver('localStorageWrapper').then(resolve, reject); | ||
} | ||
@@ -898,3 +882,5 @@ | ||
resolve(); | ||
}, null); | ||
}, function(t, error) { | ||
reject(error); | ||
}); | ||
}); | ||
@@ -932,3 +918,3 @@ }); | ||
}); | ||
}); | ||
}, reject); | ||
}); | ||
@@ -989,3 +975,3 @@ } | ||
}); | ||
}); | ||
}, reject); | ||
}); | ||
@@ -1014,3 +1000,3 @@ } | ||
}); | ||
}); | ||
}, reject); | ||
}); | ||
@@ -1040,3 +1026,3 @@ } | ||
}); | ||
}); | ||
}, reject); | ||
}); | ||
@@ -1070,3 +1056,3 @@ } | ||
}); | ||
}); | ||
}, reject); | ||
}); | ||
@@ -1104,3 +1090,3 @@ } | ||
}); | ||
}); | ||
}, reject); | ||
}); | ||
@@ -1136,3 +1122,3 @@ } | ||
}); | ||
}); | ||
}, reject); | ||
}); | ||
@@ -1367,24 +1353,2 @@ } | ||
// Initialize IndexedDB; fall back to vendor-prefixed versions if needed. | ||
var indexedDB = indexedDB || this.indexedDB || this.webkitIndexedDB || | ||
this.mozIndexedDB || this.OIndexedDB || | ||
this.msIndexedDB; | ||
var supportsIndexedDB = indexedDB && | ||
typeof indexedDB.open === 'function' && | ||
indexedDB.open('_localforage_spec_test', 1) | ||
.onupgradeneeded === null; | ||
// Check for WebSQL. | ||
var openDatabase = this.openDatabase; | ||
// Check for localStorage. | ||
var supportsLocalStorage = (function() { | ||
try { | ||
return localStorage && typeof localStorage.setItem === 'function'; | ||
} catch (e) { | ||
return false; | ||
} | ||
})(); | ||
// The actual localForage object that we expose as a module or via a | ||
@@ -1444,17 +1408,25 @@ // global. It's extended by pulling in one of our other libraries. | ||
setDriver: function(driverName, callback, errorCallback) { | ||
setDriver: function(drivers, callback, errorCallback) { | ||
var self = this; | ||
var isArray = Array.isArray || function(arg) { | ||
return Object.prototype.toString.call(arg) === '[object Array]'; | ||
}; | ||
if (!isArray(drivers) && typeof drivers === 'string') { | ||
drivers = [drivers]; | ||
} | ||
this._driverSet = new Promise(function(resolve, reject) { | ||
if ((!supportsIndexedDB && | ||
driverName === localForage.INDEXEDDB) || | ||
(!openDatabase && driverName === localForage.WEBSQL) || | ||
(!supportsLocalStorage && | ||
driverName === localForage.LOCALSTORAGE)) { | ||
var driverName = self._getFirstSupportedDriver(drivers); | ||
if (!driverName) { | ||
var error = new Error('No available storage method found.'); | ||
self._driverSet = Promise.reject(error); | ||
if (errorCallback) { | ||
errorCallback(); | ||
errorCallback(error); | ||
} | ||
reject(localForage); | ||
reject(error); | ||
@@ -1508,4 +1480,22 @@ return; | ||
_getFirstSupportedDriver: function(drivers) { | ||
if (drivers) { | ||
for (var i = 0; i < drivers.length; i++) { | ||
var driver = drivers[i]; | ||
if (this.supports(driver)) { | ||
return driver; | ||
} | ||
} | ||
} | ||
return null; | ||
}, | ||
supports: function(driverName) { | ||
return !!driverSupport[driverName]; | ||
}, | ||
ready: function(callback) { | ||
var ready = new Promise(function(resolve) { | ||
var ready = new Promise(function(resolve, reject) { | ||
localForage._driverSet.then(function() { | ||
@@ -1517,4 +1507,4 @@ if (localForage._ready === null) { | ||
localForage._ready.then(resolve); | ||
}); | ||
localForage._ready.then(resolve, reject); | ||
}, reject); | ||
}); | ||
@@ -1536,4 +1526,2 @@ | ||
// Select our storage library. | ||
var storageLibrary; | ||
// Check to see if IndexedDB is available and if it is the latest | ||
@@ -1544,24 +1532,39 @@ // implementation; it's our preferred backend library. We use "_spec_test" | ||
// See: https://github.com/mozilla/localForage/issues/128 | ||
if (supportsIndexedDB) { | ||
storageLibrary = localForage.INDEXEDDB; | ||
} else if (openDatabase) { // WebSQL is available, so we'll use that. | ||
storageLibrary = localForage.WEBSQL; | ||
} else if (supportsLocalStorage) { // If nothing else is available, | ||
// we try to use localStorage. | ||
storageLibrary = localForage.LOCALSTORAGE; | ||
} | ||
var driverSupport = (function(_this) { | ||
// Initialize IndexedDB; fall back to vendor-prefixed versions | ||
// if needed. | ||
var indexedDB = indexedDB || _this.indexedDB || _this.webkitIndexedDB || | ||
_this.mozIndexedDB || _this.OIndexedDB || | ||
_this.msIndexedDB; | ||
// If window.localForageConfig is set, use it for configuration. | ||
if (this.localForageConfig) { | ||
localForage.config = this.localForageConfig; | ||
} | ||
var result = {}; | ||
// Set the (default) driver, or report the error. | ||
if (storageLibrary) { | ||
localForage.setDriver(storageLibrary); | ||
} else { | ||
localForage._ready = Promise.reject( | ||
new Error('No available storage method found.')); | ||
} | ||
result[localForage.WEBSQL] = !!_this.openDatabase; | ||
result[localForage.INDEXEDDB] = !!( | ||
indexedDB && | ||
typeof indexedDB.open === 'function' && | ||
indexedDB.open('_localforage_spec_test', 1) | ||
.onupgradeneeded === null | ||
); | ||
result[localForage.LOCALSTORAGE] = !!(function() { | ||
try { | ||
return (localStorage && | ||
typeof localStorage.setItem === 'function'); | ||
} catch (e) { | ||
return false; | ||
} | ||
})(); | ||
return result; | ||
})(this); | ||
var driverTestOrder = [ | ||
localForage.INDEXEDDB, | ||
localForage.WEBSQL, | ||
localForage.LOCALSTORAGE | ||
]; | ||
localForage.setDriver(driverTestOrder); | ||
// We allow localForage to be declared as a module or as a library | ||
@@ -1568,0 +1571,0 @@ // available without AMD/require.js. |
@@ -1,1 +0,1 @@ | ||
(function(){"use strict";function a(a){if(a)for(var b in a)l[b]=a[b];return new j(function(a,b){var c=m.open(l.name,l.version);c.onerror=function(){b(c.error)},c.onupgradeneeded=function(){c.result.createObjectStore(l.storeName)},c.onsuccess=function(){k=c.result,a()}})}function b(a,b){var c=this;return new j(function(d,e){c.ready().then(function(){var c=k.transaction(l.storeName,"readonly").objectStore(l.storeName),f=c.get(a);f.onsuccess=function(){var a=f.result;void 0===a&&(a=null),i(b,a),d(a)},f.onerror=function(){b&&b(null,f.error),e(f.error)}},function(a){e(a)})})}function c(a,b,c){var d=this;return new j(function(e,f){d.ready().then(function(){var d=k.transaction(l.storeName,"readwrite").objectStore(l.storeName);null===b&&(b=void 0);var g=d.put(b,a);g.onsuccess=function(){void 0===b&&(b=null),i(c,b),e(b)},g.onerror=function(){c&&c(null,g.error),f(g.error)}},function(a){f(a)})})}function d(a,b){var c=this;return new j(function(d,e){c.ready().then(function(){var c=k.transaction(l.storeName,"readwrite").objectStore(l.storeName),f=c["delete"](a);f.onsuccess=function(){i(b),d()},f.onerror=function(){b&&b(f.error),e(f.error)},f.onabort=function(a){var c=a.target.error;"QuotaExceededError"===c&&(b&&b(c),e(c))}},function(a){e(a)})})}function e(a){var b=this;return new j(function(c,d){b.ready().then(function(){var b=k.transaction(l.storeName,"readwrite").objectStore(l.storeName),e=b.clear();e.onsuccess=function(){i(a),c()},e.onerror=function(){a&&a(null,e.error),d(e.error)}},function(a){d(a)})})}function f(a){var b=this;return new j(function(c,d){b.ready().then(function(){var b=k.transaction(l.storeName,"readonly").objectStore(l.storeName),e=b.count();e.onsuccess=function(){a&&a(e.result),c(e.result)},e.onerror=function(){a&&a(null,e.error),d(e.error)}},function(a){d(a)})})}function g(a,b){var c=this;return new j(function(d,e){return 0>a?(b&&b(null),void d(null)):void c.ready().then(function(){var c=k.transaction(l.storeName,"readonly").objectStore(l.storeName),f=!1,g=c.openCursor();g.onsuccess=function(){var c=g.result;return c?void(0===a?(b&&b(c.key),d(c.key)):f?(b&&b(c.key),d(c.key)):(f=!0,c.advance(a))):(b&&b(null),void d(null))},g.onerror=function(){b&&b(null,g.error),e(g.error)}},function(a){e(a)})})}function h(a){var b=this;return new j(function(c,d){b.ready().then(function(){var b=k.transaction(l.storeName,"readonly").objectStore(l.storeName),e=b.openCursor(),f=[];e.onsuccess=function(){var b=e.result;return b?(f.push(b.key),void b.continue()):(a&&a(f),void c(f))},e.onerror=function(){a&&a(null,e.error),d(e.error)}},function(a){d(a)})})}function i(a,b){return a?setTimeout(function(){return a(b)},0):void 0}var j="undefined"!=typeof module&&module.exports?require("promise"):this.Promise,k=null,l={},m=m||this.indexedDB||this.webkitIndexedDB||this.mozIndexedDB||this.OIndexedDB||this.msIndexedDB;if(m){var n={_driver:"asyncStorage",_initStorage:a,getItem:b,setItem:c,removeItem:d,clear:e,length:f,key:g,keys:h};"function"==typeof define&&define.amd?define("asyncStorage",function(){return n}):"undefined"!=typeof module&&module.exports?module.exports=n:this.asyncStorage=n}}).call(this),function(){"use strict";function a(a){if(a)for(var b in a)m[b]=a[b];return l=m.name+"/",n.resolve()}function b(a){var b=this;return new n(function(c){b.ready().then(function(){o.clear(),a&&a(),c()})})}function c(a,b){var c=this;return new n(function(d,e){c.ready().then(function(){try{var c=o.getItem(l+a);c&&(c=h(c)),b&&b(c),d(c)}catch(f){b&&b(null,f),e(f)}})})}function d(a,b){var c=this;return new n(function(d){c.ready().then(function(){var c;try{c=o.key(a)}catch(e){c=null}c&&(c=c.substring(l.length)),b&&b(c),d(c)})})}function e(a){var b=this;return new n(function(c){b.ready().then(function(){for(var b=o.length,d=[],e=0;b>e;e++)d.push(o.key(e).substring(l.length));a&&a(d),c(d)})})}function f(a){var b=this;return new n(function(c){b.ready().then(function(){var b=o.length;a&&a(b),c(b)})})}function g(a,b){var c=this;return new n(function(d){c.ready().then(function(){o.removeItem(l+a),b&&b(),d()})})}function h(a){if(a.substring(0,r)!==q)return JSON.parse(a);for(var b=a.substring(D),c=a.substring(r,D),d=new ArrayBuffer(2*b.length),e=new Uint16Array(d),f=b.length-1;f>=0;f--)e[f]=b.charCodeAt(f);switch(c){case s:return d;case t:return new Blob([d]);case u:return new Int8Array(d);case v:return new Uint8Array(d);case w:return new Uint8ClampedArray(d);case x:return new Int16Array(d);case z:return new Uint16Array(d);case y:return new Int32Array(d);case A:return new Uint32Array(d);case B:return new Float32Array(d);case C:return new Float64Array(d);default:throw new Error("Unkown type: "+c)}}function i(a){var b="",c=new Uint16Array(a);try{b=String.fromCharCode.apply(null,c)}catch(d){for(var e=0;e<c.length;e++)b+=String.fromCharCode(c[e])}return b}function j(a,b){var c="";if(a&&(c=a.toString()),a&&("[object ArrayBuffer]"===a.toString()||a.buffer&&"[object ArrayBuffer]"===a.buffer.toString())){var d,e=q;a instanceof ArrayBuffer?(d=a,e+=s):(d=a.buffer,"[object Int8Array]"===c?e+=u:"[object Uint8Array]"===c?e+=v:"[object Uint8ClampedArray]"===c?e+=w:"[object Int16Array]"===c?e+=x:"[object Uint16Array]"===c?e+=z:"[object Int32Array]"===c?e+=y:"[object Uint32Array]"===c?e+=A:"[object Float32Array]"===c?e+=B:"[object Float64Array]"===c?e+=C:b(new Error("Failed to get type for BinaryArray"))),b(e+i(d))}else if("[object Blob]"===c){var f=new FileReader;f.onload=function(){var a=i(this.result);b(q+t+a)},f.readAsArrayBuffer(a)}else try{b(JSON.stringify(a))}catch(g){this.console&&this.console.error&&this.console.error("Couldn't convert value into a JSON string: ",a),b(null,g)}}function k(a,b,c){var d=this;return new n(function(e,f){d.ready().then(function(){void 0===b&&(b=null);var d=b;j(b,function(b,g){if(g)c&&c(null,g),f(g);else{try{o.setItem(l+a,b)}catch(h){("QuotaExceededError"===h.name||"NS_ERROR_DOM_QUOTA_REACHED"===h.name)&&(c&&c(null,h),f(h))}c&&c(d),e(d)}})})})}var l="",m={},n="undefined"!=typeof module&&module.exports?require("promise"):this.Promise,o=null;try{if(!(this.localStorage&&"setItem"in this.localStorage))return;o=this.localStorage}catch(p){return}var q="__lfsc__:",r=q.length,s="arbf",t="blob",u="si08",v="ui08",w="uic8",x="si16",y="si32",z="ur16",A="ui32",B="fl32",C="fl64",D=r+s.length,E={_driver:"localStorageWrapper",_initStorage:a,getItem:c,setItem:k,removeItem:g,clear:b,length:f,key:d,keys:e};"function"==typeof define&&define.amd?define("localStorageWrapper",function(){return E}):"undefined"!=typeof module&&module.exports?module.exports=E:this.localStorageWrapper=E}.call(this),function(){"use strict";function a(a){var b=this;if(a)for(var c in a)p[c]="string"!=typeof a[c]?a[c].toString():a[c];return new m(function(a){try{o=n(p.name,p.version,p.description,p.size)}catch(c){return b.setDriver("localStorageWrapper").then(a)}o.transaction(function(b){b.executeSql("CREATE TABLE IF NOT EXISTS "+p.storeName+" (id INTEGER PRIMARY KEY, key unique, value)",[],function(){a()},null)})})}function b(a,b){var c=this;return new m(function(d,e){c.ready().then(function(){o.transaction(function(c){c.executeSql("SELECT * FROM "+p.storeName+" WHERE key = ? LIMIT 1",[a],function(a,c){var e=c.rows.length?c.rows.item(0).value:null;e&&(e=j(e)),b&&b(e),d(e)},function(a,c){b&&b(null,c),e(c)})})})})}function c(a,b,c){var d=this;return new m(function(e,f){d.ready().then(function(){void 0===b&&(b=null);var d=b;k(b,function(b,g){g?f(g):o.transaction(function(g){g.executeSql("INSERT OR REPLACE INTO "+p.storeName+" (key, value) VALUES (?, ?)",[a,b],function(){c&&c(d),e(d)},function(a,b){c&&c(null,b),f(b)})},function(a){a.code===a.QUOTA_ERR&&(c&&c(null,a),f(a))})})})})}function d(a,b){var c=this;return new m(function(d,e){c.ready().then(function(){o.transaction(function(c){c.executeSql("DELETE FROM "+p.storeName+" WHERE key = ?",[a],function(){b&&b(),d()},function(a,c){b&&b(c),e(c)})})})})}function e(a){var b=this;return new m(function(c,d){b.ready().then(function(){o.transaction(function(b){b.executeSql("DELETE FROM "+p.storeName,[],function(){a&&a(),c()},function(b,c){a&&a(c),d(c)})})})})}function f(a){var b=this;return new m(function(c,d){b.ready().then(function(){o.transaction(function(b){b.executeSql("SELECT COUNT(key) as c FROM "+p.storeName,[],function(b,d){var e=d.rows.item(0).c;a&&a(e),c(e)},function(b,c){a&&a(null,c),d(c)})})})})}function g(a,b){var c=this;return new m(function(d,e){c.ready().then(function(){o.transaction(function(c){c.executeSql("SELECT key FROM "+p.storeName+" WHERE id = ? LIMIT 1",[a+1],function(a,c){var e=c.rows.length?c.rows.item(0).key:null;b&&b(e),d(e)},function(a,c){b&&b(null,c),e(c)})})})})}function h(a){var b=this;return new m(function(c,d){b.ready().then(function(){o.transaction(function(b){b.executeSql("SELECT key FROM "+p.storeName,[],function(b,d){for(var e=d.rows.length,f=[],g=0;e>g;g++)f.push(d.rows.item(g).key);a&&a(f),c(f)},function(b,c){a&&a(null,c),d(c)})})})})}function i(a){var b,c=new Uint8Array(a),d="";for(b=0;b<c.length;b+=3)d+=l[c[b]>>2],d+=l[(3&c[b])<<4|c[b+1]>>4],d+=l[(15&c[b+1])<<2|c[b+2]>>6],d+=l[63&c[b+2]];return c.length%3===2?d=d.substring(0,d.length-1)+"=":c.length%3===1&&(d=d.substring(0,d.length-2)+"=="),d}function j(a){if(a.substring(0,r)!==q)return JSON.parse(a);var b,c,d,e,f,g=a.substring(D),h=a.substring(r,D),i=.75*g.length,j=g.length,k=0;"="===g[g.length-1]&&(i--,"="===g[g.length-2]&&i--);var m=new ArrayBuffer(i),n=new Uint8Array(m);for(b=0;j>b;b+=4)c=l.indexOf(g[b]),d=l.indexOf(g[b+1]),e=l.indexOf(g[b+2]),f=l.indexOf(g[b+3]),n[k++]=c<<2|d>>4,n[k++]=(15&d)<<4|e>>2,n[k++]=(3&e)<<6|63&f;switch(h){case s:return m;case t:return new Blob([m]);case u:return new Int8Array(m);case v:return new Uint8Array(m);case w:return new Uint8ClampedArray(m);case x:return new Int16Array(m);case z:return new Uint16Array(m);case y:return new Int32Array(m);case A:return new Uint32Array(m);case B:return new Float32Array(m);case C:return new Float64Array(m);default:throw new Error("Unkown type: "+h)}}function k(a,b){var c="";if(a&&(c=a.toString()),a&&("[object ArrayBuffer]"===a.toString()||a.buffer&&"[object ArrayBuffer]"===a.buffer.toString())){var d,e=q;a instanceof ArrayBuffer?(d=a,e+=s):(d=a.buffer,"[object Int8Array]"===c?e+=u:"[object Uint8Array]"===c?e+=v:"[object Uint8ClampedArray]"===c?e+=w:"[object Int16Array]"===c?e+=x:"[object Uint16Array]"===c?e+=z:"[object Int32Array]"===c?e+=y:"[object Uint32Array]"===c?e+=A:"[object Float32Array]"===c?e+=B:"[object Float64Array]"===c?e+=C:b(new Error("Failed to get type for BinaryArray"))),b(e+i(d))}else if("[object Blob]"===c){var f=new FileReader;f.onload=function(){var a=i(this.result);b(q+t+a)},f.readAsArrayBuffer(a)}else try{b(JSON.stringify(a))}catch(g){this.console&&this.console.error&&this.console.error("Couldn't convert value into a JSON string: ",a),b(null,g)}}var l="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",m="undefined"!=typeof module&&module.exports?require("promise"):this.Promise,n=this.openDatabase,o=null,p={},q="__lfsc__:",r=q.length,s="arbf",t="blob",u="si08",v="ui08",w="uic8",x="si16",y="si32",z="ur16",A="ui32",B="fl32",C="fl64",D=r+s.length;if(n){var E={_driver:"webSQLStorage",_initStorage:a,getItem:b,setItem:c,removeItem:d,clear:e,length:f,key:g,keys:h};"function"==typeof define&&define.amd?define("webSQLStorage",function(){return E}):"undefined"!=typeof module&&module.exports?module.exports=E:this.webSQLStorage=E}}.call(this),function(){"use strict";var a="undefined"!=typeof module&&module.exports?require("promise"):this.Promise,b=1,c=2,d=3,e=d;"function"==typeof define&&define.amd?e=b:"undefined"!=typeof module&&module.exports&&(e=c);var f,g=g||this.indexedDB||this.webkitIndexedDB||this.mozIndexedDB||this.OIndexedDB||this.msIndexedDB,h=g&&"function"==typeof g.open&&null===g.open("_localforage_spec_test",1).onupgradeneeded,i=this.openDatabase,j=function(){try{return localStorage&&"function"==typeof localStorage.setItem}catch(a){return!1}}(),k=this,l={INDEXEDDB:"asyncStorage",LOCALSTORAGE:"localStorageWrapper",WEBSQL:"webSQLStorage",_config:{description:"",name:"localforage",size:4980736,storeName:"keyvaluepairs",version:1},config:function(a){if("object"==typeof a){if(this._ready)return new Error("Can't call config() after localforage has been used.");for(var b in a)this._config[b]=a[b];return!0}return"string"==typeof a?this._config[a]:this._config},driver:function(){return this._driver||null},_ready:!1,_driverSet:null,setDriver:function(d,f,g){var m=this;return this._driverSet=new a(function(a,n){if(!h&&d===l.INDEXEDDB||!i&&d===l.WEBSQL||!j&&d===l.LOCALSTORAGE)return g&&g(),void n(l);if(m._ready=null,e===b)return void require([d],function(b){m._extend(b),f&&f(),a()});if(e===c){var o;switch(d){case m.INDEXEDDB:o=require("./drivers/indexeddb");break;case m.LOCALSTORAGE:o=require("./drivers/localstorage");break;case m.WEBSQL:o=require("./drivers/websql")}m._extend(o)}else m._extend(k[d]);f&&f(),a()}),this._driverSet},ready:function(b){var c=new a(function(a){l._driverSet.then(function(){null===l._ready&&(l._ready=l._initStorage(l._config)),l._ready.then(a)})});return c.then(b,b),c},_extend:function(a){for(var b in a)a.hasOwnProperty(b)&&(this[b]=a[b])}};h?f=l.INDEXEDDB:i?f=l.WEBSQL:j&&(f=l.LOCALSTORAGE),this.localForageConfig&&(l.config=this.localForageConfig),f?l.setDriver(f):l._ready=a.reject(new Error("No available storage method found.")),e===b?define(function(){return l}):e===c?module.exports=l:this.localforage=l}.call(this); | ||
(function(){"use strict";function a(a){if(a)for(var b in a)l[b]=a[b];return new j(function(a,b){var c=m.open(l.name,l.version);c.onerror=function(){b(c.error)},c.onupgradeneeded=function(){c.result.createObjectStore(l.storeName)},c.onsuccess=function(){k=c.result,a()}})}function b(a,b){var c=this;return new j(function(d,e){c.ready().then(function(){var c=k.transaction(l.storeName,"readonly").objectStore(l.storeName),f=c.get(a);f.onsuccess=function(){var a=f.result;void 0===a&&(a=null),i(b,a),d(a)},f.onerror=function(){b&&b(null,f.error),e(f.error)}},e)})}function c(a,b,c){var d=this;return new j(function(e,f){d.ready().then(function(){var d=k.transaction(l.storeName,"readwrite").objectStore(l.storeName);null===b&&(b=void 0);var g=d.put(b,a);g.onsuccess=function(){void 0===b&&(b=null),i(c,b),e(b)},g.onerror=function(){c&&c(null,g.error),f(g.error)}},f)})}function d(a,b){var c=this;return new j(function(d,e){c.ready().then(function(){var c=k.transaction(l.storeName,"readwrite").objectStore(l.storeName),f=c["delete"](a);f.onsuccess=function(){i(b),d()},f.onerror=function(){b&&b(f.error),e(f.error)},f.onabort=function(a){var c=a.target.error;"QuotaExceededError"===c&&(b&&b(c),e(c))}},e)})}function e(a){var b=this;return new j(function(c,d){b.ready().then(function(){var b=k.transaction(l.storeName,"readwrite").objectStore(l.storeName),e=b.clear();e.onsuccess=function(){i(a),c()},e.onerror=function(){a&&a(null,e.error),d(e.error)}},d)})}function f(a){var b=this;return new j(function(c,d){b.ready().then(function(){var b=k.transaction(l.storeName,"readonly").objectStore(l.storeName),e=b.count();e.onsuccess=function(){a&&a(e.result),c(e.result)},e.onerror=function(){a&&a(null,e.error),d(e.error)}},d)})}function g(a,b){var c=this;return new j(function(d,e){return 0>a?(b&&b(null),void d(null)):void c.ready().then(function(){var c=k.transaction(l.storeName,"readonly").objectStore(l.storeName),f=!1,g=c.openCursor();g.onsuccess=function(){var c=g.result;return c?void(0===a?(b&&b(c.key),d(c.key)):f?(b&&b(c.key),d(c.key)):(f=!0,c.advance(a))):(b&&b(null),void d(null))},g.onerror=function(){b&&b(null,g.error),e(g.error)}},e)})}function h(a){var b=this;return new j(function(c,d){b.ready().then(function(){var b=k.transaction(l.storeName,"readonly").objectStore(l.storeName),e=b.openCursor(),f=[];e.onsuccess=function(){var b=e.result;return b?(f.push(b.key),void b["continue"]()):(a&&a(f),void c(f))},e.onerror=function(){a&&a(null,e.error),d(e.error)}},d)})}function i(a,b){return a?setTimeout(function(){return a(b)},0):void 0}var j="undefined"!=typeof module&&module.exports?require("promise"):this.Promise,k=null,l={},m=m||this.indexedDB||this.webkitIndexedDB||this.mozIndexedDB||this.OIndexedDB||this.msIndexedDB;if(m){var n={_driver:"asyncStorage",_initStorage:a,getItem:b,setItem:c,removeItem:d,clear:e,length:f,key:g,keys:h};"function"==typeof define&&define.amd?define("asyncStorage",function(){return n}):"undefined"!=typeof module&&module.exports?module.exports=n:this.asyncStorage=n}}).call(this),function(){"use strict";function a(a){if(a)for(var b in a)m[b]=a[b];return l=m.name+"/",n.resolve()}function b(a){var b=this;return new n(function(c,d){b.ready().then(function(){o.clear(),a&&a(),c()},d)})}function c(a,b){var c=this;return new n(function(d,e){c.ready().then(function(){try{var c=o.getItem(l+a);c&&(c=h(c)),b&&b(c),d(c)}catch(f){b&&b(null,f),e(f)}},e)})}function d(a,b){var c=this;return new n(function(d,e){c.ready().then(function(){var c;try{c=o.key(a)}catch(e){c=null}c&&(c=c.substring(l.length)),b&&b(c),d(c)},e)})}function e(a){var b=this;return new n(function(c,d){b.ready().then(function(){for(var b=o.length,d=[],e=0;b>e;e++)d.push(o.key(e).substring(l.length));a&&a(d),c(d)},d)})}function f(a){var b=this;return new n(function(c,d){b.ready().then(function(){var b=o.length;a&&a(b),c(b)},d)})}function g(a,b){var c=this;return new n(function(d,e){c.ready().then(function(){o.removeItem(l+a),b&&b(),d()},e)})}function h(a){if(a.substring(0,r)!==q)return JSON.parse(a);for(var b=a.substring(D),c=a.substring(r,D),d=new ArrayBuffer(2*b.length),e=new Uint16Array(d),f=b.length-1;f>=0;f--)e[f]=b.charCodeAt(f);switch(c){case s:return d;case t:return new Blob([d]);case u:return new Int8Array(d);case v:return new Uint8Array(d);case w:return new Uint8ClampedArray(d);case x:return new Int16Array(d);case z:return new Uint16Array(d);case y:return new Int32Array(d);case A:return new Uint32Array(d);case B:return new Float32Array(d);case C:return new Float64Array(d);default:throw new Error("Unkown type: "+c)}}function i(a){var b="",c=new Uint16Array(a);try{b=String.fromCharCode.apply(null,c)}catch(d){for(var e=0;e<c.length;e++)b+=String.fromCharCode(c[e])}return b}function j(a,b){var c="";if(a&&(c=a.toString()),a&&("[object ArrayBuffer]"===a.toString()||a.buffer&&"[object ArrayBuffer]"===a.buffer.toString())){var d,e=q;a instanceof ArrayBuffer?(d=a,e+=s):(d=a.buffer,"[object Int8Array]"===c?e+=u:"[object Uint8Array]"===c?e+=v:"[object Uint8ClampedArray]"===c?e+=w:"[object Int16Array]"===c?e+=x:"[object Uint16Array]"===c?e+=z:"[object Int32Array]"===c?e+=y:"[object Uint32Array]"===c?e+=A:"[object Float32Array]"===c?e+=B:"[object Float64Array]"===c?e+=C:b(new Error("Failed to get type for BinaryArray"))),b(e+i(d))}else if("[object Blob]"===c){var f=new FileReader;f.onload=function(){var a=i(this.result);b(q+t+a)},f.readAsArrayBuffer(a)}else try{b(JSON.stringify(a))}catch(g){this.console&&this.console.error&&this.console.error("Couldn't convert value into a JSON string: ",a),b(null,g)}}function k(a,b,c){var d=this;return new n(function(e,f){d.ready().then(function(){void 0===b&&(b=null);var d=b;j(b,function(b,g){if(g)c&&c(null,g),f(g);else{try{o.setItem(l+a,b)}catch(h){("QuotaExceededError"===h.name||"NS_ERROR_DOM_QUOTA_REACHED"===h.name)&&(c&&c(null,h),f(h))}c&&c(d),e(d)}})},f)})}var l="",m={},n="undefined"!=typeof module&&module.exports?require("promise"):this.Promise,o=null;try{if(!(this.localStorage&&"setItem"in this.localStorage))return;o=this.localStorage}catch(p){return}var q="__lfsc__:",r=q.length,s="arbf",t="blob",u="si08",v="ui08",w="uic8",x="si16",y="si32",z="ur16",A="ui32",B="fl32",C="fl64",D=r+s.length,E={_driver:"localStorageWrapper",_initStorage:a,getItem:c,setItem:k,removeItem:g,clear:b,length:f,key:d,keys:e};"function"==typeof define&&define.amd?define("localStorageWrapper",function(){return E}):"undefined"!=typeof module&&module.exports?module.exports=E:this.localStorageWrapper=E}.call(this),function(){"use strict";function a(a){var b=this;if(a)for(var c in a)p[c]="string"!=typeof a[c]?a[c].toString():a[c];return new m(function(a,c){try{o=n(p.name,p.version,p.description,p.size)}catch(d){return b.setDriver("localStorageWrapper").then(a,c)}o.transaction(function(b){b.executeSql("CREATE TABLE IF NOT EXISTS "+p.storeName+" (id INTEGER PRIMARY KEY, key unique, value)",[],function(){a()},function(a,b){c(b)})})})}function b(a,b){var c=this;return new m(function(d,e){c.ready().then(function(){o.transaction(function(c){c.executeSql("SELECT * FROM "+p.storeName+" WHERE key = ? LIMIT 1",[a],function(a,c){var e=c.rows.length?c.rows.item(0).value:null;e&&(e=j(e)),b&&b(e),d(e)},function(a,c){b&&b(null,c),e(c)})})},e)})}function c(a,b,c){var d=this;return new m(function(e,f){d.ready().then(function(){void 0===b&&(b=null);var d=b;k(b,function(b,g){g?f(g):o.transaction(function(g){g.executeSql("INSERT OR REPLACE INTO "+p.storeName+" (key, value) VALUES (?, ?)",[a,b],function(){c&&c(d),e(d)},function(a,b){c&&c(null,b),f(b)})},function(a){a.code===a.QUOTA_ERR&&(c&&c(null,a),f(a))})})},f)})}function d(a,b){var c=this;return new m(function(d,e){c.ready().then(function(){o.transaction(function(c){c.executeSql("DELETE FROM "+p.storeName+" WHERE key = ?",[a],function(){b&&b(),d()},function(a,c){b&&b(c),e(c)})})},e)})}function e(a){var b=this;return new m(function(c,d){b.ready().then(function(){o.transaction(function(b){b.executeSql("DELETE FROM "+p.storeName,[],function(){a&&a(),c()},function(b,c){a&&a(c),d(c)})})},d)})}function f(a){var b=this;return new m(function(c,d){b.ready().then(function(){o.transaction(function(b){b.executeSql("SELECT COUNT(key) as c FROM "+p.storeName,[],function(b,d){var e=d.rows.item(0).c;a&&a(e),c(e)},function(b,c){a&&a(null,c),d(c)})})},d)})}function g(a,b){var c=this;return new m(function(d,e){c.ready().then(function(){o.transaction(function(c){c.executeSql("SELECT key FROM "+p.storeName+" WHERE id = ? LIMIT 1",[a+1],function(a,c){var e=c.rows.length?c.rows.item(0).key:null;b&&b(e),d(e)},function(a,c){b&&b(null,c),e(c)})})},e)})}function h(a){var b=this;return new m(function(c,d){b.ready().then(function(){o.transaction(function(b){b.executeSql("SELECT key FROM "+p.storeName,[],function(b,d){for(var e=d.rows.length,f=[],g=0;e>g;g++)f.push(d.rows.item(g).key);a&&a(f),c(f)},function(b,c){a&&a(null,c),d(c)})})},d)})}function i(a){var b,c=new Uint8Array(a),d="";for(b=0;b<c.length;b+=3)d+=l[c[b]>>2],d+=l[(3&c[b])<<4|c[b+1]>>4],d+=l[(15&c[b+1])<<2|c[b+2]>>6],d+=l[63&c[b+2]];return c.length%3===2?d=d.substring(0,d.length-1)+"=":c.length%3===1&&(d=d.substring(0,d.length-2)+"=="),d}function j(a){if(a.substring(0,r)!==q)return JSON.parse(a);var b,c,d,e,f,g=a.substring(D),h=a.substring(r,D),i=.75*g.length,j=g.length,k=0;"="===g[g.length-1]&&(i--,"="===g[g.length-2]&&i--);var m=new ArrayBuffer(i),n=new Uint8Array(m);for(b=0;j>b;b+=4)c=l.indexOf(g[b]),d=l.indexOf(g[b+1]),e=l.indexOf(g[b+2]),f=l.indexOf(g[b+3]),n[k++]=c<<2|d>>4,n[k++]=(15&d)<<4|e>>2,n[k++]=(3&e)<<6|63&f;switch(h){case s:return m;case t:return new Blob([m]);case u:return new Int8Array(m);case v:return new Uint8Array(m);case w:return new Uint8ClampedArray(m);case x:return new Int16Array(m);case z:return new Uint16Array(m);case y:return new Int32Array(m);case A:return new Uint32Array(m);case B:return new Float32Array(m);case C:return new Float64Array(m);default:throw new Error("Unkown type: "+h)}}function k(a,b){var c="";if(a&&(c=a.toString()),a&&("[object ArrayBuffer]"===a.toString()||a.buffer&&"[object ArrayBuffer]"===a.buffer.toString())){var d,e=q;a instanceof ArrayBuffer?(d=a,e+=s):(d=a.buffer,"[object Int8Array]"===c?e+=u:"[object Uint8Array]"===c?e+=v:"[object Uint8ClampedArray]"===c?e+=w:"[object Int16Array]"===c?e+=x:"[object Uint16Array]"===c?e+=z:"[object Int32Array]"===c?e+=y:"[object Uint32Array]"===c?e+=A:"[object Float32Array]"===c?e+=B:"[object Float64Array]"===c?e+=C:b(new Error("Failed to get type for BinaryArray"))),b(e+i(d))}else if("[object Blob]"===c){var f=new FileReader;f.onload=function(){var a=i(this.result);b(q+t+a)},f.readAsArrayBuffer(a)}else try{b(JSON.stringify(a))}catch(g){this.console&&this.console.error&&this.console.error("Couldn't convert value into a JSON string: ",a),b(null,g)}}var l="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",m="undefined"!=typeof module&&module.exports?require("promise"):this.Promise,n=this.openDatabase,o=null,p={},q="__lfsc__:",r=q.length,s="arbf",t="blob",u="si08",v="ui08",w="uic8",x="si16",y="si32",z="ur16",A="ui32",B="fl32",C="fl64",D=r+s.length;if(n){var E={_driver:"webSQLStorage",_initStorage:a,getItem:b,setItem:c,removeItem:d,clear:e,length:f,key:g,keys:h};"function"==typeof define&&define.amd?define("webSQLStorage",function(){return E}):"undefined"!=typeof module&&module.exports?module.exports=E:this.webSQLStorage=E}}.call(this),function(){"use strict";var a="undefined"!=typeof module&&module.exports?require("promise"):this.Promise,b=1,c=2,d=3,e=d;"function"==typeof define&&define.amd?e=b:"undefined"!=typeof module&&module.exports&&(e=c);var f=this,g={INDEXEDDB:"asyncStorage",LOCALSTORAGE:"localStorageWrapper",WEBSQL:"webSQLStorage",_config:{description:"",name:"localforage",size:4980736,storeName:"keyvaluepairs",version:1},config:function(a){if("object"==typeof a){if(this._ready)return new Error("Can't call config() after localforage has been used.");for(var b in a)this._config[b]=a[b];return!0}return"string"==typeof a?this._config[a]:this._config},driver:function(){return this._driver||null},_ready:!1,_driverSet:null,setDriver:function(d,g,h){var i=this,j=Array.isArray||function(a){return"[object Array]"===Object.prototype.toString.call(a)};return j(d)||"string"!=typeof d||(d=[d]),this._driverSet=new a(function(j,k){var l=i._getFirstSupportedDriver(d);if(!l){var m=new Error("No available storage method found.");return i._driverSet=a.reject(m),h&&h(m),void k(m)}if(i._ready=null,e===b)return void require([l],function(a){i._extend(a),g&&g(),j()});if(e===c){var n;switch(l){case i.INDEXEDDB:n=require("./drivers/indexeddb");break;case i.LOCALSTORAGE:n=require("./drivers/localstorage");break;case i.WEBSQL:n=require("./drivers/websql")}i._extend(n)}else i._extend(f[l]);g&&g(),j()}),this._driverSet},_getFirstSupportedDriver:function(a){if(a)for(var b=0;b<a.length;b++){var c=a[b];if(this.supports(c))return c}return null},supports:function(a){return!!h[a]},ready:function(b){var c=new a(function(a,b){g._driverSet.then(function(){null===g._ready&&(g._ready=g._initStorage(g._config)),g._ready.then(a,b)},b)});return c.then(b,b),c},_extend:function(a){for(var b in a)a.hasOwnProperty(b)&&(this[b]=a[b])}},h=function(a){var b=b||a.indexedDB||a.webkitIndexedDB||a.mozIndexedDB||a.OIndexedDB||a.msIndexedDB,c={};return c[g.WEBSQL]=!!a.openDatabase,c[g.INDEXEDDB]=!(!b||"function"!=typeof b.open||null!==b.open("_localforage_spec_test",1).onupgradeneeded),c[g.LOCALSTORAGE]=!!function(){try{return localStorage&&"function"==typeof localStorage.setItem}catch(a){return!1}}(),c}(this),i=[g.INDEXEDDB,g.WEBSQL,g.LOCALSTORAGE];g.setDriver(i),e===b?define(function(){return g}):e===c?module.exports=g:this.localforage=g}.call(this); |
@@ -37,3 +37,3 @@ /* jshint node:true */ | ||
' localForage -- Offline Storage, Improved\n' + | ||
' Version 0.9.1\n' + | ||
' Version 0.9.2\n' + | ||
' http://mozilla.github.io/localForage\n' + | ||
@@ -67,2 +67,16 @@ ' (c) 2013-2014 Mozilla, Apache License 2.0\n' + | ||
}, | ||
es3_safe_recast: { | ||
dist: { | ||
files: [{ | ||
src: ['dist/localforage.js'], | ||
dest: 'dist/localforage.js' | ||
}] | ||
}, | ||
nopromises: { | ||
files: [{ | ||
src: ['dist/localforage.nopromises.js'], | ||
dest: 'dist/localforage.nopromises.js' | ||
}] | ||
} | ||
}, | ||
jscs: { | ||
@@ -116,3 +130,3 @@ source: sourceFiles | ||
'component-build') + | ||
' -o test -n localforage.component' | ||
' --dev -o test -n localforage.component' | ||
}, | ||
@@ -157,3 +171,3 @@ 'publish-site': { | ||
grunt.registerTask('default', ['build', 'connect', 'watch']); | ||
grunt.registerTask('build', ['concat', 'uglify']); | ||
grunt.registerTask('build', ['concat', 'es3_safe_recast', 'uglify']); | ||
grunt.registerTask('publish', ['build', 'shell:publish-site']); | ||
@@ -160,0 +174,0 @@ grunt.registerTask('serve', ['build', 'connect:test', 'watch']); |
@@ -11,3 +11,3 @@ { | ||
], | ||
"version": "0.9.1", | ||
"version": "0.9.2", | ||
"homepage": "https://github.com/mozilla/localForage", | ||
@@ -31,2 +31,3 @@ "repository": { | ||
"grunt-contrib-watch": "^0.5.0", | ||
"grunt-es3-safe-recast": "^0.1.0", | ||
"grunt-jscs-checker": "^0.4.4", | ||
@@ -33,0 +34,0 @@ "grunt-mocha": "^0.4.10", |
@@ -303,2 +303,5 @@ --- | ||
localforage.setDriver('localStorageWrapper'); | ||
// Supply a list of drivers, in order of preference. | ||
localforage.setDriver(['WebSQLStorage', 'localStorageWrapper']); | ||
``` | ||
@@ -309,7 +312,11 @@ | ||
localforage.setDriver "localStorageWrapper" | ||
# Supply a list of drivers, in order of preference. | ||
localforage.setDriver ["WebSQLStorage", "localStorageWrapper"] | ||
``` | ||
`setDriver(driverName)` | ||
`setDriver(driverName)`<br> | ||
`setDriver([driverName, nextDriverName])` | ||
Force usage of a particular driver, if it is available. | ||
Force usage of a particular driver or drivers, if available. | ||
@@ -316,0 +323,0 @@ By default, localForage selects backend drivers for the datastore in this |
@@ -1,1 +0,1 @@ | ||
!function(){var a,b,c,d;!function(){var e={},f={};a=function(a,b,c){e[a]={deps:b,callback:c}},d=c=b=function(a){function c(b){if("."!==b.charAt(0))return b;for(var c=b.split("/"),d=a.split("/").slice(0,-1),e=0,f=c.length;f>e;e++){var g=c[e];if(".."===g)d.pop();else{if("."===g)continue;d.push(g)}}return d.join("/")}if(d._eak_seen=e,f[a])return f[a];if(f[a]={},!e[a])throw new Error("Could not find module "+a);for(var g,h=e[a],i=h.deps,j=h.callback,k=[],l=0,m=i.length;m>l;l++)k.push("exports"===i[l]?g={}:b(c(i[l])));var n=j.apply(this,k);return f[a]=g||n}}(),a("promise/all",["./utils","exports"],function(a,b){"use strict";function c(a){var b=this;if(!d(a))throw new TypeError("You must pass an array to all.");return new b(function(b,c){function d(a){return function(b){f(a,b)}}function f(a,c){h[a]=c,0===--i&&b(h)}var g,h=[],i=a.length;0===i&&b([]);for(var j=0;j<a.length;j++)g=a[j],g&&e(g.then)?g.then(d(j),c):f(j,g)})}var d=a.isArray,e=a.isFunction;b.all=c}),a("promise/asap",["exports"],function(a){"use strict";function b(){return function(){process.nextTick(e)}}function c(){var a=0,b=new i(e),c=document.createTextNode("");return b.observe(c,{characterData:!0}),function(){c.data=a=++a%2}}function d(){return function(){j.setTimeout(e,1)}}function e(){for(var a=0;a<k.length;a++){var b=k[a],c=b[0],d=b[1];c(d)}k=[]}function f(a,b){var c=k.push([a,b]);1===c&&g()}var g,h="undefined"!=typeof window?window:{},i=h.MutationObserver||h.WebKitMutationObserver,j="undefined"!=typeof global?global:void 0===this?window:this,k=[];g="undefined"!=typeof process&&"[object process]"==={}.toString.call(process)?b():i?c():d(),a.asap=f}),a("promise/config",["exports"],function(a){"use strict";function b(a,b){return 2!==arguments.length?c[a]:void(c[a]=b)}var c={instrument:!1};a.config=c,a.configure=b}),a("promise/polyfill",["./promise","./utils","exports"],function(a,b,c){"use strict";function d(){var a;a="undefined"!=typeof global?global:"undefined"!=typeof window&&window.document?window:self;var b="Promise"in a&&"resolve"in a.Promise&&"reject"in a.Promise&&"all"in a.Promise&&"race"in a.Promise&&function(){var b;return new a.Promise(function(a){b=a}),f(b)}();b||(a.Promise=e)}var e=a.Promise,f=b.isFunction;c.polyfill=d}),a("promise/promise",["./config","./utils","./all","./race","./resolve","./reject","./asap","exports"],function(a,b,c,d,e,f,g,h){"use strict";function i(a){if(!v(a))throw new TypeError("You must pass a resolver function as the first argument to the promise constructor");if(!(this instanceof i))throw new TypeError("Failed to construct 'Promise': Please use the 'new' operator, this object constructor cannot be called as a function.");this._subscribers=[],j(a,this)}function j(a,b){function c(a){o(b,a)}function d(a){q(b,a)}try{a(c,d)}catch(e){d(e)}}function k(a,b,c,d){var e,f,g,h,i=v(c);if(i)try{e=c(d),g=!0}catch(j){h=!0,f=j}else e=d,g=!0;n(b,e)||(i&&g?o(b,e):h?q(b,f):a===D?o(b,e):a===E&&q(b,e))}function l(a,b,c,d){var e=a._subscribers,f=e.length;e[f]=b,e[f+D]=c,e[f+E]=d}function m(a,b){for(var c,d,e=a._subscribers,f=a._detail,g=0;g<e.length;g+=3)c=e[g],d=e[g+b],k(b,c,d,f);a._subscribers=null}function n(a,b){var c,d=null;try{if(a===b)throw new TypeError("A promises callback cannot return that same promise.");if(u(b)&&(d=b.then,v(d)))return d.call(b,function(d){return c?!0:(c=!0,void(b!==d?o(a,d):p(a,d)))},function(b){return c?!0:(c=!0,void q(a,b))}),!0}catch(e){return c?!0:(q(a,e),!0)}return!1}function o(a,b){a===b?p(a,b):n(a,b)||p(a,b)}function p(a,b){a._state===B&&(a._state=C,a._detail=b,t.async(r,a))}function q(a,b){a._state===B&&(a._state=C,a._detail=b,t.async(s,a))}function r(a){m(a,a._state=D)}function s(a){m(a,a._state=E)}var t=a.config,u=(a.configure,b.objectOrFunction),v=b.isFunction,w=(b.now,c.all),x=d.race,y=e.resolve,z=f.reject,A=g.asap;t.async=A;var B=void 0,C=0,D=1,E=2;i.prototype={constructor:i,_state:void 0,_detail:void 0,_subscribers:void 0,then:function(a,b){var c=this,d=new this.constructor(function(){});if(this._state){var e=arguments;t.async(function(){k(c._state,d,e[c._state-1],c._detail)})}else l(this,d,a,b);return d},"catch":function(a){return this.then(null,a)}},i.all=w,i.race=x,i.resolve=y,i.reject=z,h.Promise=i}),a("promise/race",["./utils","exports"],function(a,b){"use strict";function c(a){var b=this;if(!d(a))throw new TypeError("You must pass an array to race.");return new b(function(b,c){for(var d,e=0;e<a.length;e++)d=a[e],d&&"function"==typeof d.then?d.then(b,c):b(d)})}var d=a.isArray;b.race=c}),a("promise/reject",["exports"],function(a){"use strict";function b(a){var b=this;return new b(function(b,c){c(a)})}a.reject=b}),a("promise/resolve",["exports"],function(a){"use strict";function b(a){if(a&&"object"==typeof a&&a.constructor===this)return a;var b=this;return new b(function(b){b(a)})}a.resolve=b}),a("promise/utils",["exports"],function(a){"use strict";function b(a){return c(a)||"object"==typeof a&&null!==a}function c(a){return"function"==typeof a}function d(a){return"[object Array]"===Object.prototype.toString.call(a)}var e=Date.now||function(){return(new Date).getTime()};a.objectOrFunction=b,a.isFunction=c,a.isArray=d,a.now=e}),b("promise/polyfill").polyfill()}(),function(){"use strict";function a(a){if(a)for(var b in a)l[b]=a[b];return new j(function(a,b){var c=m.open(l.name,l.version);c.onerror=function(){b(c.error)},c.onupgradeneeded=function(){c.result.createObjectStore(l.storeName)},c.onsuccess=function(){k=c.result,a()}})}function b(a,b){var c=this;return new j(function(d,e){c.ready().then(function(){var c=k.transaction(l.storeName,"readonly").objectStore(l.storeName),f=c.get(a);f.onsuccess=function(){var a=f.result;void 0===a&&(a=null),i(b,a),d(a)},f.onerror=function(){b&&b(null,f.error),e(f.error)}},function(a){e(a)})})}function c(a,b,c){var d=this;return new j(function(e,f){d.ready().then(function(){var d=k.transaction(l.storeName,"readwrite").objectStore(l.storeName);null===b&&(b=void 0);var g=d.put(b,a);g.onsuccess=function(){void 0===b&&(b=null),i(c,b),e(b)},g.onerror=function(){c&&c(null,g.error),f(g.error)}},function(a){f(a)})})}function d(a,b){var c=this;return new j(function(d,e){c.ready().then(function(){var c=k.transaction(l.storeName,"readwrite").objectStore(l.storeName),f=c["delete"](a);f.onsuccess=function(){i(b),d()},f.onerror=function(){b&&b(f.error),e(f.error)},f.onabort=function(a){var c=a.target.error;"QuotaExceededError"===c&&(b&&b(c),e(c))}},function(a){e(a)})})}function e(a){var b=this;return new j(function(c,d){b.ready().then(function(){var b=k.transaction(l.storeName,"readwrite").objectStore(l.storeName),e=b.clear();e.onsuccess=function(){i(a),c()},e.onerror=function(){a&&a(null,e.error),d(e.error)}},function(a){d(a)})})}function f(a){var b=this;return new j(function(c,d){b.ready().then(function(){var b=k.transaction(l.storeName,"readonly").objectStore(l.storeName),e=b.count();e.onsuccess=function(){a&&a(e.result),c(e.result)},e.onerror=function(){a&&a(null,e.error),d(e.error)}},function(a){d(a)})})}function g(a,b){var c=this;return new j(function(d,e){return 0>a?(b&&b(null),void d(null)):void c.ready().then(function(){var c=k.transaction(l.storeName,"readonly").objectStore(l.storeName),f=!1,g=c.openCursor();g.onsuccess=function(){var c=g.result;return c?void(0===a?(b&&b(c.key),d(c.key)):f?(b&&b(c.key),d(c.key)):(f=!0,c.advance(a))):(b&&b(null),void d(null))},g.onerror=function(){b&&b(null,g.error),e(g.error)}},function(a){e(a)})})}function h(a){var b=this;return new j(function(c,d){b.ready().then(function(){var b=k.transaction(l.storeName,"readonly").objectStore(l.storeName),e=b.openCursor(),f=[];e.onsuccess=function(){var b=e.result;return b?(f.push(b.key),void b.continue()):(a&&a(f),void c(f))},e.onerror=function(){a&&a(null,e.error),d(e.error)}},function(a){d(a)})})}function i(a,b){return a?setTimeout(function(){return a(b)},0):void 0}var j="undefined"!=typeof module&&module.exports?require("promise"):this.Promise,k=null,l={},m=m||this.indexedDB||this.webkitIndexedDB||this.mozIndexedDB||this.OIndexedDB||this.msIndexedDB;if(m){var n={_driver:"asyncStorage",_initStorage:a,getItem:b,setItem:c,removeItem:d,clear:e,length:f,key:g,keys:h};"function"==typeof define&&define.amd?define("asyncStorage",function(){return n}):"undefined"!=typeof module&&module.exports?module.exports=n:this.asyncStorage=n}}.call(this),function(){"use strict";function a(a){if(a)for(var b in a)m[b]=a[b];return l=m.name+"/",n.resolve()}function b(a){var b=this;return new n(function(c){b.ready().then(function(){o.clear(),a&&a(),c()})})}function c(a,b){var c=this;return new n(function(d,e){c.ready().then(function(){try{var c=o.getItem(l+a);c&&(c=h(c)),b&&b(c),d(c)}catch(f){b&&b(null,f),e(f)}})})}function d(a,b){var c=this;return new n(function(d){c.ready().then(function(){var c;try{c=o.key(a)}catch(e){c=null}c&&(c=c.substring(l.length)),b&&b(c),d(c)})})}function e(a){var b=this;return new n(function(c){b.ready().then(function(){for(var b=o.length,d=[],e=0;b>e;e++)d.push(o.key(e).substring(l.length));a&&a(d),c(d)})})}function f(a){var b=this;return new n(function(c){b.ready().then(function(){var b=o.length;a&&a(b),c(b)})})}function g(a,b){var c=this;return new n(function(d){c.ready().then(function(){o.removeItem(l+a),b&&b(),d()})})}function h(a){if(a.substring(0,r)!==q)return JSON.parse(a);for(var b=a.substring(D),c=a.substring(r,D),d=new ArrayBuffer(2*b.length),e=new Uint16Array(d),f=b.length-1;f>=0;f--)e[f]=b.charCodeAt(f);switch(c){case s:return d;case t:return new Blob([d]);case u:return new Int8Array(d);case v:return new Uint8Array(d);case w:return new Uint8ClampedArray(d);case x:return new Int16Array(d);case z:return new Uint16Array(d);case y:return new Int32Array(d);case A:return new Uint32Array(d);case B:return new Float32Array(d);case C:return new Float64Array(d);default:throw new Error("Unkown type: "+c)}}function i(a){var b="",c=new Uint16Array(a);try{b=String.fromCharCode.apply(null,c)}catch(d){for(var e=0;e<c.length;e++)b+=String.fromCharCode(c[e])}return b}function j(a,b){var c="";if(a&&(c=a.toString()),a&&("[object ArrayBuffer]"===a.toString()||a.buffer&&"[object ArrayBuffer]"===a.buffer.toString())){var d,e=q;a instanceof ArrayBuffer?(d=a,e+=s):(d=a.buffer,"[object Int8Array]"===c?e+=u:"[object Uint8Array]"===c?e+=v:"[object Uint8ClampedArray]"===c?e+=w:"[object Int16Array]"===c?e+=x:"[object Uint16Array]"===c?e+=z:"[object Int32Array]"===c?e+=y:"[object Uint32Array]"===c?e+=A:"[object Float32Array]"===c?e+=B:"[object Float64Array]"===c?e+=C:b(new Error("Failed to get type for BinaryArray"))),b(e+i(d))}else if("[object Blob]"===c){var f=new FileReader;f.onload=function(){var a=i(this.result);b(q+t+a)},f.readAsArrayBuffer(a)}else try{b(JSON.stringify(a))}catch(g){this.console&&this.console.error&&this.console.error("Couldn't convert value into a JSON string: ",a),b(null,g)}}function k(a,b,c){var d=this;return new n(function(e,f){d.ready().then(function(){void 0===b&&(b=null);var d=b;j(b,function(b,g){if(g)c&&c(null,g),f(g);else{try{o.setItem(l+a,b)}catch(h){("QuotaExceededError"===h.name||"NS_ERROR_DOM_QUOTA_REACHED"===h.name)&&(c&&c(null,h),f(h))}c&&c(d),e(d)}})})})}var l="",m={},n="undefined"!=typeof module&&module.exports?require("promise"):this.Promise,o=null;try{if(!(this.localStorage&&"setItem"in this.localStorage))return;o=this.localStorage}catch(p){return}var q="__lfsc__:",r=q.length,s="arbf",t="blob",u="si08",v="ui08",w="uic8",x="si16",y="si32",z="ur16",A="ui32",B="fl32",C="fl64",D=r+s.length,E={_driver:"localStorageWrapper",_initStorage:a,getItem:c,setItem:k,removeItem:g,clear:b,length:f,key:d,keys:e};"function"==typeof define&&define.amd?define("localStorageWrapper",function(){return E}):"undefined"!=typeof module&&module.exports?module.exports=E:this.localStorageWrapper=E}.call(this),function(){"use strict";function a(a){var b=this;if(a)for(var c in a)p[c]="string"!=typeof a[c]?a[c].toString():a[c];return new m(function(a){try{o=n(p.name,p.version,p.description,p.size)}catch(c){return b.setDriver("localStorageWrapper").then(a)}o.transaction(function(b){b.executeSql("CREATE TABLE IF NOT EXISTS "+p.storeName+" (id INTEGER PRIMARY KEY, key unique, value)",[],function(){a()},null)})})}function b(a,b){var c=this;return new m(function(d,e){c.ready().then(function(){o.transaction(function(c){c.executeSql("SELECT * FROM "+p.storeName+" WHERE key = ? LIMIT 1",[a],function(a,c){var e=c.rows.length?c.rows.item(0).value:null;e&&(e=j(e)),b&&b(e),d(e)},function(a,c){b&&b(null,c),e(c)})})})})}function c(a,b,c){var d=this;return new m(function(e,f){d.ready().then(function(){void 0===b&&(b=null);var d=b;k(b,function(b,g){g?f(g):o.transaction(function(g){g.executeSql("INSERT OR REPLACE INTO "+p.storeName+" (key, value) VALUES (?, ?)",[a,b],function(){c&&c(d),e(d)},function(a,b){c&&c(null,b),f(b)})},function(a){a.code===a.QUOTA_ERR&&(c&&c(null,a),f(a))})})})})}function d(a,b){var c=this;return new m(function(d,e){c.ready().then(function(){o.transaction(function(c){c.executeSql("DELETE FROM "+p.storeName+" WHERE key = ?",[a],function(){b&&b(),d()},function(a,c){b&&b(c),e(c)})})})})}function e(a){var b=this;return new m(function(c,d){b.ready().then(function(){o.transaction(function(b){b.executeSql("DELETE FROM "+p.storeName,[],function(){a&&a(),c()},function(b,c){a&&a(c),d(c)})})})})}function f(a){var b=this;return new m(function(c,d){b.ready().then(function(){o.transaction(function(b){b.executeSql("SELECT COUNT(key) as c FROM "+p.storeName,[],function(b,d){var e=d.rows.item(0).c;a&&a(e),c(e)},function(b,c){a&&a(null,c),d(c)})})})})}function g(a,b){var c=this;return new m(function(d,e){c.ready().then(function(){o.transaction(function(c){c.executeSql("SELECT key FROM "+p.storeName+" WHERE id = ? LIMIT 1",[a+1],function(a,c){var e=c.rows.length?c.rows.item(0).key:null;b&&b(e),d(e)},function(a,c){b&&b(null,c),e(c)})})})})}function h(a){var b=this;return new m(function(c,d){b.ready().then(function(){o.transaction(function(b){b.executeSql("SELECT key FROM "+p.storeName,[],function(b,d){for(var e=d.rows.length,f=[],g=0;e>g;g++)f.push(d.rows.item(g).key);a&&a(f),c(f)},function(b,c){a&&a(null,c),d(c)})})})})}function i(a){var b,c=new Uint8Array(a),d="";for(b=0;b<c.length;b+=3)d+=l[c[b]>>2],d+=l[(3&c[b])<<4|c[b+1]>>4],d+=l[(15&c[b+1])<<2|c[b+2]>>6],d+=l[63&c[b+2]];return c.length%3===2?d=d.substring(0,d.length-1)+"=":c.length%3===1&&(d=d.substring(0,d.length-2)+"=="),d}function j(a){if(a.substring(0,r)!==q)return JSON.parse(a);var b,c,d,e,f,g=a.substring(D),h=a.substring(r,D),i=.75*g.length,j=g.length,k=0;"="===g[g.length-1]&&(i--,"="===g[g.length-2]&&i--);var m=new ArrayBuffer(i),n=new Uint8Array(m);for(b=0;j>b;b+=4)c=l.indexOf(g[b]),d=l.indexOf(g[b+1]),e=l.indexOf(g[b+2]),f=l.indexOf(g[b+3]),n[k++]=c<<2|d>>4,n[k++]=(15&d)<<4|e>>2,n[k++]=(3&e)<<6|63&f;switch(h){case s:return m;case t:return new Blob([m]);case u:return new Int8Array(m);case v:return new Uint8Array(m);case w:return new Uint8ClampedArray(m);case x:return new Int16Array(m);case z:return new Uint16Array(m);case y:return new Int32Array(m);case A:return new Uint32Array(m);case B:return new Float32Array(m);case C:return new Float64Array(m);default:throw new Error("Unkown type: "+h)}}function k(a,b){var c="";if(a&&(c=a.toString()),a&&("[object ArrayBuffer]"===a.toString()||a.buffer&&"[object ArrayBuffer]"===a.buffer.toString())){var d,e=q;a instanceof ArrayBuffer?(d=a,e+=s):(d=a.buffer,"[object Int8Array]"===c?e+=u:"[object Uint8Array]"===c?e+=v:"[object Uint8ClampedArray]"===c?e+=w:"[object Int16Array]"===c?e+=x:"[object Uint16Array]"===c?e+=z:"[object Int32Array]"===c?e+=y:"[object Uint32Array]"===c?e+=A:"[object Float32Array]"===c?e+=B:"[object Float64Array]"===c?e+=C:b(new Error("Failed to get type for BinaryArray"))),b(e+i(d))}else if("[object Blob]"===c){var f=new FileReader;f.onload=function(){var a=i(this.result);b(q+t+a)},f.readAsArrayBuffer(a)}else try{b(JSON.stringify(a))}catch(g){this.console&&this.console.error&&this.console.error("Couldn't convert value into a JSON string: ",a),b(null,g)}}var l="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",m="undefined"!=typeof module&&module.exports?require("promise"):this.Promise,n=this.openDatabase,o=null,p={},q="__lfsc__:",r=q.length,s="arbf",t="blob",u="si08",v="ui08",w="uic8",x="si16",y="si32",z="ur16",A="ui32",B="fl32",C="fl64",D=r+s.length;if(n){var E={_driver:"webSQLStorage",_initStorage:a,getItem:b,setItem:c,removeItem:d,clear:e,length:f,key:g,keys:h};"function"==typeof define&&define.amd?define("webSQLStorage",function(){return E}):"undefined"!=typeof module&&module.exports?module.exports=E:this.webSQLStorage=E}}.call(this),function(){"use strict";var a="undefined"!=typeof module&&module.exports?require("promise"):this.Promise,b=1,c=2,d=3,e=d;"function"==typeof define&&define.amd?e=b:"undefined"!=typeof module&&module.exports&&(e=c);var f,g=g||this.indexedDB||this.webkitIndexedDB||this.mozIndexedDB||this.OIndexedDB||this.msIndexedDB,h=g&&"function"==typeof g.open&&null===g.open("_localforage_spec_test",1).onupgradeneeded,i=this.openDatabase,j=function(){try{return localStorage&&"function"==typeof localStorage.setItem}catch(a){return!1}}(),k=this,l={INDEXEDDB:"asyncStorage",LOCALSTORAGE:"localStorageWrapper",WEBSQL:"webSQLStorage",_config:{description:"",name:"localforage",size:4980736,storeName:"keyvaluepairs",version:1},config:function(a){if("object"==typeof a){if(this._ready)return new Error("Can't call config() after localforage has been used.");for(var b in a)this._config[b]=a[b];return!0}return"string"==typeof a?this._config[a]:this._config},driver:function(){return this._driver||null},_ready:!1,_driverSet:null,setDriver:function(d,f,g){var m=this;return this._driverSet=new a(function(a,n){if(!h&&d===l.INDEXEDDB||!i&&d===l.WEBSQL||!j&&d===l.LOCALSTORAGE)return g&&g(),void n(l);if(m._ready=null,e===b)return void require([d],function(b){m._extend(b),f&&f(),a()});if(e===c){var o;switch(d){case m.INDEXEDDB:o=require("./drivers/indexeddb");break;case m.LOCALSTORAGE:o=require("./drivers/localstorage");break;case m.WEBSQL:o=require("./drivers/websql")}m._extend(o)}else m._extend(k[d]);f&&f(),a()}),this._driverSet},ready:function(b){var c=new a(function(a){l._driverSet.then(function(){null===l._ready&&(l._ready=l._initStorage(l._config)),l._ready.then(a)})});return c.then(b,b),c},_extend:function(a){for(var b in a)a.hasOwnProperty(b)&&(this[b]=a[b])}};h?f=l.INDEXEDDB:i?f=l.WEBSQL:j&&(f=l.LOCALSTORAGE),this.localForageConfig&&(l.config=this.localForageConfig),f?l.setDriver(f):l._ready=a.reject(new Error("No available storage method found.")),e===b?define(function(){return l}):e===c?module.exports=l:this.localforage=l}.call(this); | ||
!function(){var a,b,c,d;!function(){var e={},f={};a=function(a,b,c){e[a]={deps:b,callback:c}},d=c=b=function(a){function c(b){if("."!==b.charAt(0))return b;for(var c=b.split("/"),d=a.split("/").slice(0,-1),e=0,f=c.length;f>e;e++){var g=c[e];if(".."===g)d.pop();else{if("."===g)continue;d.push(g)}}return d.join("/")}if(d._eak_seen=e,f[a])return f[a];if(f[a]={},!e[a])throw new Error("Could not find module "+a);for(var g,h=e[a],i=h.deps,j=h.callback,k=[],l=0,m=i.length;m>l;l++)k.push("exports"===i[l]?g={}:b(c(i[l])));var n=j.apply(this,k);return f[a]=g||n}}(),a("promise/all",["./utils","exports"],function(a,b){"use strict";function c(a){var b=this;if(!d(a))throw new TypeError("You must pass an array to all.");return new b(function(b,c){function d(a){return function(b){f(a,b)}}function f(a,c){h[a]=c,0===--i&&b(h)}var g,h=[],i=a.length;0===i&&b([]);for(var j=0;j<a.length;j++)g=a[j],g&&e(g.then)?g.then(d(j),c):f(j,g)})}var d=a.isArray,e=a.isFunction;b.all=c}),a("promise/asap",["exports"],function(a){"use strict";function b(){return function(){process.nextTick(e)}}function c(){var a=0,b=new i(e),c=document.createTextNode("");return b.observe(c,{characterData:!0}),function(){c.data=a=++a%2}}function d(){return function(){j.setTimeout(e,1)}}function e(){for(var a=0;a<k.length;a++){var b=k[a],c=b[0],d=b[1];c(d)}k=[]}function f(a,b){var c=k.push([a,b]);1===c&&g()}var g,h="undefined"!=typeof window?window:{},i=h.MutationObserver||h.WebKitMutationObserver,j="undefined"!=typeof global?global:void 0===this?window:this,k=[];g="undefined"!=typeof process&&"[object process]"==={}.toString.call(process)?b():i?c():d(),a.asap=f}),a("promise/config",["exports"],function(a){"use strict";function b(a,b){return 2!==arguments.length?c[a]:void(c[a]=b)}var c={instrument:!1};a.config=c,a.configure=b}),a("promise/polyfill",["./promise","./utils","exports"],function(a,b,c){"use strict";function d(){var a;a="undefined"!=typeof global?global:"undefined"!=typeof window&&window.document?window:self;var b="Promise"in a&&"resolve"in a.Promise&&"reject"in a.Promise&&"all"in a.Promise&&"race"in a.Promise&&function(){var b;return new a.Promise(function(a){b=a}),f(b)}();b||(a.Promise=e)}var e=a.Promise,f=b.isFunction;c.polyfill=d}),a("promise/promise",["./config","./utils","./all","./race","./resolve","./reject","./asap","exports"],function(a,b,c,d,e,f,g,h){"use strict";function i(a){if(!v(a))throw new TypeError("You must pass a resolver function as the first argument to the promise constructor");if(!(this instanceof i))throw new TypeError("Failed to construct 'Promise': Please use the 'new' operator, this object constructor cannot be called as a function.");this._subscribers=[],j(a,this)}function j(a,b){function c(a){o(b,a)}function d(a){q(b,a)}try{a(c,d)}catch(e){d(e)}}function k(a,b,c,d){var e,f,g,h,i=v(c);if(i)try{e=c(d),g=!0}catch(j){h=!0,f=j}else e=d,g=!0;n(b,e)||(i&&g?o(b,e):h?q(b,f):a===D?o(b,e):a===E&&q(b,e))}function l(a,b,c,d){var e=a._subscribers,f=e.length;e[f]=b,e[f+D]=c,e[f+E]=d}function m(a,b){for(var c,d,e=a._subscribers,f=a._detail,g=0;g<e.length;g+=3)c=e[g],d=e[g+b],k(b,c,d,f);a._subscribers=null}function n(a,b){var c,d=null;try{if(a===b)throw new TypeError("A promises callback cannot return that same promise.");if(u(b)&&(d=b.then,v(d)))return d.call(b,function(d){return c?!0:(c=!0,void(b!==d?o(a,d):p(a,d)))},function(b){return c?!0:(c=!0,void q(a,b))}),!0}catch(e){return c?!0:(q(a,e),!0)}return!1}function o(a,b){a===b?p(a,b):n(a,b)||p(a,b)}function p(a,b){a._state===B&&(a._state=C,a._detail=b,t.async(r,a))}function q(a,b){a._state===B&&(a._state=C,a._detail=b,t.async(s,a))}function r(a){m(a,a._state=D)}function s(a){m(a,a._state=E)}var t=a.config,u=(a.configure,b.objectOrFunction),v=b.isFunction,w=(b.now,c.all),x=d.race,y=e.resolve,z=f.reject,A=g.asap;t.async=A;var B=void 0,C=0,D=1,E=2;i.prototype={constructor:i,_state:void 0,_detail:void 0,_subscribers:void 0,then:function(a,b){var c=this,d=new this.constructor(function(){});if(this._state){var e=arguments;t.async(function(){k(c._state,d,e[c._state-1],c._detail)})}else l(this,d,a,b);return d},"catch":function(a){return this.then(null,a)}},i.all=w,i.race=x,i.resolve=y,i.reject=z,h.Promise=i}),a("promise/race",["./utils","exports"],function(a,b){"use strict";function c(a){var b=this;if(!d(a))throw new TypeError("You must pass an array to race.");return new b(function(b,c){for(var d,e=0;e<a.length;e++)d=a[e],d&&"function"==typeof d.then?d.then(b,c):b(d)})}var d=a.isArray;b.race=c}),a("promise/reject",["exports"],function(a){"use strict";function b(a){var b=this;return new b(function(b,c){c(a)})}a.reject=b}),a("promise/resolve",["exports"],function(a){"use strict";function b(a){if(a&&"object"==typeof a&&a.constructor===this)return a;var b=this;return new b(function(b){b(a)})}a.resolve=b}),a("promise/utils",["exports"],function(a){"use strict";function b(a){return c(a)||"object"==typeof a&&null!==a}function c(a){return"function"==typeof a}function d(a){return"[object Array]"===Object.prototype.toString.call(a)}var e=Date.now||function(){return(new Date).getTime()};a.objectOrFunction=b,a.isFunction=c,a.isArray=d,a.now=e}),b("promise/polyfill").polyfill()}(),function(){"use strict";function a(a){if(a)for(var b in a)l[b]=a[b];return new j(function(a,b){var c=m.open(l.name,l.version);c.onerror=function(){b(c.error)},c.onupgradeneeded=function(){c.result.createObjectStore(l.storeName)},c.onsuccess=function(){k=c.result,a()}})}function b(a,b){var c=this;return new j(function(d,e){c.ready().then(function(){var c=k.transaction(l.storeName,"readonly").objectStore(l.storeName),f=c.get(a);f.onsuccess=function(){var a=f.result;void 0===a&&(a=null),i(b,a),d(a)},f.onerror=function(){b&&b(null,f.error),e(f.error)}},e)})}function c(a,b,c){var d=this;return new j(function(e,f){d.ready().then(function(){var d=k.transaction(l.storeName,"readwrite").objectStore(l.storeName);null===b&&(b=void 0);var g=d.put(b,a);g.onsuccess=function(){void 0===b&&(b=null),i(c,b),e(b)},g.onerror=function(){c&&c(null,g.error),f(g.error)}},f)})}function d(a,b){var c=this;return new j(function(d,e){c.ready().then(function(){var c=k.transaction(l.storeName,"readwrite").objectStore(l.storeName),f=c["delete"](a);f.onsuccess=function(){i(b),d()},f.onerror=function(){b&&b(f.error),e(f.error)},f.onabort=function(a){var c=a.target.error;"QuotaExceededError"===c&&(b&&b(c),e(c))}},e)})}function e(a){var b=this;return new j(function(c,d){b.ready().then(function(){var b=k.transaction(l.storeName,"readwrite").objectStore(l.storeName),e=b.clear();e.onsuccess=function(){i(a),c()},e.onerror=function(){a&&a(null,e.error),d(e.error)}},d)})}function f(a){var b=this;return new j(function(c,d){b.ready().then(function(){var b=k.transaction(l.storeName,"readonly").objectStore(l.storeName),e=b.count();e.onsuccess=function(){a&&a(e.result),c(e.result)},e.onerror=function(){a&&a(null,e.error),d(e.error)}},d)})}function g(a,b){var c=this;return new j(function(d,e){return 0>a?(b&&b(null),void d(null)):void c.ready().then(function(){var c=k.transaction(l.storeName,"readonly").objectStore(l.storeName),f=!1,g=c.openCursor();g.onsuccess=function(){var c=g.result;return c?void(0===a?(b&&b(c.key),d(c.key)):f?(b&&b(c.key),d(c.key)):(f=!0,c.advance(a))):(b&&b(null),void d(null))},g.onerror=function(){b&&b(null,g.error),e(g.error)}},e)})}function h(a){var b=this;return new j(function(c,d){b.ready().then(function(){var b=k.transaction(l.storeName,"readonly").objectStore(l.storeName),e=b.openCursor(),f=[];e.onsuccess=function(){var b=e.result;return b?(f.push(b.key),void b["continue"]()):(a&&a(f),void c(f))},e.onerror=function(){a&&a(null,e.error),d(e.error)}},d)})}function i(a,b){return a?setTimeout(function(){return a(b)},0):void 0}var j="undefined"!=typeof module&&module.exports?require("promise"):this.Promise,k=null,l={},m=m||this.indexedDB||this.webkitIndexedDB||this.mozIndexedDB||this.OIndexedDB||this.msIndexedDB;if(m){var n={_driver:"asyncStorage",_initStorage:a,getItem:b,setItem:c,removeItem:d,clear:e,length:f,key:g,keys:h};"function"==typeof define&&define.amd?define("asyncStorage",function(){return n}):"undefined"!=typeof module&&module.exports?module.exports=n:this.asyncStorage=n}}.call(this),function(){"use strict";function a(a){if(a)for(var b in a)m[b]=a[b];return l=m.name+"/",n.resolve()}function b(a){var b=this;return new n(function(c,d){b.ready().then(function(){o.clear(),a&&a(),c()},d)})}function c(a,b){var c=this;return new n(function(d,e){c.ready().then(function(){try{var c=o.getItem(l+a);c&&(c=h(c)),b&&b(c),d(c)}catch(f){b&&b(null,f),e(f)}},e)})}function d(a,b){var c=this;return new n(function(d,e){c.ready().then(function(){var c;try{c=o.key(a)}catch(e){c=null}c&&(c=c.substring(l.length)),b&&b(c),d(c)},e)})}function e(a){var b=this;return new n(function(c,d){b.ready().then(function(){for(var b=o.length,d=[],e=0;b>e;e++)d.push(o.key(e).substring(l.length));a&&a(d),c(d)},d)})}function f(a){var b=this;return new n(function(c,d){b.ready().then(function(){var b=o.length;a&&a(b),c(b)},d)})}function g(a,b){var c=this;return new n(function(d,e){c.ready().then(function(){o.removeItem(l+a),b&&b(),d()},e)})}function h(a){if(a.substring(0,r)!==q)return JSON.parse(a);for(var b=a.substring(D),c=a.substring(r,D),d=new ArrayBuffer(2*b.length),e=new Uint16Array(d),f=b.length-1;f>=0;f--)e[f]=b.charCodeAt(f);switch(c){case s:return d;case t:return new Blob([d]);case u:return new Int8Array(d);case v:return new Uint8Array(d);case w:return new Uint8ClampedArray(d);case x:return new Int16Array(d);case z:return new Uint16Array(d);case y:return new Int32Array(d);case A:return new Uint32Array(d);case B:return new Float32Array(d);case C:return new Float64Array(d);default:throw new Error("Unkown type: "+c)}}function i(a){var b="",c=new Uint16Array(a);try{b=String.fromCharCode.apply(null,c)}catch(d){for(var e=0;e<c.length;e++)b+=String.fromCharCode(c[e])}return b}function j(a,b){var c="";if(a&&(c=a.toString()),a&&("[object ArrayBuffer]"===a.toString()||a.buffer&&"[object ArrayBuffer]"===a.buffer.toString())){var d,e=q;a instanceof ArrayBuffer?(d=a,e+=s):(d=a.buffer,"[object Int8Array]"===c?e+=u:"[object Uint8Array]"===c?e+=v:"[object Uint8ClampedArray]"===c?e+=w:"[object Int16Array]"===c?e+=x:"[object Uint16Array]"===c?e+=z:"[object Int32Array]"===c?e+=y:"[object Uint32Array]"===c?e+=A:"[object Float32Array]"===c?e+=B:"[object Float64Array]"===c?e+=C:b(new Error("Failed to get type for BinaryArray"))),b(e+i(d))}else if("[object Blob]"===c){var f=new FileReader;f.onload=function(){var a=i(this.result);b(q+t+a)},f.readAsArrayBuffer(a)}else try{b(JSON.stringify(a))}catch(g){this.console&&this.console.error&&this.console.error("Couldn't convert value into a JSON string: ",a),b(null,g)}}function k(a,b,c){var d=this;return new n(function(e,f){d.ready().then(function(){void 0===b&&(b=null);var d=b;j(b,function(b,g){if(g)c&&c(null,g),f(g);else{try{o.setItem(l+a,b)}catch(h){("QuotaExceededError"===h.name||"NS_ERROR_DOM_QUOTA_REACHED"===h.name)&&(c&&c(null,h),f(h))}c&&c(d),e(d)}})},f)})}var l="",m={},n="undefined"!=typeof module&&module.exports?require("promise"):this.Promise,o=null;try{if(!(this.localStorage&&"setItem"in this.localStorage))return;o=this.localStorage}catch(p){return}var q="__lfsc__:",r=q.length,s="arbf",t="blob",u="si08",v="ui08",w="uic8",x="si16",y="si32",z="ur16",A="ui32",B="fl32",C="fl64",D=r+s.length,E={_driver:"localStorageWrapper",_initStorage:a,getItem:c,setItem:k,removeItem:g,clear:b,length:f,key:d,keys:e};"function"==typeof define&&define.amd?define("localStorageWrapper",function(){return E}):"undefined"!=typeof module&&module.exports?module.exports=E:this.localStorageWrapper=E}.call(this),function(){"use strict";function a(a){var b=this;if(a)for(var c in a)p[c]="string"!=typeof a[c]?a[c].toString():a[c];return new m(function(a,c){try{o=n(p.name,p.version,p.description,p.size)}catch(d){return b.setDriver("localStorageWrapper").then(a,c)}o.transaction(function(b){b.executeSql("CREATE TABLE IF NOT EXISTS "+p.storeName+" (id INTEGER PRIMARY KEY, key unique, value)",[],function(){a()},function(a,b){c(b)})})})}function b(a,b){var c=this;return new m(function(d,e){c.ready().then(function(){o.transaction(function(c){c.executeSql("SELECT * FROM "+p.storeName+" WHERE key = ? LIMIT 1",[a],function(a,c){var e=c.rows.length?c.rows.item(0).value:null;e&&(e=j(e)),b&&b(e),d(e)},function(a,c){b&&b(null,c),e(c)})})},e)})}function c(a,b,c){var d=this;return new m(function(e,f){d.ready().then(function(){void 0===b&&(b=null);var d=b;k(b,function(b,g){g?f(g):o.transaction(function(g){g.executeSql("INSERT OR REPLACE INTO "+p.storeName+" (key, value) VALUES (?, ?)",[a,b],function(){c&&c(d),e(d)},function(a,b){c&&c(null,b),f(b)})},function(a){a.code===a.QUOTA_ERR&&(c&&c(null,a),f(a))})})},f)})}function d(a,b){var c=this;return new m(function(d,e){c.ready().then(function(){o.transaction(function(c){c.executeSql("DELETE FROM "+p.storeName+" WHERE key = ?",[a],function(){b&&b(),d()},function(a,c){b&&b(c),e(c)})})},e)})}function e(a){var b=this;return new m(function(c,d){b.ready().then(function(){o.transaction(function(b){b.executeSql("DELETE FROM "+p.storeName,[],function(){a&&a(),c()},function(b,c){a&&a(c),d(c)})})},d)})}function f(a){var b=this;return new m(function(c,d){b.ready().then(function(){o.transaction(function(b){b.executeSql("SELECT COUNT(key) as c FROM "+p.storeName,[],function(b,d){var e=d.rows.item(0).c;a&&a(e),c(e)},function(b,c){a&&a(null,c),d(c)})})},d)})}function g(a,b){var c=this;return new m(function(d,e){c.ready().then(function(){o.transaction(function(c){c.executeSql("SELECT key FROM "+p.storeName+" WHERE id = ? LIMIT 1",[a+1],function(a,c){var e=c.rows.length?c.rows.item(0).key:null;b&&b(e),d(e)},function(a,c){b&&b(null,c),e(c)})})},e)})}function h(a){var b=this;return new m(function(c,d){b.ready().then(function(){o.transaction(function(b){b.executeSql("SELECT key FROM "+p.storeName,[],function(b,d){for(var e=d.rows.length,f=[],g=0;e>g;g++)f.push(d.rows.item(g).key);a&&a(f),c(f)},function(b,c){a&&a(null,c),d(c)})})},d)})}function i(a){var b,c=new Uint8Array(a),d="";for(b=0;b<c.length;b+=3)d+=l[c[b]>>2],d+=l[(3&c[b])<<4|c[b+1]>>4],d+=l[(15&c[b+1])<<2|c[b+2]>>6],d+=l[63&c[b+2]];return c.length%3===2?d=d.substring(0,d.length-1)+"=":c.length%3===1&&(d=d.substring(0,d.length-2)+"=="),d}function j(a){if(a.substring(0,r)!==q)return JSON.parse(a);var b,c,d,e,f,g=a.substring(D),h=a.substring(r,D),i=.75*g.length,j=g.length,k=0;"="===g[g.length-1]&&(i--,"="===g[g.length-2]&&i--);var m=new ArrayBuffer(i),n=new Uint8Array(m);for(b=0;j>b;b+=4)c=l.indexOf(g[b]),d=l.indexOf(g[b+1]),e=l.indexOf(g[b+2]),f=l.indexOf(g[b+3]),n[k++]=c<<2|d>>4,n[k++]=(15&d)<<4|e>>2,n[k++]=(3&e)<<6|63&f;switch(h){case s:return m;case t:return new Blob([m]);case u:return new Int8Array(m);case v:return new Uint8Array(m);case w:return new Uint8ClampedArray(m);case x:return new Int16Array(m);case z:return new Uint16Array(m);case y:return new Int32Array(m);case A:return new Uint32Array(m);case B:return new Float32Array(m);case C:return new Float64Array(m);default:throw new Error("Unkown type: "+h)}}function k(a,b){var c="";if(a&&(c=a.toString()),a&&("[object ArrayBuffer]"===a.toString()||a.buffer&&"[object ArrayBuffer]"===a.buffer.toString())){var d,e=q;a instanceof ArrayBuffer?(d=a,e+=s):(d=a.buffer,"[object Int8Array]"===c?e+=u:"[object Uint8Array]"===c?e+=v:"[object Uint8ClampedArray]"===c?e+=w:"[object Int16Array]"===c?e+=x:"[object Uint16Array]"===c?e+=z:"[object Int32Array]"===c?e+=y:"[object Uint32Array]"===c?e+=A:"[object Float32Array]"===c?e+=B:"[object Float64Array]"===c?e+=C:b(new Error("Failed to get type for BinaryArray"))),b(e+i(d))}else if("[object Blob]"===c){var f=new FileReader;f.onload=function(){var a=i(this.result);b(q+t+a)},f.readAsArrayBuffer(a)}else try{b(JSON.stringify(a))}catch(g){this.console&&this.console.error&&this.console.error("Couldn't convert value into a JSON string: ",a),b(null,g)}}var l="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",m="undefined"!=typeof module&&module.exports?require("promise"):this.Promise,n=this.openDatabase,o=null,p={},q="__lfsc__:",r=q.length,s="arbf",t="blob",u="si08",v="ui08",w="uic8",x="si16",y="si32",z="ur16",A="ui32",B="fl32",C="fl64",D=r+s.length;if(n){var E={_driver:"webSQLStorage",_initStorage:a,getItem:b,setItem:c,removeItem:d,clear:e,length:f,key:g,keys:h};"function"==typeof define&&define.amd?define("webSQLStorage",function(){return E}):"undefined"!=typeof module&&module.exports?module.exports=E:this.webSQLStorage=E}}.call(this),function(){"use strict";var a="undefined"!=typeof module&&module.exports?require("promise"):this.Promise,b=1,c=2,d=3,e=d;"function"==typeof define&&define.amd?e=b:"undefined"!=typeof module&&module.exports&&(e=c);var f=this,g={INDEXEDDB:"asyncStorage",LOCALSTORAGE:"localStorageWrapper",WEBSQL:"webSQLStorage",_config:{description:"",name:"localforage",size:4980736,storeName:"keyvaluepairs",version:1},config:function(a){if("object"==typeof a){if(this._ready)return new Error("Can't call config() after localforage has been used.");for(var b in a)this._config[b]=a[b];return!0}return"string"==typeof a?this._config[a]:this._config},driver:function(){return this._driver||null},_ready:!1,_driverSet:null,setDriver:function(d,g,h){var i=this,j=Array.isArray||function(a){return"[object Array]"===Object.prototype.toString.call(a)};return j(d)||"string"!=typeof d||(d=[d]),this._driverSet=new a(function(j,k){var l=i._getFirstSupportedDriver(d);if(!l){var m=new Error("No available storage method found.");return i._driverSet=a.reject(m),h&&h(m),void k(m)}if(i._ready=null,e===b)return void require([l],function(a){i._extend(a),g&&g(),j()});if(e===c){var n;switch(l){case i.INDEXEDDB:n=require("./drivers/indexeddb");break;case i.LOCALSTORAGE:n=require("./drivers/localstorage");break;case i.WEBSQL:n=require("./drivers/websql")}i._extend(n)}else i._extend(f[l]);g&&g(),j()}),this._driverSet},_getFirstSupportedDriver:function(a){if(a)for(var b=0;b<a.length;b++){var c=a[b];if(this.supports(c))return c}return null},supports:function(a){return!!h[a]},ready:function(b){var c=new a(function(a,b){g._driverSet.then(function(){null===g._ready&&(g._ready=g._initStorage(g._config)),g._ready.then(a,b)},b)});return c.then(b,b),c},_extend:function(a){for(var b in a)a.hasOwnProperty(b)&&(this[b]=a[b])}},h=function(a){var b=b||a.indexedDB||a.webkitIndexedDB||a.mozIndexedDB||a.OIndexedDB||a.msIndexedDB,c={};return c[g.WEBSQL]=!!a.openDatabase,c[g.INDEXEDDB]=!(!b||"function"!=typeof b.open||null!==b.open("_localforage_spec_test",1).onupgradeneeded),c[g.LOCALSTORAGE]=!!function(){try{return localStorage&&"function"==typeof localStorage.setItem}catch(a){return!1}}(),c}(this),i=[g.INDEXEDDB,g.WEBSQL,g.LOCALSTORAGE];g.setDriver(i),e===b?define(function(){return g}):e===c?module.exports=g:this.localforage=g}.call(this); |
@@ -76,5 +76,3 @@ // Some code originally from async_storage.js in | ||
}; | ||
}, function(err) { | ||
reject(err) ; | ||
}); | ||
}, reject); | ||
}); | ||
@@ -121,5 +119,3 @@ } | ||
}; | ||
}, function(err) { | ||
reject(err) ; | ||
}); | ||
}, reject); | ||
}); | ||
@@ -135,10 +131,8 @@ } | ||
// We use `['delete']` instead of `.delete` because IE 8 will | ||
// throw a fit if it sees the reserved word "delete" in this | ||
// scenario. | ||
// See: https://github.com/mozilla/localForage/pull/67 | ||
// | ||
// This can be removed once we no longer care about IE 8, for | ||
// what that's worth. | ||
var req = store['delete'](key); | ||
// We use a Grunt task to make this safe for IE and some | ||
// versions of Android (including those used by Cordova). | ||
// Normally IE won't like `.delete()` and will insist on | ||
// using `['delete']()`, but we have a build step that | ||
// fixes this for us now. | ||
var req = store.delete(key); | ||
req.onsuccess = function() { | ||
@@ -172,5 +166,3 @@ | ||
}; | ||
}, function(err) { | ||
reject(err) ; | ||
}); | ||
}, reject); | ||
}); | ||
@@ -200,5 +192,3 @@ } | ||
}; | ||
}, function(err) { | ||
reject(err) ; | ||
}); | ||
}, reject); | ||
}); | ||
@@ -230,5 +220,3 @@ } | ||
}; | ||
}, function(err) { | ||
reject(err) ; | ||
}); | ||
}, reject); | ||
}); | ||
@@ -301,5 +289,3 @@ } | ||
}; | ||
}, function(err) { | ||
reject(err) ; | ||
}); | ||
}, reject); | ||
}); | ||
@@ -342,5 +328,3 @@ } | ||
}; | ||
}, function(err) { | ||
reject(err) ; | ||
}); | ||
}, reject); | ||
}); | ||
@@ -347,0 +331,0 @@ } |
@@ -68,3 +68,3 @@ // If IndexedDB isn't available, we'll fall back to localStorage. | ||
var _this = this; | ||
return new Promise(function(resolve) { | ||
return new Promise(function(resolve, reject) { | ||
_this.ready().then(function() { | ||
@@ -78,3 +78,3 @@ localStorage.clear(); | ||
resolve(); | ||
}); | ||
}, reject); | ||
}); | ||
@@ -113,3 +113,3 @@ } | ||
} | ||
}); | ||
}, reject); | ||
}); | ||
@@ -121,3 +121,3 @@ } | ||
var _this = this; | ||
return new Promise(function(resolve) { | ||
return new Promise(function(resolve, reject) { | ||
_this.ready().then(function() { | ||
@@ -140,3 +140,3 @@ var result; | ||
resolve(result); | ||
}); | ||
}, reject); | ||
}); | ||
@@ -147,3 +147,3 @@ } | ||
var _this = this; | ||
return new Promise(function(resolve) { | ||
return new Promise(function(resolve, reject) { | ||
_this.ready().then(function() { | ||
@@ -162,3 +162,3 @@ var length = localStorage.length; | ||
resolve(keys); | ||
}); | ||
}, reject); | ||
}); | ||
@@ -170,3 +170,3 @@ } | ||
var _this = this; | ||
return new Promise(function(resolve) { | ||
return new Promise(function(resolve, reject) { | ||
_this.ready().then(function() { | ||
@@ -180,3 +180,3 @@ var result = localStorage.length; | ||
resolve(result); | ||
}); | ||
}, reject); | ||
}); | ||
@@ -188,3 +188,3 @@ } | ||
var _this = this; | ||
return new Promise(function(resolve) { | ||
return new Promise(function(resolve, reject) { | ||
_this.ready().then(function() { | ||
@@ -198,3 +198,3 @@ localStorage.removeItem(keyPrefix + key); | ||
resolve(); | ||
}); | ||
}, reject); | ||
}); | ||
@@ -405,3 +405,3 @@ } | ||
}); | ||
}); | ||
}, reject); | ||
}); | ||
@@ -408,0 +408,0 @@ } |
@@ -59,3 +59,3 @@ /* | ||
return new Promise(function(resolve) { | ||
return new Promise(function(resolve, reject) { | ||
// Open the database; the openDatabase API will automatically | ||
@@ -67,3 +67,3 @@ // create it for us if it doesn't exist. | ||
} catch (e) { | ||
return _this.setDriver('localStorageWrapper').then(resolve); | ||
return _this.setDriver('localStorageWrapper').then(resolve, reject); | ||
} | ||
@@ -76,3 +76,5 @@ | ||
resolve(); | ||
}, null); | ||
}, function(t, error) { | ||
reject(error); | ||
}); | ||
}); | ||
@@ -110,3 +112,3 @@ }); | ||
}); | ||
}); | ||
}, reject); | ||
}); | ||
@@ -167,3 +169,3 @@ } | ||
}); | ||
}); | ||
}, reject); | ||
}); | ||
@@ -192,3 +194,3 @@ } | ||
}); | ||
}); | ||
}, reject); | ||
}); | ||
@@ -218,3 +220,3 @@ } | ||
}); | ||
}); | ||
}, reject); | ||
}); | ||
@@ -248,3 +250,3 @@ } | ||
}); | ||
}); | ||
}, reject); | ||
}); | ||
@@ -282,3 +284,3 @@ } | ||
}); | ||
}); | ||
}, reject); | ||
}); | ||
@@ -314,3 +316,3 @@ } | ||
}); | ||
}); | ||
}, reject); | ||
}); | ||
@@ -317,0 +319,0 @@ } |
@@ -25,24 +25,2 @@ (function() { | ||
// Initialize IndexedDB; fall back to vendor-prefixed versions if needed. | ||
var indexedDB = indexedDB || this.indexedDB || this.webkitIndexedDB || | ||
this.mozIndexedDB || this.OIndexedDB || | ||
this.msIndexedDB; | ||
var supportsIndexedDB = indexedDB && | ||
typeof indexedDB.open === 'function' && | ||
indexedDB.open('_localforage_spec_test', 1) | ||
.onupgradeneeded === null; | ||
// Check for WebSQL. | ||
var openDatabase = this.openDatabase; | ||
// Check for localStorage. | ||
var supportsLocalStorage = (function() { | ||
try { | ||
return localStorage && typeof localStorage.setItem === 'function'; | ||
} catch (e) { | ||
return false; | ||
} | ||
})(); | ||
// The actual localForage object that we expose as a module or via a | ||
@@ -102,17 +80,25 @@ // global. It's extended by pulling in one of our other libraries. | ||
setDriver: function(driverName, callback, errorCallback) { | ||
setDriver: function(drivers, callback, errorCallback) { | ||
var self = this; | ||
var isArray = Array.isArray || function(arg) { | ||
return Object.prototype.toString.call(arg) === '[object Array]'; | ||
}; | ||
if (!isArray(drivers) && typeof drivers === 'string') { | ||
drivers = [drivers]; | ||
} | ||
this._driverSet = new Promise(function(resolve, reject) { | ||
if ((!supportsIndexedDB && | ||
driverName === localForage.INDEXEDDB) || | ||
(!openDatabase && driverName === localForage.WEBSQL) || | ||
(!supportsLocalStorage && | ||
driverName === localForage.LOCALSTORAGE)) { | ||
var driverName = self._getFirstSupportedDriver(drivers); | ||
if (!driverName) { | ||
var error = new Error('No available storage method found.'); | ||
self._driverSet = Promise.reject(error); | ||
if (errorCallback) { | ||
errorCallback(); | ||
errorCallback(error); | ||
} | ||
reject(localForage); | ||
reject(error); | ||
@@ -166,4 +152,22 @@ return; | ||
_getFirstSupportedDriver: function(drivers) { | ||
if (drivers) { | ||
for (var i = 0; i < drivers.length; i++) { | ||
var driver = drivers[i]; | ||
if (this.supports(driver)) { | ||
return driver; | ||
} | ||
} | ||
} | ||
return null; | ||
}, | ||
supports: function(driverName) { | ||
return !!driverSupport[driverName]; | ||
}, | ||
ready: function(callback) { | ||
var ready = new Promise(function(resolve) { | ||
var ready = new Promise(function(resolve, reject) { | ||
localForage._driverSet.then(function() { | ||
@@ -175,4 +179,4 @@ if (localForage._ready === null) { | ||
localForage._ready.then(resolve); | ||
}); | ||
localForage._ready.then(resolve, reject); | ||
}, reject); | ||
}); | ||
@@ -194,4 +198,2 @@ | ||
// Select our storage library. | ||
var storageLibrary; | ||
// Check to see if IndexedDB is available and if it is the latest | ||
@@ -202,24 +204,39 @@ // implementation; it's our preferred backend library. We use "_spec_test" | ||
// See: https://github.com/mozilla/localForage/issues/128 | ||
if (supportsIndexedDB) { | ||
storageLibrary = localForage.INDEXEDDB; | ||
} else if (openDatabase) { // WebSQL is available, so we'll use that. | ||
storageLibrary = localForage.WEBSQL; | ||
} else if (supportsLocalStorage) { // If nothing else is available, | ||
// we try to use localStorage. | ||
storageLibrary = localForage.LOCALSTORAGE; | ||
} | ||
var driverSupport = (function(_this) { | ||
// Initialize IndexedDB; fall back to vendor-prefixed versions | ||
// if needed. | ||
var indexedDB = indexedDB || _this.indexedDB || _this.webkitIndexedDB || | ||
_this.mozIndexedDB || _this.OIndexedDB || | ||
_this.msIndexedDB; | ||
// If window.localForageConfig is set, use it for configuration. | ||
if (this.localForageConfig) { | ||
localForage.config = this.localForageConfig; | ||
} | ||
var result = {}; | ||
// Set the (default) driver, or report the error. | ||
if (storageLibrary) { | ||
localForage.setDriver(storageLibrary); | ||
} else { | ||
localForage._ready = Promise.reject( | ||
new Error('No available storage method found.')); | ||
} | ||
result[localForage.WEBSQL] = !!_this.openDatabase; | ||
result[localForage.INDEXEDDB] = !!( | ||
indexedDB && | ||
typeof indexedDB.open === 'function' && | ||
indexedDB.open('_localforage_spec_test', 1) | ||
.onupgradeneeded === null | ||
); | ||
result[localForage.LOCALSTORAGE] = !!(function() { | ||
try { | ||
return (localStorage && | ||
typeof localStorage.setItem === 'function'); | ||
} catch (e) { | ||
return false; | ||
} | ||
})(); | ||
return result; | ||
})(this); | ||
var driverTestOrder = [ | ||
localForage.INDEXEDDB, | ||
localForage.WEBSQL, | ||
localForage.LOCALSTORAGE | ||
]; | ||
localForage.setDriver(driverTestOrder); | ||
// We allow localForage to be declared as a module or as a library | ||
@@ -226,0 +243,0 @@ // available without AMD/require.js. |
@@ -1,2 +0,2 @@ | ||
/* global before:true, beforeEach:true, describe:true, expect:true, it:true, Modernizr:true, Promise:true, require:true */ | ||
/* global after:true, before:true, beforeEach:true, describe:true, expect:true, it:true, Modernizr:true, Promise:true, require:true */ | ||
var DRIVERS = [ | ||
@@ -22,6 +22,5 @@ localforage.INDEXEDDB, | ||
if (componentBuild) { | ||
var promise = require.modules['then~promise@4.0.0'].exports; | ||
expect(typeof promise).to.be('function'); | ||
expect(require('promise')).to.be.a('function'); | ||
} else { | ||
expect(typeof Promise).to.be('function'); | ||
expect(Promise).to.be.a('function'); | ||
} | ||
@@ -31,2 +30,33 @@ }); | ||
describe('localForage', function() { | ||
var appropriateDriver; | ||
before(function() { | ||
appropriateDriver = | ||
(localforage.supports(localforage.WEBSQL) && localforage.WEBSQL) || | ||
(localforage.supports(localforage.INDEXEDDB) && | ||
localforage.INDEXEDDB) || | ||
(localforage.supports(localforage.localStorage) && | ||
localforage.localStorage); | ||
}); | ||
it('automatically selects the most appropriate driver (' + | ||
appropriateDriver + ')', function(done) { | ||
if (appropriateDriver) { | ||
localforage.ready().then(function() { | ||
expect(localforage.driver()).to.be(appropriateDriver); | ||
done(); | ||
}); | ||
} else { | ||
localforage.ready().then(null, function(error) { | ||
expect(error).to.be.an(Error); | ||
expect(error.message).to | ||
.be('No available storage method found.'); | ||
expect(localforage.driver()).to.be(null); | ||
done(); | ||
}); | ||
} | ||
}); | ||
}); | ||
DRIVERS.forEach(function(driverName) { | ||
@@ -53,24 +83,31 @@ if ((!Modernizr.indexeddb && driverName === localforage.INDEXEDDB) || | ||
it('has a localStorage API', function() { | ||
expect(typeof localforage.getItem).to.be('function'); | ||
expect(typeof localforage.setItem).to.be('function'); | ||
expect(typeof localforage.clear).to.be('function'); | ||
expect(typeof localforage.length).to.be('function'); | ||
expect(typeof localforage.removeItem).to.be('function'); | ||
expect(typeof localforage.key).to.be('function'); | ||
expect(localforage.getItem).to.be.a('function'); | ||
expect(localforage.setItem).to.be.a('function'); | ||
expect(localforage.clear).to.be.a('function'); | ||
expect(localforage.length).to.be.a('function'); | ||
expect(localforage.removeItem).to.be.a('function'); | ||
expect(localforage.key).to.be.a('function'); | ||
}); | ||
it('has the localForage API', function() { | ||
expect(typeof localforage._initStorage).to.be('function'); | ||
expect(typeof localforage.config).to.be('function'); | ||
expect(typeof localforage.driver).to.be('function'); | ||
expect(typeof localforage.getItem).to.be('function'); | ||
expect(typeof localforage.setItem).to.be('function'); | ||
expect(typeof localforage.clear).to.be('function'); | ||
expect(typeof localforage.length).to.be('function'); | ||
expect(typeof localforage.removeItem).to.be('function'); | ||
expect(typeof localforage.key).to.be('function'); | ||
expect(typeof localforage.setDriver).to.be('function'); | ||
expect(typeof localforage.ready).to.be('function'); | ||
expect(localforage._initStorage).to.be.a('function'); | ||
expect(localforage.config).to.be.a('function'); | ||
expect(localforage.driver).to.be.a('function'); | ||
expect(localforage.supports).to.be.a('function'); | ||
expect(localforage.getItem).to.be.a('function'); | ||
expect(localforage.setItem).to.be.a('function'); | ||
expect(localforage.clear).to.be.a('function'); | ||
expect(localforage.length).to.be.a('function'); | ||
expect(localforage.removeItem).to.be.a('function'); | ||
expect(localforage.key).to.be.a('function'); | ||
expect(localforage.setDriver).to.be.a('function'); | ||
expect(localforage.ready).to.be.a('function'); | ||
}); | ||
// Make sure we don't support bogus drivers. | ||
it('supports ' + driverName + ' database driver', function() { | ||
expect(localforage.supports(driverName) === true); | ||
expect(localforage.supports('I am not a driver') === false); | ||
}); | ||
it('sets the right database driver', function() { | ||
@@ -337,2 +374,97 @@ expect(localforage.driver() === driverName); | ||
}); | ||
describe(driverName + ' driver', function() { | ||
'use strict'; | ||
var driverPreferedOrder; | ||
before(function() { | ||
// add some unsupported drivers before | ||
// and after the target driver | ||
driverPreferedOrder = ['I am a not supported driver']; | ||
if (!Modernizr.websqldatabase) { | ||
driverPreferedOrder.push(localforage.WEBSQL); | ||
} | ||
if (!Modernizr.indexeddb) { | ||
driverPreferedOrder.push(localforage.INDEXEDDB); | ||
} | ||
if (!Modernizr.localstorage) { | ||
driverPreferedOrder.push(localforage.localStorage); | ||
} | ||
driverPreferedOrder.push(driverName); | ||
driverPreferedOrder.push('I am another not supported driver'); | ||
}); | ||
it('is used according to setDriver preference order', function(done) { | ||
localforage.setDriver(driverPreferedOrder).then(function() { | ||
expect(localforage.driver()).to.be(driverName); | ||
done(); | ||
}); | ||
}); | ||
}); | ||
describe(driverName + ' driver when ready() gets rejected', function() { | ||
'use strict'; | ||
var _oldReady; | ||
before(function(done) { | ||
_oldReady = localforage.ready; | ||
localforage.ready = function() { | ||
return Promise.reject(); | ||
}; | ||
done(); | ||
}); | ||
after(function(done) { | ||
localforage.ready = _oldReady; | ||
_oldReady = null; | ||
done(); | ||
}); | ||
it('rejects getItem() promise', function(done) { | ||
localforage.getItem().then(null, function(/*err*/) { | ||
done(); | ||
}); | ||
}); | ||
it('rejects setItem() promise', function(done) { | ||
localforage.setItem().then(null, function(/*err*/) { | ||
done(); | ||
}); | ||
}); | ||
it('rejects clear() promise', function(done) { | ||
localforage.clear().then(null, function(/*err*/) { | ||
done(); | ||
}); | ||
}); | ||
it('rejects length() promise', function(done) { | ||
localforage.length().then(null, function(/*err*/) { | ||
done(); | ||
}); | ||
}); | ||
it('rejects removeItem() promise', function(done) { | ||
localforage.removeItem().then(null, function(/*err*/) { | ||
done(); | ||
}); | ||
}); | ||
it('rejects key() promise', function(done) { | ||
localforage.key().then(null, function(/*err*/) { | ||
done(); | ||
}); | ||
}); | ||
it('rejects keys() promise', function(done) { | ||
localforage.keys().then(null, function(/*err*/) { | ||
done(); | ||
}); | ||
}); | ||
}); | ||
}); |
@@ -115,3 +115,3 @@ /* global before:true, beforeEach:true, describe:true, expect:true, it:true */ | ||
it("returns all values when config isn't passed arguments", function() { | ||
expect(typeof localforage.config()).to.be('object'); | ||
expect(localforage.config()).to.be.an('object'); | ||
expect(Object.keys(localforage.config()).length).to.be(5); | ||
@@ -118,0 +118,0 @@ }); |
@@ -52,7 +52,7 @@ /* global before:true, beforeEach:true, describe:true, expect:true, it:true, Modernizr:true */ | ||
expect(setValue).to.be(546); | ||
expect(typeof setValue).to.be('number'); | ||
expect(setValue).to.be.a('number'); | ||
localforage.getItem('number', function(value) { | ||
expect(value).to.be(setValue); | ||
expect(typeof value).to.be('number'); | ||
expect(value).to.be.a('number'); | ||
done(); | ||
@@ -65,3 +65,3 @@ }); | ||
expect(setValue).to.be(546); | ||
expect(typeof setValue).to.be('number'); | ||
expect(setValue).to.be.a('number'); | ||
@@ -71,3 +71,3 @@ return localforage.getItem('number'); | ||
expect(value).to.be(546); | ||
expect(typeof value).to.be('number'); | ||
expect(value).to.be.a('number'); | ||
done(); | ||
@@ -80,7 +80,7 @@ }); | ||
expect(setValue).to.be(false); | ||
expect(typeof setValue).to.be('boolean'); | ||
expect(setValue).to.be.a('boolean'); | ||
localforage.getItem('boolean', function(value) { | ||
expect(value).to.be(setValue); | ||
expect(typeof value).to.be('boolean'); | ||
expect(value).to.be.a('boolean'); | ||
done(); | ||
@@ -93,3 +93,3 @@ }); | ||
expect(setValue).to.be(false); | ||
expect(typeof setValue).to.be('boolean'); | ||
expect(setValue).to.be.a('boolean'); | ||
@@ -99,3 +99,3 @@ return localforage.getItem('boolean'); | ||
expect(value).to.be(false); | ||
expect(typeof value).to.be('boolean'); | ||
expect(value).to.be.a('boolean'); | ||
done(); | ||
@@ -108,7 +108,5 @@ }); | ||
expect(setValue).to.be(null); | ||
expect(typeof setValue).to.be('object'); | ||
localforage.getItem('null', function(value) { | ||
expect(value).to.be(setValue); | ||
expect(typeof value).to.be('object'); | ||
expect(value).to.be(null); | ||
done(); | ||
@@ -121,3 +119,2 @@ }); | ||
expect(setValue).to.be(null); | ||
expect(typeof setValue).to.be('object'); | ||
@@ -127,3 +124,2 @@ return localforage.getItem('null'); | ||
expect(value).to.be(null); | ||
expect(typeof value).to.be('object'); | ||
done(); | ||
@@ -136,7 +132,5 @@ }); | ||
expect(setValue).to.be(null); | ||
expect(typeof setValue).to.be('object'); | ||
localforage.getItem('null', function(value) { | ||
expect(value).to.be(setValue); | ||
expect(typeof value).to.be('object'); | ||
expect(value).to.be(null); | ||
done(); | ||
@@ -149,3 +143,2 @@ }); | ||
expect(setValue).to.be(null); | ||
expect(typeof setValue).to.be('object'); | ||
@@ -155,3 +148,2 @@ return localforage.getItem('null'); | ||
expect(value).to.be(null); | ||
expect(typeof value).to.be('object'); | ||
done(); | ||
@@ -164,7 +156,7 @@ }); | ||
expect(setValue).to.be(546.041); | ||
expect(typeof setValue).to.be('number'); | ||
expect(setValue).to.be.a('number'); | ||
localforage.getItem('float', function(value) { | ||
expect(value).to.be(setValue); | ||
expect(typeof value).to.be('number'); | ||
expect(value).to.be.a('number'); | ||
done(); | ||
@@ -177,3 +169,3 @@ }); | ||
expect(setValue).to.be(546.041); | ||
expect(typeof setValue).to.be('number'); | ||
expect(setValue).to.be.a('number'); | ||
@@ -183,3 +175,3 @@ return localforage.getItem('float'); | ||
expect(value).to.be(546.041); | ||
expect(typeof value).to.be('number'); | ||
expect(value).to.be.a('number'); | ||
done(); | ||
@@ -198,3 +190,3 @@ }); | ||
expect(value instanceof Array).to.be(true); | ||
expect(typeof value[1]).to.be('string'); | ||
expect(value[1]).to.be.a('string'); | ||
done(); | ||
@@ -213,3 +205,3 @@ }); | ||
expect(value instanceof Array).to.be(true); | ||
expect(typeof value[1]).to.be('string'); | ||
expect(value[1]).to.be.a('string'); | ||
done(); | ||
@@ -224,2 +216,8 @@ }); | ||
}, | ||
nestedObjects: [ | ||
{truth: true}, | ||
{theCake: 'is a lie'}, | ||
{happiness: 'is a warm gun'}, | ||
false | ||
], | ||
string: 'bar' | ||
@@ -231,3 +229,3 @@ }; | ||
.to.be(Object.keys(objectToSave).length); | ||
expect(typeof setValue).to.be('object'); | ||
expect(setValue).to.be.an('object'); | ||
@@ -237,4 +235,7 @@ localforage.getItem('obj', function(value) { | ||
.to.be(Object.keys(objectToSave).length); | ||
expect(typeof value).to.be('object'); | ||
expect(typeof value.nested).to.be('object'); | ||
expect(value).to.be.an('object'); | ||
expect(value.nested).to.be.an('object'); | ||
expect(value.nestedObjects[0].truth).to.be.a('boolean'); | ||
expect(value.nestedObjects[1].theCake).to.be.a('string'); | ||
expect(value.nestedObjects[3]).to.be(false); | ||
done(); | ||
@@ -248,3 +249,3 @@ }); | ||
.to.be(Object.keys(objectToSave).length); | ||
expect(typeof setValue).to.be('object'); | ||
expect(setValue).to.be.an('object'); | ||
@@ -255,4 +256,7 @@ return localforage.getItem('obj'); | ||
.to.be(Object.keys(objectToSave).length); | ||
expect(typeof value).to.be('object'); | ||
expect(typeof value.nested).to.be('object'); | ||
expect(value).to.be.an('object'); | ||
expect(value.nested).to.be.an('object'); | ||
expect(value.nestedObjects[0].truth).to.be.a('boolean'); | ||
expect(value.nestedObjects[1].theCake).to.be.a('string'); | ||
expect(value.nestedObjects[3]).to.be(false); | ||
done(); | ||
@@ -259,0 +263,0 @@ }); |
@@ -1,44 +0,85 @@ | ||
/* global before:true, describe:true, expect:true, it:true */ | ||
/* global describe:true, expect:true, it:true, Modernizr:true */ | ||
describe('When No Drivers Are Available', function() { | ||
'use strict'; | ||
before(function(done) { | ||
try { | ||
window.indexedDB.open = null; | ||
} catch (error) { | ||
} | ||
try { | ||
window.localStorage.setItem = null; | ||
} catch (error) { | ||
} | ||
try { | ||
window.openDatabase = null; | ||
} catch (error) { | ||
} | ||
var DRIVERS = [ | ||
localforage.INDEXEDDB, | ||
localforage.LOCALSTORAGE, | ||
localforage.WEBSQL | ||
]; | ||
done(); | ||
it('agrees with Modernizr on storage drivers support', function() { | ||
expect(localforage.supports(localforage.INDEXEDDB)).to.be(false); | ||
expect(localforage.supports(localforage.INDEXEDDB)) | ||
.to.be(Modernizr.indexeddb); | ||
expect(localforage.supports(localforage.LOCALSTORAGE)) | ||
.to.be(false); | ||
expect(localforage.supports(localforage.LOCALSTORAGE)) | ||
.to.be(Modernizr.localstorage); | ||
expect(localforage.supports(localforage.WEBSQL)).to.be(false); | ||
expect(localforage.supports(localforage.WEBSQL)) | ||
.to.be(Modernizr.websqldatabase); | ||
}); | ||
// Test to make sure localStorage isn't used when it isn't available. | ||
// it("can't use unsupported localStorage [callback]", function(done) { | ||
// var _oldLS = window.localStorage; | ||
// window.localStorage = null; | ||
// | ||
// localforage.setDriver(localforage.LOCALSTORAGE, null, function() { | ||
// expect(localforage.driver()).to.be(previousDriver); | ||
// done(); | ||
// }); | ||
// }); | ||
it.skip('fails to load localForage [promise]', function(done) { | ||
localforage.ready(null, function(error) { | ||
expect(error).to.be('No available storage method found.'); | ||
it('fails to load localForage [callback]', function(done) { | ||
localforage.ready(function(error) { | ||
expect(error).to.be.an(Error); | ||
expect(error.message).to.be('No available storage method found.'); | ||
done(); | ||
}); | ||
// localforage.setDriver(localforage.LOCALSTORAGE).then(null, | ||
// function(error) { | ||
// expect(error).to.be('No available storage method found.'); | ||
// window.localStorage = _oldLS; | ||
// done(); | ||
// }); | ||
}); | ||
it('fails to load localForage [promise]', function(done) { | ||
localforage.ready().then(null, function(error) { | ||
expect(error).to.be.an(Error); | ||
expect(error.message).to.be('No available storage method found.'); | ||
done(); | ||
}); | ||
}); | ||
it('has no driver set', function(done) { | ||
localforage.ready(function() { | ||
expect(localforage.driver()).to.be(null); | ||
done(); | ||
}); | ||
}); | ||
DRIVERS.forEach(function(driverName) { | ||
it('fails to setDriver ' + driverName + ' [callback]', function(done) { | ||
localforage.setDriver(driverName, null, function(error) { | ||
expect(error).to.be.an(Error); | ||
expect(error.message).to | ||
.be('No available storage method found.'); | ||
done(); | ||
}); | ||
}); | ||
it('fails to setDriver ' + driverName + ' [promise]', function(done) { | ||
localforage.setDriver(driverName).then(null, function(error) { | ||
expect(error).to.be.an(Error); | ||
expect(error.message).to | ||
.be('No available storage method found.'); | ||
done(); | ||
}); | ||
}); | ||
}); | ||
it('fails to setDriver using array parameter [callback]', function(done) { | ||
localforage.setDriver(DRIVERS, null, function(error) { | ||
expect(error).to.be.an(Error); | ||
expect(error.message).to.be('No available storage method found.'); | ||
done(); | ||
}); | ||
}); | ||
it('fails to setDriver using array parameter [promise]', function(done) { | ||
localforage.setDriver(DRIVERS).then(null, function(error) { | ||
expect(error).to.be.an(Error); | ||
expect(error.message).to.be('No available storage method found.'); | ||
done(); | ||
}); | ||
}); | ||
}); |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
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
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
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
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
918082
10840
17
98