This repository has been archived by the owner on Feb 26, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 408
/
Copy pathlong-stack-trace-zone.min.js
executable file
·15 lines (15 loc) · 2.22 KB
/
long-stack-trace-zone.min.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
/**
* @license
* Copyright Google Inc. 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
*/
!function(t){"function"==typeof define&&define.amd?define(t):t()}(function(){"use strict";
/**
* @license
* Copyright Google Inc. 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
*/var t="\n",a={},r="STACKTRACE TRACKING",e="__SEP_TAG__",n=e+"@[native]",c=function c(){this.error=f(),this.timestamp=new Date};function i(){return new Error(r)}function o(){try{throw i()}catch(t){return t}}var s=i(),_=o(),f=s.stack?i:_.stack?o:i;function u(a){return a.stack?a.stack.split(t):[]}function k(t,r){for(var e=u(r),n=0;n<e.length;n++)a.hasOwnProperty(e[n])||t.push(e[n])}function T(a,r){var c=[r?r.trim():""];if(a)for(var i=(new Date).getTime(),o=0;o<a.length;o++){var s=a[o],_=s.timestamp,f="____________________Elapsed "+(i-_.getTime())+" ms; At: "+_;f=f.replace(/[^\w\d]/g,"_"),c.push(n.replace(e,f)),k(c,s.error),i=_.getTime()}return c.join(t)}Zone.longStackTraceZoneSpec={name:"long-stack-trace",longStackTraceLimit:10,getLongStackTrace:function(t){if(t){var a=t[Zone.__symbol__("currentTaskTrace")];return a?T(a,t.stack):t.stack}},onScheduleTask:function(t,a,r,e){if(Error.stackTraceLimit>0){var n=Zone.currentTask,i=n&&n.data&&n.data.__creationTrace__||[];(i=[new c].concat(i)).length>this.longStackTraceLimit&&(i.length=this.longStackTraceLimit),e.data||(e.data={}),"eventTask"===e.type&&(e.data=Object.assign({},e.data)),e.data.__creationTrace__=i}return t.scheduleTask(r,e)},onHandleError:function(t,a,r,e){if(Error.stackTraceLimit>0){var n=Zone.currentTask||e.task;if(e instanceof Error&&n){var c=T(n.data&&n.data.__creationTrace__,e.stack);try{e.stack=e.longStack=c}catch(t){}}}return t.handleError(r,e)}},function h(){if(!(Error.stackTraceLimit<=0)){var t=[];!function t(a,r){r>0&&(a.push(u((new c).error)),t(a,r-1))}(t,2);for(var i=t[0],o=t[1],s=0;s<i.length;s++)if(-1==(f=i[s]).indexOf(r)){var _=f.match(/^\s*at\s+/);if(_){n=_[0]+e+" (http://localhost)";break}}for(s=0;s<i.length;s++){var f;if((f=i[s])!==o[s])break;a[f]=!0}}}()});