Created
September 6, 2017 21:08
-
-
Save kjlape/ac6583af390bbb7f6a4320c5e6801d4a to your computer and use it in GitHub Desktop.
Stack Extractor for old IE/Safari
This file contains hidden or 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
| functionName = (func) -> | |
| stringified = func.toString() | |
| name = _.words(stringified.slice(0, stringified.indexOf('(')))[1] || '~anonymous~' | |
| params = _.words(stringified.match(/\(.*\)/)[0]).join(', ') | |
| "#{name} (#{params}) { ... }" | |
| getCallstack = (caller) -> | |
| caller = arguments.callee.caller if arguments.length == 0 | |
| if caller? | |
| try | |
| [functionName caller].concat getCallstack(caller.caller) | |
| catch error | |
| console.error error | |
| [] | |
| else | |
| [] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment