Skip to content

Instantly share code, notes, and snippets.

@Strae
Last active May 13, 2016 10:09
Show Gist options
  • Save Strae/890e7871965805735248543be7fea2df to your computer and use it in GitHub Desktop.
Save Strae/890e7871965805735248543be7fea2df to your computer and use it in GitHub Desktop.
Js debug utilities
// 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.
".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