Created
July 25, 2012 22:19
-
-
Save abi/3179061 to your computer and use it in GitHub Desktop.
Debugging in JS/CS
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
// Notify the user (or not?) when there's no console | |
d = function() { | |
// TODO: Update the JS from CS | |
var args; | |
args = 1 <= arguments.length ? [].slice.call(arguments, 0) : []; | |
return console.log.apply(console, args); | |
}; | |
d = (args...) -> | |
# Works in Chrome | |
line = (new Error).stack.split("\n")[2] | |
index = line.indexOf(" at ") | |
remainingLine = line.slice(index + 4, line.length) | |
splitLine = remainingLine.split('/') | |
args.push remainingLine.split('(')[0] + " @ [" + _(splitLine).last().split(')')[0] + "]" | |
console.log.apply console, args |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
hipster