Created
November 23, 2017 18:51
-
-
Save awkward-ninja/d996f2714d2233335a6ff22be547518b to your computer and use it in GitHub Desktop.
Angular-style parameter name extraction (in ES6)
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
const | |
PARAMS_RE = /^[^(]*\(([^)]*)\)/m, | |
COMMENT_RE = /((\/\/.*$)|(\/\*.*?\*\/))/mg, | |
SPACE_RE = /\s*/mg | |
const params = String( pred ) | |
.match( PARAMS_RE )[ 1 ] | |
.replace( COMMENT_RE, '' ) | |
.replace( SPACE_RE, '' ) | |
.split( ',' ) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment