What does line number, or filename for that matter, mean when a file has gone through one or more transpilation and/or minification passes? Is the notion that the first processor that touches the file would substitute those values?
Bob On Fri, Aug 24, 2018 at 11:34 PM Claude Pache <claude.pa...@gmail.com> wrote: > > > Le 24 août 2018 à 05:55, J Decker <d3c...@gmail.com> a écrit : > > On Thu, Aug 23, 2018 at 5:26 PM Aaron Gray <aaronngray.li...@gmail.com> > wrote: > >> I am debugging existing code that I have modularized, and am class'izing >> that has unittests and it just would have been very useful to have this >> facility. >> > In a browser, console.log is usually associated with the file and line > number anyway; which includes using devtools with node.... but it would be > handy for logging. with V8 there is console.trace; which spits out the > stack trace too... before I discovered that I did a logging function > like... > > (from > https://stackoverflow.com/questions/591857/how-can-i-get-a-javascript-stack-trace-when-i-throw-an-exception > ) > function stackTrace() { var err = new Error(); return err.stack; } // > parse stack to get frame-1 online > > // or maybe just frame-1... > function stackTrace() { var err = new Error(); return err.stack.split( > "\n" )[1]; } > > --- > function stacktrace() { > function st2(f) { > return !f ? [] : > st2(f.caller).concat([f.toString().split('(')[0].substring(9) + > '(' + f.arguments.join(',') + ')']); > } > return st2(arguments.callee.caller); > } > > EDIT 2 (2017) : > > In all modern browsers you can simply call: console.trace(); (MDN > Reference) > --- > > Although I do still miss just being able to get __FILE__ and __LINE__ > > > > See also: > > https://github.com/tc39/proposal-error-stacks > > If/when that proposal is implemented, you'll have a simple way to get a > *structured* representation of the trace: > > ```js > System.getTrace(new Error) > ``` > > from which you can much more easily extract line number, filename, etc. > > —Claude >
_______________________________________________ es-discuss mailing list es-discuss@mozilla.org https://mail.mozilla.org/listinfo/es-discuss