forked from zhurui/management
3 lines
4.9 KiB
JavaScript
3 lines
4.9 KiB
JavaScript
|
!function(e,t){"use strict";"function"==typeof define&&define.amd?define("stackframe",[],t):"object"==typeof exports?module.exports=t():e.StackFrame=t()}(this,function(){"use strict";function e(e){return!isNaN(parseFloat(e))&&isFinite(e)}function t(e){return e.charAt(0).toUpperCase()+e.substring(1)}function r(e){return function(){return this[e]}}function n(e){if(e instanceof Object)for(var r=0;r<c.length;r++)e.hasOwnProperty(c[r])&&void 0!==e[c[r]]&&this["set"+t(c[r])](e[c[r]])}var i=["isConstructor","isEval","isNative","isToplevel"],a=["columnNumber","lineNumber"],o=["fileName","functionName","source"],s=["args"],c=i.concat(a,o,s);n.prototype={getArgs:function(){return this.args},setArgs:function(e){if("[object Array]"!==Object.prototype.toString.call(e))throw new TypeError("Args must be an Array");this.args=e},getEvalOrigin:function(){return this.evalOrigin},setEvalOrigin:function(e){if(e instanceof n)this.evalOrigin=e;else{if(!(e instanceof Object))throw new TypeError("Eval Origin must be an Object or StackFrame");this.evalOrigin=new n(e)}},toString:function(){var t=this.getFunctionName()||"{anonymous}",r="("+(this.getArgs()||[]).join(",")+")",n=this.getFileName()?"@"+this.getFileName():"",i=e(this.getLineNumber())?":"+this.getLineNumber():"",a=e(this.getColumnNumber())?":"+this.getColumnNumber():"";return t+r+n+i+a}};for(var u=0;u<i.length;u++)n.prototype["get"+t(i[u])]=r(i[u]),n.prototype["set"+t(i[u])]=function(e){return function(t){this[e]=Boolean(t)}}(i[u]);for(var f=0;f<a.length;f++)n.prototype["get"+t(a[f])]=r(a[f]),n.prototype["set"+t(a[f])]=function(t){return function(r){if(!e(r))throw new TypeError(t+" must be a Number");this[t]=Number(r)}}(a[f]);for(var p=0;p<o.length;p++)n.prototype["get"+t(o[p])]=r(o[p]),n.prototype["set"+t(o[p])]=function(e){return function(t){this[e]=String(t)}}(o[p]);return n}),function(e,t){"use strict";"function"==typeof define&&define.amd?define("error-stack-parser",["stackframe"],t):"object"==typeof exports?module.exports=t(require("stackframe")):e.ErrorStackParser=t(e.StackFrame)}(this,function(e){"use strict";var t=/(^|@)\S+\:\d+/,r=/^\s*at .*(\S+\:\d+|\(native\))/m,n=/^(eval@)?(\[native code\])?$/;return{parse:function(e){if("undefined"!=typeof e.stacktrace||"undefined"!=typeof e["opera#sourceloc"])return this.parseOpera(e);if(e.stack&&e.stack.match(r))return this.parseV8OrIE(e);if(e.stack)return this.parseFFOrSafari(e);throw new Error("Cannot parse given Error object")},extractLocation:function(e){if(e.indexOf(":")===-1)return[e];var t=/(.+?)(?:\:(\d+))?(?:\:(\d+))?$/,r=t.exec(e.replace(/[\(\)]/g,""));return[r[1],r[2]||void 0,r[3]||void 0]},parseV8OrIE:function(t){var n=t.stack.split("\n").filter(function(e){return!!e.match(r)},this);return n.map(function(t){t.indexOf("(eval ")>-1&&(t=t.replace(/eval code/g,"eval").replace(/(\(eval at [^\()]*)|(\)\,.*$)/g,""));var r=t.replace(/^\s+/,"").replace(/\(eval code/g,"("),n=r.match(/ (\((.+):(\d+):(\d+)\)$)/);r=n?r.replace(n[0],""):r;var i=r.split(/\s+/).slice(1),a=this.extractLocation(n?n[1]:i.pop()),o=i.join(" ")||void 0,s=["eval","<anonymous>"].indexOf(a[0])>-1?void 0:a[0];return new e({functionName:o,fileName:s,lineNumber:a[1],columnNumber:a[2],source:t})},this)},parseFFOrSafari:function(t){var r=t.stack.split("\n").filter(function(e){return!e.match(n)},this);return r.map(function(t){if(t.indexOf(" > eval")>-1&&(t=t.replace(/ line (\d+)(?: > eval line \d+)* > eval\:\d+\:\d+/g,":$1")),t.indexOf("@")===-1&&t.indexOf(":")===-1)return new e({functionName:t});var r=/((.*".+"[^@]*)?[^@]*)(?:@)/,n=t.match(r),i=n&&n[1]?n[1]:void 0,a=this.extractLocation(t.replace(r,""));return new e({functionName:i,fileName:a[0],lineNumber:a[1],columnNumber:a[2],source:t})},this)},parseOpera:function(e){return!e.stacktrace||e.message.indexOf("\n")>-1&&e.message.split("\n").length>e.stacktrace.split("\n").length?this.parseOpera9(e):e.stack?this.parseOpera11(e):this.parseOpera10(e)},parseOpera9:function(t){for(var r=/Line (\d+).*script (?:in )?(\S+)/i,n=t.message.split("\n"),i=[],a=2,o=n.length;a<o;a+=2){var s=r.exec(n[a]);s&&i.push(new e({fileName:s[2],lin
|
||
|
//# sourceMappingURL=error-stack-parser.min.js.map
|