Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Side by Side Diff: lib/localforage.min.js

Issue 29526591: Issue 5562 - Move Edge storage to IndexedDB (Closed)
Patch Set: Remove accidental code Created Aug. 24, 2017, 5:15 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « lib/io.js ('k') | metadata.edge » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 /*!
2 localForage -- Offline Storage, Improved
3 Version 1.5.0
4 https://localforage.github.io/localForage
5 (c) 2013-2017 Mozilla, Apache License 2.0
6 */
7 !function(a){if("object"==typeof exports&&"undefined"!=typeof module)module.expo rts=a();else if("function"==typeof define&&define.amd)define([],a);else{var b;b= "undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"! =typeof self?self:this,b.localforage=a()}}(function(){return function a(b,c,d){f unction e(g,h){if(!c[g]){if(!b[g]){var i="function"==typeof require&&require;if( !h&&i)return i(g,!0);if(f)return f(g,!0);var j=new Error("Cannot find module '"+ g+"'");throw j.code="MODULE_NOT_FOUND",j}var k=c[g]={exports:{}};b[g][0].call(k. exports,function(a){var c=b[g][1][a];return e(c||a)},k,k.exports,a,b,c,d)}return c[g].exports}for(var f="function"==typeof require&&require,g=0;g<d.length;g++)e (d[g]);return e}({1:[function(a,b,c){(function(a){"use strict";function c(){k=!0 ;for(var a,b,c=l.length;c;){for(b=l,l=[],a=-1;++a<c;)b[a]();c=l.length}k=!1}func tion d(a){1!==l.push(a)||k||e()}var e,f=a.MutationObserver||a.WebKitMutationObse rver;if(f){var g=0,h=new f(c),i=a.document.createTextNode("");h.observe(i,{chara cterData:!0}),e=function(){i.data=g=++g%2}}else if(a.setImmediate||void 0===a.Me ssageChannel)e="document"in a&&"onreadystatechange"in a.document.createElement(" script")?function(){var b=a.document.createElement("script");b.onreadystatechang e=function(){c(),b.onreadystatechange=null,b.parentNode.removeChild(b),b=null},a .document.documentElement.appendChild(b)}:function(){setTimeout(c,0)};else{var j =new a.MessageChannel;j.port1.onmessage=c,e=function(){j.port2.postMessage(0)}}v ar k,l=[];b.exports=d}).call(this,"undefined"!=typeof global?global:"undefined"! =typeof self?self:"undefined"!=typeof window?window:{})},{}],2:[function(a,b,c){ "use strict";function d(){}function e(a){if("function"!=typeof a)throw new TypeE rror("resolver must be a function");this.state=s,this.queue=[],this.outcome=void 0,a!==d&&i(this,a)}function f(a,b,c){this.promise=a,"function"==typeof b&&(this .onFulfilled=b,this.callFulfilled=this.otherCallFulfilled),"function"==typeof c& &(this.onRejected=c,this.callRejected=this.otherCallRejected)}function g(a,b,c){ o(function(){var d;try{d=b(c)}catch(b){return p.reject(a,b)}d===a?p.reject(a,new TypeError("Cannot resolve promise with itself")):p.resolve(a,d)})}function h(a) {var b=a&&a.then;if(a&&"object"==typeof a&&"function"==typeof b)return function( ){b.apply(a,arguments)}}function i(a,b){function c(b){f||(f=!0,p.reject(a,b))}fu nction d(b){f||(f=!0,p.resolve(a,b))}function e(){b(d,c)}var f=!1,g=j(e);"error" ===g.status&&c(g.value)}function j(a,b){var c={};try{c.value=a(b),c.status="succ ess"}catch(a){c.status="error",c.value=a}return c}function k(a){return a instanc eof this?a:p.resolve(new this(d),a)}function l(a){var b=new this(d);return p.rej ect(b,a)}function m(a){function b(a,b){function d(a){g[b]=a,++h!==e||f||(f=!0,p. resolve(j,g))}c.resolve(a).then(d,function(a){f||(f=!0,p.reject(j,a))})}var c=th is;if("[object Array]"!==Object.prototype.toString.call(a))return this.reject(ne w TypeError("must be an array"));var e=a.length,f=!1;if(!e)return this.resolve([ ]);for(var g=new Array(e),h=0,i=-1,j=new this(d);++i<e;)b(a[i],i);return j}funct ion n(a){function b(a){c.resolve(a).then(function(a){f||(f=!0,p.resolve(h,a))},f unction(a){f||(f=!0,p.reject(h,a))})}var c=this;if("[object Array]"!==Object.pro totype.toString.call(a))return this.reject(new TypeError("must be an array"));va r e=a.length,f=!1;if(!e)return this.resolve([]);for(var g=-1,h=new this(d);++g<e ;)b(a[g]);return h}var o=a(1),p={},q=["REJECTED"],r=["FULFILLED"],s=["PENDING"]; b.exports=c=e,e.prototype.catch=function(a){return this.then(null,a)},e.prototyp e.then=function(a,b){if("function"!=typeof a&&this.state===r||"function"!=typeof b&&this.state===q)return this;var c=new this.constructor(d);if(this.state!==s){ g(c,this.state===r?a:b,this.outcome)}else this.queue.push(new f(c,a,b));return c },f.prototype.callFulfilled=function(a){p.resolve(this.promise,a)},f.prototype.o therCallFulfilled=function(a){g(this.promise,this.onFulfilled,a)},f.prototype.ca llRejected=function(a){p.reject(this.promise,a)},f.prototype.otherCallRejected=f unction(a){g(this.promise,this.onRejected,a)},p.resolve=function(a,b){var c=j(h, b);if("error"===c.status)return p.reject(a,c.value);var d=c.value;if(d)i(a,d);el se{a.state=r,a.outcome=b;for(var e=-1,f=a.queue.length;++e<f;)a.queue[e].callFul filled(b)}return a},p.reject=function(a,b){a.state=q,a.outcome=b;for(var c=-1,d= a.queue.length;++c<d;)a.queue[c].callRejected(b);return a},c.resolve=k,c.reject= l,c.all=m,c.race=n},{1:1}],3:[function(a,b,c){(function(b){"use strict";"functio n"!=typeof b.Promise&&(b.Promise=a(2))}).call(this,"undefined"!=typeof global?gl obal:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{2:2}] ,4:[function(a,b,c){"use strict";function d(a,b){if(!(a instanceof b))throw new TypeError("Cannot call a class as a function")}function e(){try{if("undefined"!= typeof indexedDB)return indexedDB;if("undefined"!=typeof webkitIndexedDB)return webkitIndexedDB;if("undefined"!=typeof mozIndexedDB)return mozIndexedDB;if("unde fined"!=typeof OIndexedDB)return OIndexedDB;if("undefined"!=typeof msIndexedDB)r eturn msIndexedDB}catch(a){}}function f(){try{if(!ka)return!1;var a="undefined"! =typeof openDatabase&&/(Safari|iPhone|iPad|iPod)/.test(navigator.userAgent)&&!/C hrome/.test(navigator.userAgent)&&!/BlackBerry/.test(navigator.platform),b="func tion"==typeof fetch&&-1!==fetch.toString().indexOf("[native code");return(!a||b) &&"undefined"!=typeof indexedDB&&"undefined"!=typeof IDBKeyRange}catch(a){return !1}}function g(){return"function"==typeof openDatabase}function h(){try{return"u ndefined"!=typeof localStorage&&"setItem"in localStorage&&localStorage.setItem}c atch(a){return!1}}function i(a,b){a=a||[],b=b||{};try{return new Blob(a,b)}catch (f){if("TypeError"!==f.name)throw f;for(var c="undefined"!=typeof BlobBuilder?Bl obBuilder:"undefined"!=typeof MSBlobBuilder?MSBlobBuilder:"undefined"!=typeof Mo zBlobBuilder?MozBlobBuilder:WebKitBlobBuilder,d=new c,e=0;e<a.length;e+=1)d.appe nd(a[e]);return d.getBlob(b.type)}}function j(a,b){b&&a.then(function(a){b(null, a)},function(a){b(a)})}function k(a,b,c){"function"==typeof b&&a.then(b),"functi on"==typeof c&&a.catch(c)}function l(a){return"string"!=typeof a&&(console.warn( a+" used as a key, but it is not a string."),a=String(a)),a}function m(a){for(va r b=a.length,c=new ArrayBuffer(b),d=new Uint8Array(c),e=0;e<b;e++)d[e]=a.charCod eAt(e);return c}function n(a){return new na(function(b){var c=a.transaction(oa,r a),d=i([""]);c.objectStore(oa).put(d,"key"),c.onabort=function(a){a.preventDefau lt(),a.stopPropagation(),b(!1)},c.oncomplete=function(){var a=navigator.userAgen t.match(/Chrome\/(\d+)/),c=navigator.userAgent.match(/Edge\//);b(c||!a||parseInt (a[1],10)>=43)}}).catch(function(){return!1})}function o(a){return"boolean"==typ eof la?na.resolve(la):n(a).then(function(a){return la=a})}function p(a){var b=ma [a.name],c={};c.promise=new na(function(a){c.resolve=a}),b.deferredOperations.pu sh(c),b.dbReady?b.dbReady=b.dbReady.then(function(){return c.promise}):b.dbReady =c.promise}function q(a){var b=ma[a.name],c=b.deferredOperations.pop();c&&c.reso lve()}function r(a,b){var c=ma[a.name],d=c.deferredOperations.pop();d&&d.reject( b)}function s(a,b){return new na(function(c,d){if(a.db){if(!b)return c(a.db);p(a ),a.db.close()}var e=[a.name];b&&e.push(a.version);var f=ka.open.apply(ka,e);b&& (f.onupgradeneeded=function(b){var c=f.result;try{c.createObjectStore(a.storeNam e),b.oldVersion<=1&&c.createObjectStore(oa)}catch(c){if("ConstraintError"!==c.na me)throw c;console.warn('The database "'+a.name+'" has been upgraded from versio n '+b.oldVersion+" to version "+b.newVersion+', but the storage "'+a.storeName+' " already exists.')}}),f.onerror=function(a){a.preventDefault(),d(f.error)},f.on success=function(){c(f.result),q(a)}})}function t(a){return s(a,!1)}function u(a ){return s(a,!0)}function v(a,b){if(!a.db)return!0;var c=!a.db.objectStoreNames. contains(a.storeName),d=a.version<a.db.version,e=a.version>a.db.version;if(d&&(a .version!==b&&console.warn('The database "'+a.name+"\" can't be downgraded from version "+a.db.version+" to version "+a.version+"."),a.version=a.db.version),e|| c){if(c){var f=a.db.version+1;f>a.version&&(a.version=f)}return!0}return!1}funct ion w(a){return new na(function(b,c){var d=new FileReader;d.onerror=c,d.onloaden d=function(c){var d=btoa(c.target.result||"");b({__local_forage_encoded_blob:!0, data:d,type:a.type})},d.readAsBinaryString(a)})}function x(a){return i([m(atob(a .data))],{type:a.type})}function y(a){return a&&a.__local_forage_encoded_blob}fu nction z(a){var b=this,c=b._initReady().then(function(){var a=ma[b._dbInfo.name] ;if(a&&a.dbReady)return a.dbReady});return k(c,a,a),c}function A(a){p(a);for(var b=ma[a.name],c=b.forages,d=0;d<c.length;d++)c[d]._dbInfo.db&&(c[d]._dbInfo.db.c lose(),c[d]._dbInfo.db=null);return s(a,!1).then(function(a){for(var b=0;b<c.len gth;b++)c[b]._dbInfo.db=a}).catch(function(b){throw r(a,b),b})}function B(a,b,c) {try{var d=a.db.transaction(a.storeName,b);c(null,d)}catch(d){if(!a.db||"Invalid StateError"===d.name)return A(a).then(function(){var d=a.db.transaction(a.storeN ame,b);c(null,d)});c(d)}}function C(a){function b(){return na.resolve()}var c=th is,d={db:null};if(a)for(var e in a)d[e]=a[e];ma||(ma={});var f=ma[d.name];f||(f= {forages:[],db:null,dbReady:null,deferredOperations:[]},ma[d.name]=f),f.forages. push(c),c._initReady||(c._initReady=c.ready,c.ready=z);for(var g=[],h=0;h<f.fora ges.length;h++){var i=f.forages[h];i!==c&&g.push(i._initReady().catch(b))}var j= f.forages.slice(0);return na.all(g).then(function(){return d.db=f.db,t(d)}).then (function(a){return d.db=a,v(d,c._defaultConfig.version)?u(d):a}).then(function( a){d.db=f.db=a,c._dbInfo=d;for(var b=0;b<j.length;b++){var e=j[b];e!==c&&(e._dbI nfo.db=d.db,e._dbInfo.version=d.version)}})}function D(a,b){var c=this;a=l(a);va r d=new na(function(b,d){c.ready().then(function(){B(c._dbInfo,qa,function(e,f){ if(e)return d(e);try{var g=f.objectStore(c._dbInfo.storeName),h=g.get(a);h.onsuc cess=function(){var a=h.result;void 0===a&&(a=null),y(a)&&(a=x(a)),b(a)},h.onerr or=function(){d(h.error)}}catch(a){d(a)}})}).catch(d)});return j(d,b),d}function E(a,b){var c=this,d=new na(function(b,d){c.ready().then(function(){B(c._dbInfo, qa,function(e,f){if(e)return d(e);try{var g=f.objectStore(c._dbInfo.storeName),h =g.openCursor(),i=1;h.onsuccess=function(){var c=h.result;if(c){var d=c.value;y( d)&&(d=x(d));var e=a(d,c.key,i++);void 0!==e?b(e):c.continue()}else b()},h.onerr or=function(){d(h.error)}}catch(a){d(a)}})}).catch(d)});return j(d,b),d}function F(a,b,c){var d=this;a=l(a);var e=new na(function(c,e){var f;d.ready().then(func tion(){return f=d._dbInfo,"[object Blob]"===pa.call(b)?o(f.db).then(function(a){ return a?b:w(b)}):b}).then(function(b){B(d._dbInfo,ra,function(f,g){if(f)return e(f);try{var h=g.objectStore(d._dbInfo.storeName),i=h.put(b,a);null===b&&(b=void 0),g.oncomplete=function(){void 0===b&&(b=null),c(b)},g.onabort=g.onerror=funct ion(){var a=i.error?i.error:i.transaction.error;e(a)}}catch(a){e(a)}})}).catch(e )});return j(e,c),e}function G(a,b){var c=this;a=l(a);var d=new na(function(b,d) {c.ready().then(function(){B(c._dbInfo,ra,function(e,f){if(e)return d(e);try{var g=f.objectStore(c._dbInfo.storeName),h=g.delete(a);f.oncomplete=function(){b()} ,f.onerror=function(){d(h.error)},f.onabort=function(){var a=h.error?h.error:h.t ransaction.error;d(a)}}catch(a){d(a)}})}).catch(d)});return j(d,b),d}function H( a){var b=this,c=new na(function(a,c){b.ready().then(function(){B(b._dbInfo,ra,fu nction(d,e){if(d)return c(d);try{var f=e.objectStore(b._dbInfo.storeName),g=f.cl ear();e.oncomplete=function(){a()},e.onabort=e.onerror=function(){var a=g.error? g.error:g.transaction.error;c(a)}}catch(a){c(a)}})}).catch(c)});return j(c,a),c} function I(a){var b=this,c=new na(function(a,c){b.ready().then(function(){B(b._d bInfo,qa,function(d,e){if(d)return c(d);try{var f=e.objectStore(b._dbInfo.storeN ame),g=f.count();g.onsuccess=function(){a(g.result)},g.onerror=function(){c(g.er ror)}}catch(a){c(a)}})}).catch(c)});return j(c,a),c}function J(a,b){var c=this,d =new na(function(b,d){if(a<0)return void b(null);c.ready().then(function(){B(c._ dbInfo,qa,function(e,f){if(e)return d(e);try{var g=f.objectStore(c._dbInfo.store Name),h=!1,i=g.openCursor();i.onsuccess=function(){var c=i.result;if(!c)return v oid b(null);0===a?b(c.key):h?b(c.key):(h=!0,c.advance(a))},i.onerror=function(){ d(i.error)}}catch(a){d(a)}})}).catch(d)});return j(d,b),d}function K(a){var b=th is,c=new na(function(a,c){b.ready().then(function(){B(b._dbInfo,qa,function(d,e) {if(d)return c(d);try{var f=e.objectStore(b._dbInfo.storeName),g=f.openCursor(), h=[];g.onsuccess=function(){var b=g.result;if(!b)return void a(h);h.push(b.key), b.continue()},g.onerror=function(){c(g.error)}}catch(a){c(a)}})}).catch(c)});ret urn j(c,a),c}function L(a){var b,c,d,e,f,g=.75*a.length,h=a.length,i=0;"="===a[a .length-1]&&(g--,"="===a[a.length-2]&&g--);var j=new ArrayBuffer(g),k=new Uint8A rray(j);for(b=0;b<h;b+=4)c=ta.indexOf(a[b]),d=ta.indexOf(a[b+1]),e=ta.indexOf(a[ b+2]),f=ta.indexOf(a[b+3]),k[i++]=c<<2|d>>4,k[i++]=(15&d)<<4|e>>2,k[i++]=(3&e)<< 6|63&f;return j}function M(a){var b,c=new Uint8Array(a),d="";for(b=0;b<c.length; b+=3)d+=ta[c[b]>>2],d+=ta[(3&c[b])<<4|c[b+1]>>4],d+=ta[(15&c[b+1])<<2|c[b+2]>>6] ,d+=ta[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 N(a,b){var c="";if(a&&(c=Ka. call(a)),a&&("[object ArrayBuffer]"===c||a.buffer&&"[object ArrayBuffer]"===Ka.c all(a.buffer))){var d,e=wa;a instanceof ArrayBuffer?(d=a,e+=ya):(d=a.buffer,"[ob ject Int8Array]"===c?e+=Aa:"[object Uint8Array]"===c?e+=Ba:"[object Uint8Clamped Array]"===c?e+=Ca:"[object Int16Array]"===c?e+=Da:"[object Uint16Array]"===c?e+= Fa:"[object Int32Array]"===c?e+=Ea:"[object Uint32Array]"===c?e+=Ga:"[object Flo at32Array]"===c?e+=Ha:"[object Float64Array]"===c?e+=Ia:b(new Error("Failed to g et type for BinaryArray"))),b(e+M(d))}else if("[object Blob]"===c){var f=new Fil eReader;f.onload=function(){var c=ua+a.type+"~"+M(this.result);b(wa+za+c)},f.rea dAsArrayBuffer(a)}else try{b(JSON.stringify(a))}catch(c){console.error("Couldn't convert value into a JSON string: ",a),b(null,c)}}function O(a){if(a.substring( 0,xa)!==wa)return JSON.parse(a);var b,c=a.substring(Ja),d=a.substring(xa,Ja);if( d===za&&va.test(c)){var e=c.match(va);b=e[1],c=c.substring(e[0].length)}var f=L( c);switch(d){case ya:return f;case za:return i([f],{type:b});case Aa:return new Int8Array(f);case Ba:return new Uint8Array(f);case Ca:return new Uint8ClampedArr ay(f);case Da:return new Int16Array(f);case Fa:return new Uint16Array(f);case Ea :return new Int32Array(f);case Ga:return new Uint32Array(f);case Ha:return new F loat32Array(f);case Ia:return new Float64Array(f);default:throw new Error("Unkow n type: "+d)}}function P(a){var b=this,c={db:null};if(a)for(var d in a)c[d]="str ing"!=typeof a[d]?a[d].toString():a[d];var e=new na(function(a,d){try{c.db=openD atabase(c.name,String(c.version),c.description,c.size)}catch(a){return d(a)}c.db .transaction(function(e){e.executeSql("CREATE TABLE IF NOT EXISTS "+c.storeName+ " (id INTEGER PRIMARY KEY, key unique, value)",[],function(){b._dbInfo=c,a()},fu nction(a,b){d(b)})})});return c.serializer=La,e}function Q(a,b){var c=this;a=l(a );var d=new na(function(b,d){c.ready().then(function(){var e=c._dbInfo;e.db.tran saction(function(c){c.executeSql("SELECT * FROM "+e.storeName+" WHERE key = ? LI MIT 1",[a],function(a,c){var d=c.rows.length?c.rows.item(0).value:null;d&&(d=e.s erializer.deserialize(d)),b(d)},function(a,b){d(b)})})}).catch(d)});return j(d,b ),d}function R(a,b){var c=this,d=new na(function(b,d){c.ready().then(function(){ var e=c._dbInfo;e.db.transaction(function(c){c.executeSql("SELECT * FROM "+e.sto reName,[],function(c,d){for(var f=d.rows,g=f.length,h=0;h<g;h++){var i=f.item(h) ,j=i.value;if(j&&(j=e.serializer.deserialize(j)),void 0!==(j=a(j,i.key,h+1)))ret urn void b(j)}b()},function(a,b){d(b)})})}).catch(d)});return j(d,b),d}function S(a,b,c,d){var e=this;a=l(a);var f=new na(function(f,g){e.ready().then(function( ){void 0===b&&(b=null);var h=b,i=e._dbInfo;i.serializer.serialize(b,function(b,j ){j?g(j):i.db.transaction(function(c){c.executeSql("INSERT OR REPLACE INTO "+i.s toreName+" (key, value) VALUES (?, ?)",[a,b],function(){f(h)},function(a,b){g(b) })},function(b){if(b.code===b.QUOTA_ERR){if(d>0)return void f(S.apply(e,[a,h,c,d -1]));g(b)}})})}).catch(g)});return j(f,c),f}function T(a,b,c){return S.apply(th is,[a,b,c,1])}function U(a,b){var c=this;a=l(a);var d=new na(function(b,d){c.rea dy().then(function(){var e=c._dbInfo;e.db.transaction(function(c){c.executeSql(" DELETE FROM "+e.storeName+" WHERE key = ?",[a],function(){b()},function(a,b){d(b )})})}).catch(d)});return j(d,b),d}function V(a){var b=this,c=new na(function(a, c){b.ready().then(function(){var d=b._dbInfo;d.db.transaction(function(b){b.exec uteSql("DELETE FROM "+d.storeName,[],function(){a()},function(a,b){c(b)})})}).ca tch(c)});return j(c,a),c}function W(a){var b=this,c=new na(function(a,c){b.ready ().then(function(){var d=b._dbInfo;d.db.transaction(function(b){b.executeSql("SE LECT COUNT(key) as c FROM "+d.storeName,[],function(b,c){var d=c.rows.item(0).c; a(d)},function(a,b){c(b)})})}).catch(c)});return j(c,a),c}function X(a,b){var c= this,d=new na(function(b,d){c.ready().then(function(){var e=c._dbInfo;e.db.trans action(function(c){c.executeSql("SELECT key FROM "+e.storeName+" WHERE id = ? LI MIT 1",[a+1],function(a,c){var d=c.rows.length?c.rows.item(0).key:null;b(d)},fun ction(a,b){d(b)})})}).catch(d)});return j(d,b),d}function Y(a){var b=this,c=new na(function(a,c){b.ready().then(function(){var d=b._dbInfo;d.db.transaction(func tion(b){b.executeSql("SELECT key FROM "+d.storeName,[],function(b,c){for(var d=[ ],e=0;e<c.rows.length;e++)d.push(c.rows.item(e).key);a(d)},function(a,b){c(b)})} )}).catch(c)});return j(c,a),c}function Z(a){var b=this,c={};if(a)for(var d in a )c[d]=a[d];return c.keyPrefix=c.name+"/",c.storeName!==b._defaultConfig.storeNam e&&(c.keyPrefix+=c.storeName+"/"),b._dbInfo=c,c.serializer=La,na.resolve()}funct ion $(a){var b=this,c=b.ready().then(function(){for(var a=b._dbInfo.keyPrefix,c= localStorage.length-1;c>=0;c--){var d=localStorage.key(c);0===d.indexOf(a)&&loca lStorage.removeItem(d)}});return j(c,a),c}function _(a,b){var c=this;a=l(a);var d=c.ready().then(function(){var b=c._dbInfo,d=localStorage.getItem(b.keyPrefix+a );return d&&(d=b.serializer.deserialize(d)),d});return j(d,b),d}function aa(a,b) {var c=this,d=c.ready().then(function(){for(var b=c._dbInfo,d=b.keyPrefix,e=d.le ngth,f=localStorage.length,g=1,h=0;h<f;h++){var i=localStorage.key(h);if(0===i.i ndexOf(d)){var j=localStorage.getItem(i);if(j&&(j=b.serializer.deserialize(j)),v oid 0!==(j=a(j,i.substring(e),g++)))return j}}});return j(d,b),d}function ba(a,b ){var c=this,d=c.ready().then(function(){var b,d=c._dbInfo;try{b=localStorage.ke y(a)}catch(a){b=null}return b&&(b=b.substring(d.keyPrefix.length)),b});return j( d,b),d}function ca(a){var b=this,c=b.ready().then(function(){for(var a=b._dbInfo ,c=localStorage.length,d=[],e=0;e<c;e++)0===localStorage.key(e).indexOf(a.keyPre fix)&&d.push(localStorage.key(e).substring(a.keyPrefix.length));return d});retur n j(c,a),c}function da(a){var b=this,c=b.keys().then(function(a){return a.length });return j(c,a),c}function ea(a,b){var c=this;a=l(a);var d=c.ready().then(funct ion(){var b=c._dbInfo;localStorage.removeItem(b.keyPrefix+a)});return j(d,b),d}f unction fa(a,b,c){var d=this;a=l(a);var e=d.ready().then(function(){void 0===b&& (b=null);var c=b;return new na(function(e,f){var g=d._dbInfo;g.serializer.serial ize(b,function(b,d){if(d)f(d);else try{localStorage.setItem(g.keyPrefix+a,b),e(c )}catch(a){"QuotaExceededError"!==a.name&&"NS_ERROR_DOM_QUOTA_REACHED"!==a.name| |f(a),f(a)}})})});return j(e,c),e}function ga(a,b){a[b]=function(){var c=argumen ts;return a.ready().then(function(){return a[b].apply(a,c)})}}function ha(){for( var a=1;a<arguments.length;a++){var b=arguments[a];if(b)for(var c in b)b.hasOwnP roperty(c)&&(Ua(b[c])?arguments[0][c]=b[c].slice():arguments[0][c]=b[c])}return arguments[0]}function ia(a){for(var b in Pa)if(Pa.hasOwnProperty(b)&&Pa[b]===a)r eturn!0;return!1}var ja="function"==typeof Symbol&&"symbol"==typeof Symbol.itera tor?function(a){return typeof a}:function(a){return a&&"function"==typeof Symbol &&a.constructor===Symbol&&a!==Symbol.prototype?"symbol":typeof a},ka=e();"undefi ned"==typeof Promise&&a(3);var la,ma,na=Promise,oa="local-forage-detect-blob-sup port",pa=Object.prototype.toString,qa="readonly",ra="readwrite",sa={_driver:"asy ncStorage",_initStorage:C,iterate:E,getItem:D,setItem:F,removeItem:G,clear:H,len gth:I,key:J,keys:K},ta="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123 456789+/",ua="~~local_forage_type~",va=/^~~local_forage_type~([^~]+)~/,wa="__lfs c__:",xa=wa.length,ya="arbf",za="blob",Aa="si08",Ba="ui08",Ca="uic8",Da="si16",E a="si32",Fa="ur16",Ga="ui32",Ha="fl32",Ia="fl64",Ja=xa+ya.length,Ka=Object.proto type.toString,La={serialize:N,deserialize:O,stringToBuffer:L,bufferToString:M},M a={_driver:"webSQLStorage",_initStorage:P,iterate:R,getItem:Q,setItem:T,removeIt em:U,clear:V,length:W,key:X,keys:Y},Na={_driver:"localStorageWrapper",_initStora ge:Z,iterate:aa,getItem:_,setItem:fa,removeItem:ea,clear:$,length:da,key:ba,keys :ca},Oa={},Pa={INDEXEDDB:"asyncStorage",LOCALSTORAGE:"localStorageWrapper",WEBSQ L:"webSQLStorage"},Qa=[Pa.INDEXEDDB,Pa.WEBSQL,Pa.LOCALSTORAGE],Ra=["clear","getI tem","iterate","key","keys","length","removeItem","setItem"],Sa={description:"", driver:Qa.slice(),name:"localforage",size:4980736,storeName:"keyvaluepairs",vers ion:1},Ta={};Ta[Pa.INDEXEDDB]=f(),Ta[Pa.WEBSQL]=g(),Ta[Pa.LOCALSTORAGE]=h();var Ua=Array.isArray||function(a){return"[object Array]"===Object.prototype.toString .call(a)},Va=function(){function a(b){d(this,a),this.INDEXEDDB=Pa.INDEXEDDB,this .LOCALSTORAGE=Pa.LOCALSTORAGE,this.WEBSQL=Pa.WEBSQL,this._defaultConfig=ha({},Sa ),this._config=ha({},this._defaultConfig,b),this._driverSet=null,this._initDrive r=null,this._ready=!1,this._dbInfo=null,this._wrapLibraryMethodsWithReady(),this .setDriver(this._config.driver).catch(function(){})}return a.prototype.config=fu nction(a){if("object"===(void 0===a?"undefined":ja(a))){if(this._ready)return ne w Error("Can't call config() after localforage has been used.");for(var b in a){ if("storeName"===b&&(a[b]=a[b].replace(/\W/g,"_")),"version"===b&&"number"!=type of a[b])return new Error("Database version must be a number.");this._config[b]=a [b]}return!("driver"in a&&a.driver)||this.setDriver(this._config.driver)}return" string"==typeof a?this._config[a]:this._config},a.prototype.defineDriver=functio n(a,b,c){var d=new na(function(b,c){try{var d=a._driver,e=new Error("Custom driv er not compliant; see https://mozilla.github.io/localForage/#definedriver"),f=ne w Error("Custom driver name already in use: "+a._driver);if(!a._driver)return vo id c(e);if(ia(a._driver))return void c(f);for(var g=Ra.concat("_initStorage"),h= 0;h<g.length;h++){var i=g[h];if(!i||!a[i]||"function"!=typeof a[i])return void c (e)}var j=function(c){Ta[d]=c,Oa[d]=a,b()};"_support"in a?a._support&&"function" ==typeof a._support?a._support().then(j,c):j(!!a._support):j(!0)}catch(a){c(a)}} );return k(d,b,c),d},a.prototype.driver=function(){return this._driver||null},a. prototype.getDriver=function(a,b,c){var d=this,e=na.resolve().then(function(){if (!ia(a)){if(Oa[a])return Oa[a];throw new Error("Driver not found.")}switch(a){ca se d.INDEXEDDB:return sa;case d.LOCALSTORAGE:return Na;case d.WEBSQL:return Ma}} );return k(e,b,c),e},a.prototype.getSerializer=function(a){var b=na.resolve(La); return k(b,a),b},a.prototype.ready=function(a){var b=this,c=b._driverSet.then(fu nction(){return null===b._ready&&(b._ready=b._initDriver()),b._ready});return k( c,a,a),c},a.prototype.setDriver=function(a,b,c){function d(){g._config.driver=g. driver()}function e(a){return g._extend(a),d(),g._ready=g._initStorage(g._config ),g._ready}function f(a){return function(){function b(){for(;c<a.length;){var f= a[c];return c++,g._dbInfo=null,g._ready=null,g.getDriver(f).then(e).catch(b)}d() ;var h=new Error("No available storage method found.");return g._driverSet=na.re ject(h),g._driverSet}var c=0;return b()}}var g=this;Ua(a)||(a=[a]);var h=this._g etSupportedDrivers(a),i=null!==this._driverSet?this._driverSet.catch(function(){ return na.resolve()}):na.resolve();return this._driverSet=i.then(function(){var a=h[0];return g._dbInfo=null,g._ready=null,g.getDriver(a).then(function(a){g._dr iver=a._driver,d(),g._wrapLibraryMethodsWithReady(),g._initDriver=f(h)})}).catch (function(){d();var a=new Error("No available storage method found.");return g._ driverSet=na.reject(a),g._driverSet}),k(this._driverSet,b,c),this._driverSet},a. prototype.supports=function(a){return!!Ta[a]},a.prototype._extend=function(a){ha (this,a)},a.prototype._getSupportedDrivers=function(a){for(var b=[],c=0,d=a.leng th;c<d;c++){var e=a[c];this.supports(e)&&b.push(e)}return b},a.prototype._wrapLi braryMethodsWithReady=function(){for(var a=0;a<Ra.length;a++)ga(this,Ra[a])},a.p rototype.createInstance=function(b){return new a(b)},a}(),Wa=new Va;b.exports=Wa },{3:3}]},{},[4])(4)});
OLDNEW
« no previous file with comments | « lib/io.js ('k') | metadata.edge » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld