Last active
June 1, 2016 09:30
-
-
Save friedemannsommer/1d0840b6670abe418ae2 to your computer and use it in GitHub Desktop.
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
function functionArguments(fn) { | |
if (fn.length > 0) { | |
var fnString = Function.prototype.toString.call(fn); | |
var firstIndex = fnString.indexOf('('); | |
var lastIndex = fnString.indexOf(')'); | |
if (firstIndex > -1 && lastIndex > firstIndex) { | |
firstIndex++; | |
return fnString.substr(firstIndex, lastIndex - firstIndex).replace(/\s+/g, '').split(','); | |
} | |
} | |
return []; | |
} |
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
function functionArguments(fn:Function):Array<string> { | |
if (fn.length > 0) { | |
let fnString = Function.prototype.toString.call(fn); | |
let firstIndex = fnString.indexOf('('); | |
let lastIndex = fnString.indexOf(')'); | |
if (firstIndex > -1 && lastIndex > firstIndex) { | |
firstIndex++; | |
return fnString.substr(firstIndex, lastIndex - firstIndex).replace(/\s+/g, '').split(','); | |
} | |
} | |
return []; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment