UNPKG

385 Btext/coffeescriptView Raw
1STRIP_COMMENTS = /((\/\/.*$)|(\/\*[\s\S]*?\*\/))/g
2ARGUMENT_NAMES = /([^\s,]+)/g
3
4module.exports = (func) ->
5 throw new TypeError 'Argument must be a function' unless func instanceof Function
6 fnStr = func.toString().replace(STRIP_COMMENTS, "")
7 result = fnStr.slice(fnStr.indexOf("(") + 1, fnStr.indexOf(")")).match(ARGUMENT_NAMES)
8 result = [] if result is null
9 return result