Skip to content

Instantly share code, notes, and snippets.

@abi
Created July 25, 2012 22:19
Show Gist options
  • Save abi/3179061 to your computer and use it in GitHub Desktop.
Save abi/3179061 to your computer and use it in GitHub Desktop.
Debugging in JS/CS
// 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
@choochootrain
Copy link

hipster

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment