Last active
February 21, 2016 23:56
-
-
Save eugenf/40cd6dc861e90d594d3e to your computer and use it in GitHub Desktop.
get function name
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
# 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