UNPKG

cross-caller

Version:

Gets the caller function, file and line number in all browsers and server environments

3 lines (2 loc) 539 B
var e=/at\s+(.*?)\s+\((.*):(\d*):(\d*)\)/i,n=/at\s+()(.*):(\d*):(\d*)/i,t=/(.*?)(?:\(\))?@(?:(.*?):(\d+)(?::(\d+))?)?/i,i=/at\s*(.*)\s+\((.*):(\d*)()\)/i;function r(r,o){for(var c=r.trim().split("\n"),d=0,s=0;d<c.length;d++){var a=c[d],l=e.exec(a)||n.exec(a)||t.exec(a)||i.exec(a);if(l&&5===l.length&&s++===o)return{function:l[1]||"",file:l[2]||"",line:l[3]||"",position:l[4]||""}}return null}function o(e){return void 0===e&&(e=0),r((new Error).stack||"",e+2)}export{o as getCaller,r as parseCallSite}; //# sourceMappingURL=index.mjs.map