Skip to content

Instantly share code, notes, and snippets.

@eugenf
Last active February 21, 2016 23:56
Show Gist options
  • Save eugenf/40cd6dc861e90d594d3e to your computer and use it in GitHub Desktop.
Save eugenf/40cd6dc861e90d594d3e to your computer and use it in GitHub Desktop.
get function name
# get class/function names helper
module.exports = (fn) ->
f = typeof fn == 'function'
s = f and (fn.name and [
''
fn.name
] or fn.toString().match(/function ([^\(]+)/))
!f and 'not a function' or s and s[1] or 'anonymous'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment