File tree 1 file changed +22
-1
lines changed
1 file changed +22
-1
lines changed Original file line number Diff line number Diff line change @@ -14,10 +14,31 @@ npm test
14
14
15
15
``` js
16
16
var functionRegex = require (' function-regex' );
17
+
18
+ var fixture = function testing (args , opts , dest , cb ) {
19
+ return cb ? {
20
+ opts: [1 ,2 ,3 ];
21
+ } : true ;
22
+ };
23
+
24
+ fixture .toString ().match (functionRegex ());
25
+ // => [1] = 'testing'
26
+ // => [2] = 'args, opts, dest, cb'
27
+ // => [3] = '\n return cb ? {\n opts: [1,2,3],\n args: args\n } : true;\n '
28
+
29
+
30
+ ' function(val, re) { return true; }' .match (functionRegex ());
31
+ // => [1] = ''
32
+ // => [2] = 'val, re'
33
+ // => [3] = ' return true; '
17
34
```
18
35
19
36
20
- ## API / CLI
37
+ ### Matching groups
38
+ + ` [0] ` full function (` 'function(val, re) { return true; }' ` )
39
+ + ` [1] ` function name (` 'testing' ` )
40
+ + ` [2] ` function arguments (` 'args, opts, dest, cb' ` )
41
+ + ` [3] ` function body (` ' return true; ' ` )
21
42
22
43
23
44
## Author
You can’t perform that action at this time.
0 commit comments