yomichan/ext/lib/dexie.min.js

2 lines
53 KiB
JavaScript
Raw Normal View History

2016-11-07 16:21:49 +00:00
!function(a,b){"object"==typeof exports&&"undefined"!=typeof module?module.exports=b():"function"==typeof define&&define.amd?define(b):a.Dexie=b()}(this,function(){"use strict";function d(b,c){return"object"!=typeof c?b:(a(c).forEach(function(a){b[a]=c[a]}),b)}function g(a,b){return f.call(a,b)}function h(b,c){"function"==typeof c&&(c=c(e(b))),a(c).forEach(function(a){j(b,a,c[a])})}function j(a,b,c,e){i(a,b,d(c&&g(c,"get")&&"function"==typeof c.get?{get:c.get,set:c.set,configurable:!0}:{value:c,configurable:!0,writable:!0},e))}function k(a){return{from:function(b){return a.prototype=Object.create(b.prototype),j(a.prototype,"constructor",a),{extend:h.bind(null,a.prototype)}}}}function m(a,b){var d,c=l(a,b);return c||(d=e(a))&&m(d,b)}function o(a,b,c){return n.call(a,b,c)}function p(a,b){return b(a)}function q(a){var b=setTimeout(a,1e3);clearTimeout(b)}function r(a){if(!a)throw new Error("Assertion Failed")}function s(a){c.setImmediate?setImmediate(a):setTimeout(a,0)}function t(a,b){return a.reduce(function(a,c,d){var e=b(c,d);return e&&(a[e[0]]=e[1]),a},{})}function u(a,b){return function(){try{a.apply(this,arguments)}catch(a){b(a)}}}function v(a,b,c){try{a.apply(null,c)}catch(a){b&&b(a)}}function w(a,b){if(g(a,b))return a[b];if(!b)return a;if("string"!=typeof b){for(var c=[],d=0,e=b.length;d<e;++d){var f=w(a,b[d]);c.push(f)}return c}var h=b.indexOf(".");if(h!==-1){var i=a[b.substr(0,h)];return void 0===i?void 0:w(i,b.substr(h+1))}}function x(a,b,c){if(a&&void 0!==b&&!("isFrozen"in Object&&Object.isFrozen(a)))if("string"!=typeof b&&"length"in b){r("string"!=typeof c&&"length"in c);for(var d=0,e=b.length;d<e;++d)x(a,b[d],c[d])}else{var f=b.indexOf(".");if(f!==-1){var g=b.substr(0,f),h=b.substr(f+1);if(""===h)void 0===c?delete a[g]:a[g]=c;else{var i=a[g];i||(i=a[g]={}),x(i,h,c)}}else void 0===c?delete a[b]:a[b]=c}}function y(a,b){"string"==typeof b?x(a,b,void 0):"length"in b&&[].map.call(b,function(b){x(a,b,void 0)})}function z(a){var b={};for(var c in a)g(a,c)&&(b[c]=a[c]);return b}function A(a){if(!a||"object"!=typeof a)return a;var c;if(b(a)){c=[];for(var d=0,e=a.length;d<e;++d)c.push(A(a[d]))}else if(a instanceof Date)c=new Date,c.setTime(a.getTime());else{c=a.constructor?Object.create(a.constructor.prototype):{};for(var f in a)g(a,f)&&(c[f]=A(a[f]))}return c}function B(b,c,d,e){return d=d||{},e=e||"",a(b).forEach(function(a){if(g(c,a)){var f=b[a],h=c[a];"object"==typeof f&&"object"==typeof h&&f&&h&&f.constructor===h.constructor?B(f,h,d,e+a+"."):f!==h&&(d[e+a]=c[a])}else d[e+a]=void 0}),a(c).forEach(function(a){g(b,a)||(d[e+a]=c[a])}),d}function F(a){var c,d,e,f;if(1===arguments.length){if(b(a))return a.slice();if(this===E&&"string"==typeof a)return[a];if(f=D(a)){for(d=[];e=f.next(),!e.done;)d.push(e.value);return d}if(null==a)return[a];if(c=a.length,"number"==typeof c){for(d=new Array(c);c--;)d[c]=a[c];return d}return[a]}for(c=arguments.length,d=new Array(c);c--;)d[c]=arguments[c];return d}function H(a){return G.apply([],a)}function J(a,b){I=a,K=b}function M(){if(L)try{throw M.arguments,new Error}catch(a){return a}return new Error}function N(a,b){var c=a.stack;return c?(b=b||0,0===c.indexOf(a.name)&&(b+=(a.name+a.message).split("\n").length),c.split("\n").slice(b).filter(K).map(function(a){return"\n"+a}).join("")):""}function O(a,b){return function(){return console.warn(a+" is deprecated. See https://github.com/dfahlander/Dexie.js/wiki/Deprecations. "+N(M(),1)),b.apply(this,arguments)}}function T(a,b){this._e=M(),this.name=a,this.message=b}function U(a,b){return a+". Errors: "+b.map(function(a){return a.toString()}).filter(function(a,b,c){return c.indexOf(a)===b}).join("\n")}function V(a,b,c,d){this._e=M(),this.failures=b,this.failedKeys=d,this.successCount=c}function W(a,b){this._e=M(),this.name="BulkError",this.failures=b,this.message=U(a,b)}function _(a,b){if(!a||a instanceof T||a instanceof TypeError||a instanceof SyntaxError||!a.name||!$[a.name])return a;var c=new $[a.name](b||a.message,a);return"stack"in a&&j(c,"stack",{get:function(){return this.inner.stack}}),c}function ba(){}function ca(a){return a}function d
a.onerror=_a(function(c){Pb(c),b._reject(a.error)}),a.onabort=_a(function(a){Pb(a),b.active&&b._reject(new Z.Abort),b.active=!1,b.on("abort").fire(a)}),a.oncomplete=_a(function(){b.active=!1,b._resolve()}),this},_promise:function(a,b,c){var d=this;if(a===P&&this.mode!==P)return ub(new Z.ReadOnly("Transaction is readonly"));if(!this.active)return ub(new Z.TransactionInactive);if(this._locked())return new Ja(function(e,f){d._blockedFuncs.push([function(){d._promise(a,b,c).then(e,f)},Fa])});if(c)return gb(function(){var a=new Ja(function(a,c){d._lock();var e=b(a,c,d);e&&e.then&&e.then(a,c)});return a.finally(function(){return d._unlock()}),a._lib=!0,a});var e=new Ja(function(a,c){var e=b(a,c,d);e&&e.then&&e.then(a,c)});return e._lib=!0,e},abort:function(){this.active&&this._reject(new Z.Abort),this.active=!1},tables:{get:O("Transaction.tables",function(){return D})},table:O("Transaction.table()",function(a){return D[a]})}),h(xa.prototype,function(){function a(a,b,c){var d=a instanceof xa?new ya(a):a;return d._ctx.error=c?new c(b):new TypeError(b),d}function b(a){return new ya(a,function(){return n.only("")}).limit(0)}function c(a){return"next"===a?function(a){return a.toUpperCase()}:function(a){return a.toLowerCase()}}function d(a){return"next"===a?function(a){return a.toLowerCase()}:function(a){return a.toUpperCase()}}function e(a,b,c,d,e,f){for(var g=Math.min(a.length,d.length),h=-1,i=0;i<g;++i){var j=b[i];if(j!==d[i])return e(a[i],c[i])<0?a.substr(0,i)+c[i]+c.substr(i+1):e(a[i],d[i])<0?a.substr(0,i)+d[i]+c.substr(i+1):h>=0?a.substr(0,h)+b[h]+c.substr(h+1):null;e(a[i],j)<0&&(h=i)}return g<d.length&&"next"===f?a+c.substr(a.length):g<a.length&&"prev"===f?a.substr(0,c.length):h<0?null:a.substr(0,h)+d[h]+c.substr(h+1)}function f(b,f,g,h){function r(a){i=c(a),j=d(a),k="next"===a?Ma:Na;var b=g.map(function(a){return{lower:j(a),upper:i(a)}}).sort(function(a,b){return k(a.lower,b.lower)});l=b.map(function(a){return a.upper}),m=b.map(function(a){return a.lower}),o=a,p="next"===a?"":h}var i,j,k,l,m,o,p,q=g.length;if(!g.every(function(a){return"string"==typeof a}))return a(b,Ab);r("next");var s=new ya(b,function(){return n.bound(l[0],m[q-1]+h)});s._ondirectionchange=function(a){r(a)};var t=0;return s._addAlgorithm(function(a,b,c){var d=a.key;if("string"!=typeof d)return!1;var g=j(d);if(f(g,m,t))return!0;for(var h=null,i=t;i<q;++i){var n=e(d,g,l[i],m[i],k,o);null===n&&null===h?t=i+1:(null===h||k(h,n)>0)&&(h=n)}return b(null!==h?function(){a.continue(h+p)}:c),!1}),s}return{between:function(c,d,e,f){e=e!==!1,f=f===!0;try{return Ga(c,d)>0||0===Ga(c,d)&&(e||f)&&(!e||!f)?b(this):new ya(this,function(){return n.bound(c,d,!e,!f)})}catch(b){return a(this,zb)}},equals:function(a){return new ya(this,function(){return n.only(a)})},above:function(a){return new ya(this,function(){return n.lowerBound(a,!0)})},aboveOrEqual:function(a){return new ya(this,function(){return n.lowerBound(a)})},below:function(a){return new ya(this,function(){return n.upperBound(a,!0)})},belowOrEqual:function(a){return new ya(this,function(){return n.upperBound(a)})},startsWith:function(b){return"string"!=typeof b?a(this,Ab):this.between(b,b+xb,!0,!0)},startsWithIgnoreCase:function(a){return""===a?this.startsWith(a):f(this,function(a,b){return 0===a.indexOf(b[0])},[a],xb)},equalsIgnoreCase:function(a){return f(this,function(a,b){return a===b[0]},[a],"")},anyOfIgnoreCase:function(){var a=F.apply(E,arguments);return 0===a.length?b(this):f(this,function(a,b){return b.indexOf(a)!==-1},a,"")},startsWithAnyOfIgnoreCase:function(){var a=F.apply(E,arguments);return 0===a.length?b(this):f(this,function(a,b){return b.some(function(b){return 0===a.indexOf(b)})},a,xb)},anyOf:function(){var c=F.apply(E,arguments),d=Ka;try{c.sort(d)}catch(b){return a(this,zb)}if(0===c.length)return b(this);var e=new ya(this,function(){return n.bound(c[0],c[c.length-1])});e._ondirectionchange=function(a){d="next"===a?Ka:La,c.sort(d)};var f=0;return e._addAlgorithm(function(a,b,e){for(var g=a.key;d(g,c[f])>0;)if(++f,f===c.length)return b(e),!1;return 0===d(g,c[f])||(b(function(){a.continue(c[f])}),!1)}