Last active
August 29, 2015 14:14
-
-
Save antyakushev/2d7fce5da410f9eb2e26 to your computer and use it in GitHub Desktop.
Coffee Script debug functions
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
augment: (withFn) -> | |
for name of @ | |
fn = @[name] | |
if typeof fn is 'function' | |
@[name] = ((name, fn) -> | |
console.log "augmenting " + name | |
args = arguments | |
-> | |
withFn.apply @, args | |
return fn.apply @, arguments | |
)(name, fn) | |
stackTrace: -> | |
e = new Error('err'); | |
stack = e.stack.replace(/^[^\(]+?[\n$]/gm, '') | |
.replace(/^\s+at\s+/gm, '') | |
.replace(/^Object.<anonymous>\s*\(/gm, '{anonymous}()@') | |
.split('\n') | |
console.log stack | |
debug: -> | |
@augment (name, fn) -> | |
console.log "calling " + name | |
@stackTrace() if name is 'clear' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment