Last active
May 13, 2016 10:09
-
-
Save Strae/890e7871965805735248543be7fea2df to your computer and use it in GitHub Desktop.
Js debug utilities
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// This small function is somewhere in my code, only purpose is to keep the snippet as small as possible | |
// Return the line number from a new Error().stack element. | |
function _dl(s){ | |
return "\n\t=>\t[" + s.toString() | |
.split(/\r\n|\n/)[1] // get the line | |
.split(/(.*)\((.*)\)(0*)/)[2] // filepath, line number | |
+ ']'; | |
} | |
// ..becose chrome console sometimes jerks with line numbers. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
".source.js": | |
"log with linenumber": | |
"prefix": "dlog" | |
"body": """ | |
console.log('$1', $2, _dl(new Error().stack)); | |
""" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment