Its not rocket science :) On Fri, 24 Aug 2018 at 21:59, Ranando King <king...@gmail.com> wrote:
> Realistically, the engine would give back file name and line number (and > hopefully character offset) of the code from the fully translated, fully > minified, actual logic that the engine loaded. Source maps could be used to > convert that obscure value back into actual original source code locations. > It would also be nice if there were a way to perform a lookup at runtime, a > function that takes a function and returns the internal Location object for > that function. > > On Fri, Aug 24, 2018 at 3:16 PM Aaron Gray <aaronngray.li...@gmail.com> > wrote: > >> Ideally at some point we won't be using transpilers anymore ;) >> >> >> On Fri, 24 Aug 2018 at 19:37, Bob Myers <r...@gol.com> wrote: >> >>> 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 >>> >> >> >> -- >> Aaron Gray >> >> Independent Open Source Software Engineer, Computer Language Researcher, >> Information Theorist, and amateur computer scientist. >> _______________________________________________ >> es-discuss mailing list >> es-discuss@mozilla.org >> https://mail.mozilla.org/listinfo/es-discuss >> > -- Aaron Gray Independent Open Source Software Engineer, Computer Language Researcher, Information Theorist, and amateur computer scientist.
_______________________________________________ es-discuss mailing list es-discuss@mozilla.org https://mail.mozilla.org/listinfo/es-discuss