Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Require Node.js 8, add TypeScript definition #1

Merged
merged 2 commits into from
Apr 18, 2019
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Fixes after review
  • Loading branch information
BendingBender committed Apr 17, 2019
commit 86880b91e675dcefbf6478feea5371dbc00e4ad6
8 changes: 4 additions & 4 deletions index.d.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
declare namespace execall {
interface Match {
match: string;
sub: string[];
subMatches: string[];
index: number;
}
}
Expand All @@ -10,7 +10,7 @@ declare namespace execall {
Find multiple RegExp matches in a string.

@param regexp - Regular expression to match against the `string`.
@returns An array of matches.
@returns The matches.

@example
```
Expand All @@ -20,12 +20,12 @@ execall(/(\d+)/g, '$200 and $400');
// [
// {
// match: '200',
// sub: ['200'],
// subMatches: ['200'],
// index: 1
// },
// {
// match: '400',
// sub: ['400'],
// subMatches: ['400'],
// index: 10
// }
// ]
Expand Down
2 changes: 1 addition & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ module.exports = (regexp, string) => {
while (match = clonedRegexp.exec(string)) {
matches.push({
match: match[0],
sub: match.slice(1),
subMatches: match.slice(1),
index: match.index
});

Expand Down
4 changes: 2 additions & 2 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,12 @@ execall(/(\d+)/g, '$200 and $400');
[
{
match: '200',
sub: ['200'],
subMatches: ['200'],
index: 1
},
{
match: '400',
sub: ['400'],
subMatches: ['400'],
index: 10
}
]
Expand Down
2 changes: 1 addition & 1 deletion test.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import execall from '.';
test('main', t => {
const f = execall(/(\d+)/, '$200 and $400')[0];
t.is(f.match, '200');
t.is(f.sub[0], '200');
t.is(f.subMatches[0], '200');
t.is(f.index, 1);
t.is(execall(/\d+/g, '$200 and $400')[1].match, '400');
t.is(execall(/\d+/g, 'unicorn').length, 0);
Expand Down