projecte_ionic/node_modules/zone.js/fesm2015/zone-patch-fetch.min.js
2022-02-09 18:30:03 +01:00

13 lines
1.6 KiB
JavaScript
Executable file

"use strict";
/**
* @license Angular v12.0.0-next.0
* (c) 2010-2020 Google LLC. https://angular.io/
* License: MIT
*/
/**
* @license
* Copyright Google LLC All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/Zone.__load_patch("fetch",(t,o,e)=>{let n=t.fetch;if("function"!=typeof n)return;const r=t[e.symbol("fetch")];r&&(n=r);const l=t.Promise,c=e.symbol("thenPatched"),a=e.symbol("fetchTaskScheduling"),s=e.symbol("fetchTaskAborting"),f=t.AbortController,i="function"==typeof f;let h=null;i&&(t.AbortController=function(){const t=new f;return t.signal.abortController=t,t},h=e.patchMethod(f.prototype,"abort",t=>(o,e)=>o.task?o.task.zone.cancelTask(o.task):t.apply(o,e)));const u=function(){};t.fetch=function(){const t=Array.prototype.slice.call(arguments),r=t.length>1?t[1]:null,f=r&&r.signal;return new Promise((r,b)=>{const p=o.current.scheduleMacroTask("fetch",u,{fetchArgs:t},()=>{let s,f=o.current;try{f[a]=!0,s=n.apply(this,t)}catch(t){return void b(t)}finally{f[a]=!1}if(!(s instanceof l)){let t=s.constructor;t[c]||e.patchThen(t)}s.then(t=>{"notScheduled"!==p.state&&p.invoke(),r(t)},t=>{"notScheduled"!==p.state&&p.invoke(),b(t)})},()=>{if(i)if(f&&f.abortController&&!f.aborted&&"function"==typeof f.abortController.abort&&h)try{o.current[s]=!0,h.call(f.abortController)}finally{o.current[s]=!1}else b("cancel fetch need a AbortController.signal");else b("No AbortController supported, can not cancel fetch")});f&&f.abortController&&(f.abortController.task=p)})}});