Comments (7)
it's freaking ugly, but something like this might work:
http://stackoverflow.com/a/1009988/3823857
we could possibly modify it to handle multiple invocations in the same function by looking at line number, kind of like the console does?!
from console.label.
still looking close to impossible, but this gives some hope:
http://stackoverflow.com/a/10276296/3823857
from console.label.
ok, taking a different tack:
find the line number this was called from.
then use one of the tricks above to turn the calling function into a string
use the line number to figure out what line in that string it was invoked from
then use a basic regexp within that line to find "console.label(", and take whatever's inside the parens.
i'm not sure if getting the line number is the global line number, or the line number within that function.
either way, worth investigating:
http://stackoverflow.com/a/3806596/3823857
http://stackoverflow.com/questions/14172455/get-name-and-line-of-calling-function-in-node-js
caveat: we might have to handle this differently if it's in the global scope.
from console.label.
this looks super promising!!
https://github.com/stacktracejs/stacktrace.js
from console.label.
oh my gosh, yes, this looks soooo good:
https://www.stacktracejs.com/
from console.label.
Actually you can do this?
const myVar = 'Hello'
Object.keys({myVar})[0]
// returns "myVar"
Do you want me to implement it @ClimbsRocks ?
from console.label.
Omg, brilliant- yes please, @ans-4175 ! That's a much cleaner implementation than I had in mind.
from console.label.
Related Issues (3)
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from console.label.