Last active
November 11, 2024 07:16
-
-
Save samthor/a48c38a31715e9fdda3310a4e2a17ccf to your computer and use it in GitHub Desktop.
This file contains hidden or 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
const functionMatch = /^function\s*\w*\(([\w\s,]+)\) {/; | |
/** | |
* @param {!Function} fn | |
* @return {!Array<string>} array of simple arg names (no =, ... etc) | |
*/ | |
function simpleArgNames(fn) { | |
const match = functionRe.exec(fn.toString()); | |
if (!match) { return []; } | |
const args = match[1].split(',').map((x) => x.trim()); | |
if (args.length && args[args.length - 1] === '') { | |
args.pop(); | |
} | |
return args; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment