blob: 837f0b75e7738dc2b47e7c17f07060c9a511416c [file] [log] [blame]
'use strict';(function(d){function O(a){return function(b){return a.apply(b,la.call(arguments,1))}}function P(){var a=this;ca.call(this,function(b,m){a[E]=b;a[Q]=m})}function V(a){try{F(a,e,function(){})}catch(b){}}function q(){this.back=this.front={elements:new da,next:e};this.size=this.cursor=0}function v(a,b,m){a=a===e?{}:a;var c=b===e?{}:b;b=c.size;c=c.highWaterMark;c===e&&(c=1);this[p]=0;this[p]=this[p]&-7|0;this[u]=e;this[K]=e;this[y]=e;var d=a.type;if("bytes"===String(d))throw new G("bytes type is not yet implemented");
if(d!==e)throw new G("Invalid type is specified");this[y]=new L(this,a,b,c,m)}function L(a,b,m,d){if(!1===B(a))throw new c("Illegal constructor");if(a[y]!==e)throw new c("Illegal constructor");this[k]=a;this[W]=b;this[z]=new q;this[H]=0;this[g]=0;m=ma(m,d);this[ea]=m.size;this[fa]=m.highWaterMark;var R=this;b=na(b,"start",this,"underlyingSource.start");F(C(b),function(){R[g]|=1;M(R)},function(b){0===h(a)&&A(R,b)})}function oa(a,b){a[z]=new q;return ga(a[W],"cancel",b,"underlyingSource.cancel")}function N(a){if(!1===
B(a))throw new c("ReadableStreamReader constructor argument is not a readable stream");if(!0===I(a))throw new c("ReadableStreamReader constructor can only accept readable streams that are not yet locked to a reader");this[x]=a;a[u]=this;switch(h(a)){case 0:this[t]=new P;break;case 1:this[t]=C(e);break;case 2:this[t]=n(a[K]),V(this[t])}this[r]=new q}function X(a){return new N(a)}function S(a,b){a[p]|=1;var m=h(a);if(1===m)return C(e);if(2===m)return n(a[K]);Y(a);a=oa(a[y],b);return F(a,function(){return e})}
function T(a){var b=a[k];a[g]|=2;0===a[z].length&&Y(b)}function U(a,b){var m=a[k];if(!0===I(m)&&0<m[u][r].length)m[u][r].shift()[E]({value:b,done:!1});else{var c=1,d=a[ea];if(d!==e)try{c=d(b)}catch(w){throw 0===h(m)&&A(a,w),w;}try{c=Z(c);if(ha(c)||c===+pa||0>c)throw new G("The return value of a queuing strategy's size function must be a finite, non-NaN, non-negative number");a[H]+=c;a[z].push({value:b,size:c})}catch(w){throw 0===h(m)&&A(a,w),w;}}M(a)}function h(a){return(a[p]&6)>>1}function A(a,b){a[z]=
new q;qa(a[k],b)}function qa(a,b){a[K]=b;a[p]=a[p]&-7|4;a=a[u];if(a===e)return e;!0===D(a)&&(a[r].forEach(function(a){a[Q](b)}),a[r]=new q);a[t][Q](b);V(a[t])}function Y(a){a[p]=a[p]&-7|2;a=a[u];if(a===e)return e;!0===D(a)&&(a[r].forEach(function(a){a[E]({value:e,done:!0})}),a[r]=new q);a[t][E](e)}function aa(a){var b=h(a[k]);return 1===b?0:2===b?null:a[fa]-a[H]}function B(a){return J(a,y)}function I(a){return a[u]!==e}function D(a){return J(a,r)}function ba(a){a=a[x];a[p]|=1;if(1===h(a))return C({value:e,
done:!0});if(2===h(a))return n(a[K]);a=a[y];var b=a[k];if(0<a[z].length){var c=a[z].shift();a[H]-=c.size;c=c.value;a[g]&2&&0===a[z].length?Y(b):M(a);a=C({value:c,done:!1})}else c=new P,b[u][r].push(c),M(a),a=c;return a}function M(a){if(!1===ra(a))return e;if(a[g]&4)return a[g]|=8,e;a[g]|=4;var b=ga(a[W],"pull",a,"underlyingSource.pull");F(b,function(){a[g]&=-5;a[g]&8&&(a[g]&=-9,M(a))},function(b){0===h(a[k])&&A(a,b)})}function ra(a){var b=a[k],c=h(b);return 1===c||2===c||a[g]&2||!(a[g]&1)?!1:!0===
I(b)&&0<b[u][r].length||0<aa(a)?!0:!1}function ia(a){function b(){return F(ba(c),function(a){var b=a.value;!0===a.done&&!1===d&&(!1===f&&T(q),!1===g&&T(r),d=!0);!0!==d&&(!1===f&&U(q,b),!1===g&&U(r,b))})}var c=X(a),d=!1,f=!1,g=!1,h,l,k=new P,n=new v({pull:b,cancel:function(b){f=!0;h=b;!0===g&&(b=S(a,[h,l]),k[E](b));return k}}),p=new v({pull:b,cancel:function(b){g=!0;l=b;!0===f&&(b=S(a,[h,l]),k[E](b));return k}}),q=n[y],r=p[y];F(c[t],e,function(a){!0!==d&&(A(q,a),A(r,a),d=!0)});return[n,p]}function ma(a,
b){if(a!==e&&"function"!==typeof a)throw new c("A queuing strategy's size property must be a function");b=Z(b);if(ha(b))throw new G("A queueing strategy's highWaterMark property must be a nonnegative, non-NaN number");if(0>b)throw new G("A queueing strategy's highWaterMark property must be a nonnegative, non-NaN number");return{size:a,highWaterMark:b}}function na(a,b,d,f){b=a[b];if(b===e)return e;if("function"!==typeof b)throw new c(ja(f));return ka(b,a,d)}function ga(a,b,d,f){try{var g=a[b]}catch(w){return n(w)}if(g===
e)return C(e);if("function"!==typeof g)return n(new c(ja(f)));try{return C(ka(g,a,d))}catch(w){return n(w)}}var l=d.Object.defineProperty,da=d.Array,f=d.Symbol,la=d.Array.prototype.slice,ca=d.Promise,E=f("[[Resolve]]"),Q=f("[[Reject]]");P.prototype=ca.prototype;l(q.prototype,"length",{get:function(){return this.size}});q.prototype.push=function(a){++this.size;if(16384===this.back.elements.length){var b=this.back;this.back={elements:new da,next:e};b.next=this.back}this.back.elements.push(a)};q.prototype.shift=
function(){--this.size;this.front.elements.length===this.cursor&&(this.front=this.front.next,this.cursor=0);var a=this.front.elements[this.cursor];this.front.elements[this.cursor]=e;++this.cursor;return a};q.prototype.forEach=function(a){for(var b=this.cursor,c=this.front,d=c.elements;b!==d.length||c.next!==e;)b===d.length&&(c=c.next,d=c.elements,b=0),a(d[b]),++b};q.prototype.peek=function(){return this.front.elements.length===this.cursor?this.front.next.elements[0]:this.front.elements[this.cursor]};
var u=f("[[reader]]"),K=f("[[storedError]]"),y=f("[[controller]]"),t=f("[[closedPromise]]"),x=f("[[ownerReadableStream]]"),r=f("[[readRequests]]"),p=f("bit field for [[state]] and [[disturbed]]"),W=f("[[underlyingSource]]"),k=f("[[controlledReadableStream]]"),z=f("[[queue]]"),H=f("[[totalQueuedSize]]"),ea=f("[[strategySize]]"),fa=f("[[strategyHWM]]"),g=f("bit field for [[started]], [[closeRequested]], [[pulling]], [[pullAgain]]"),e=d.undefined,pa=d.Infinity,J=O(d.Object.hasOwnProperty),ka=O(d.Function.prototype.call);
O(d.Function.prototype.apply);var c=d.TypeError,G=d.RangeError,Z=d.Number,ha=Z.isNaN,f=d.Promise,F=O(f.prototype.then),C=f.resolve.bind(f),n=f.reject.bind(f),ja=function(a){return a+" must be a function or undefined"};l(v.prototype,"locked",{enumerable:!1,configurable:!0,get:function(){if(!1===B(this))throw new c("Illegal invocation");return I(this)}});l(v.prototype,"cancel",{enumerable:!1,configurable:!0,writable:!0,value:function(a){return!1===B(this)?n(new c("Illegal invocation")):!0===I(this)?
n(new c("Cannot cancel a readable stream that is locked to a reader")):S(this,a)}});l(v.prototype,"getReader",{enumerable:!1,configurable:!0,writable:!0,value:function(a){a=(a===e?{}:a).mode;if(!1===B(this))throw new c("Illegal invocation");if("byob"===a)throw new c("This readable stream does not support BYOB readers");if(a===e)return X(this);throw new G('Invalid reader mode given: expected undefined or "byob"');}});l(v.prototype,"pipeThrough",{enumerable:!1,configurable:!0,writable:!0,value:function(a,
b){throw new c("pipeThrough not implemented");}});l(v.prototype,"pipeTo",{enumerable:!1,configurable:!0,writable:!0,value:function(a){throw new c("pipeTo not implemented");}});l(v.prototype,"tee",{enumerable:!1,configurable:!0,writable:!0,value:function(){if(!1===B(this))throw new c("Illegal invocation");return ia(this)}});l(L.prototype,"desiredSize",{enumerable:!1,configurable:!0,get:function(){if(!1===J(this,k))throw new c("Illegal invocation");return aa(this)}});l(L.prototype,"close",{enumerable:!1,
configurable:!0,writable:!0,value:function(){if(!1===J(this,k))throw new c("Illegal invocation");var a=this[k];if(this[g]&2)throw new c("Cannot close a readable stream that has already been requested to be closed");a=h(a);if(2===a)throw new c("Cannot close an errored readable stream");if(1===a)throw new c("Cannot close a closed readable stream");return T(this)}});l(L.prototype,"enqueue",{enumerable:!1,configurable:!0,writable:!0,value:function(a){if(!1===J(this,k))throw new c("Illegal invocation");
var b=this[k];if(this[g]&2)throw new c("Cannot enqueue a chunk into a readable stream that is closed or has been requested to be closed");b=h(b);if(2===b)throw new c("Cannot enqueue a chunk into an errored readable stream");if(1===b)throw new c("Cannot enqueue a chunk into a closed readable stream");return U(this,a)}});l(L.prototype,"error",{enumerable:!1,configurable:!0,writable:!0,value:function(a){if(!1===J(this,k))throw new c("Illegal invocation");var b=h(this[k]);if(2===b)throw new c("Cannot error a readable stream that is already errored");
if(1===b)throw new c("Cannot error a close readable stream");return A(this,a)}});l(N.prototype,"closed",{enumerable:!1,configurable:!0,get:function(){return!1===D(this)?n(new c("Illegal invocation")):this[t]}});l(N.prototype,"cancel",{enumerable:!1,configurable:!0,writable:!0,value:function(a){return!1===D(this)?n(new c("Illegal invocation")):this[x]===e?n(new c("This readable stream reader has been released and cannot be used to cancel its previous owner stream")):S(this[x],a)}});l(N.prototype,"read",
{enumerable:!1,configurable:!0,writable:!0,value:function(){return!1===D(this)?n(new c("Illegal invocation")):this[x]===e?n(new c("This readable stream reader has been released and cannot be used to read from its previous owner stream")):ba(this)}});l(N.prototype,"releaseLock",{enumerable:!1,configurable:!0,writable:!0,value:function(){if(!1===D(this))throw new c("Illegal invocation");if(this[x]===e)return e;if(0<this[r].length)throw new c("Cannot release a readable stream reader when it still has outstanding read() calls that have not yet settled");
if(0===h(this[x])){var a=new c("This readable stream reader has been released and cannot be used to monitor the stream's state");this[t][Q](a)}else this[t]=n(new c("This readable stream reader has been released and cannot be used to monitor the stream's state"));V(this[t]);this[x][u]=e;this[x]=e}});l(d,"ReadableStream",{value:v,enumerable:!1,configurable:!0,writable:!0});d.AcquireReadableStreamDefaultReader=X;d.IsReadableStream=B;d.IsReadableStreamDisturbed=function(a){return a[p]&1};d.IsReadableStreamLocked=
I;d.IsReadableStreamReadable=function(a){return 0===h(a)};d.IsReadableStreamClosed=function(a){return 1===h(a)};d.IsReadableStreamErrored=function(a){return 2===h(a)};d.IsReadableStreamDefaultReader=D;d.ReadableStreamDefaultReaderRead=ba;d.ReadableStreamTee=ia;d.ReadableStreamDefaultControllerClose=T;d.ReadableStreamDefaultControllerGetDesiredSize=aa;d.ReadableStreamDefaultControllerEnqueue=U;d.ReadableStreamDefaultControllerError=A})(this);