stacktracejs / stack-generator Goto Github PK
View Code? Open in Web Editor NEWGenerate artificial backtrace by walking arguments.callee.caller chain
Home Page: https://www.stacktracejs.com/#!/docs/stack-generator
License: MIT License
Generate artificial backtrace by walking arguments.callee.caller chain
Home Page: https://www.stacktracejs.com/#!/docs/stack-generator
License: MIT License
Given the function source:
function () {
// set the script that called this function
updateLastScript(script)
// immediately unset it
_setTimeout(function () { updateLastScript(null) }, 0)
cb.apply(this, arguments)
}
this Regex will incorrectly name the function updateLastScript
which is an unfortunate sequence of a comment ending in function
followed by a function call.
stack-generator/stack-generator.js
Line 30 in 1e295b6
a nested function definition can also trip it up:
function () {
function jim() {
// inner
}
more()
statements()
}
The following update fixes these scenarios, correctly returning null
for these two annonymous functions:
- if (/function(?:\s+([\w$]+))+\s*\(/.test(curr.toString())) {
+ if (/^\s*function(?:\s+([\w$]+))+\s*\(/.test(curr.toString())) {
I'm not sure if the "any preceding whitespace" part is strictly necessary but I don't think it hurts to permit that.
I can put together a PR for this including tests but I wanted to post it up as an issue before I get around to that while I work around it.
stack-generator/stack-generator.js
Line 25 in a5cd8e0
Two possible approaches:
Object.prototype.toString.call(arg)
Perhaps an option could be introduced that takes one approach or the other.
Can you please clarify this statement?
If this pertains to the "use strict"
JavaScript directive, what does that entail? Does it work on pages where some of the scripts you're tracing through use strict mode, or does this limitation apply to the calling script only?
Thanks ๐
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.