Skip to content

Commit 21cdea5

Browse files
author
tunnckoCore
committed
add docs
1 parent 35f2328 commit 21cdea5

File tree

1 file changed

+22
-1
lines changed

1 file changed

+22
-1
lines changed

readme.md

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,31 @@ npm test
1414
1515
```js
1616
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; '
1734
```
1835

1936

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; '`)
2142

2243

2344
## Author

0 commit comments

Comments
 (0)