Skip to content

Instantly share code, notes, and snippets.

@kjlape
Created September 6, 2017 21:08
Show Gist options
  • Select an option

  • Save kjlape/ac6583af390bbb7f6a4320c5e6801d4a to your computer and use it in GitHub Desktop.

Select an option

Save kjlape/ac6583af390bbb7f6a4320c5e6801d4a to your computer and use it in GitHub Desktop.
Stack Extractor for old IE/Safari
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