Skip to content

Commit

Permalink
chore: bump version
Browse files Browse the repository at this point in the history
  • Loading branch information
1fabiopereira committed Aug 21, 2022
1 parent 2b2c30e commit c9aabd8
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 2 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "react-native-pdf-extractor",
"version": "0.1.2",
"version": "0.1.3",
"description": "This library allows you to extract pdfs file data using matches specifics patterns.",
"main": "lib/commonjs/index.js",
"module": "lib/module/index.js",
Expand Down
3 changes: 2 additions & 1 deletion src/Match.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
const reducer = (pattern: RegExp) => (matches: string[], line: string) => {
const iterator = line.matchAll(pattern);
const regexp = pattern.global ? pattern : new RegExp(pattern, 'g');
const iterator = line.matchAll(regexp);
let stop = false;

do {
Expand Down
16 changes: 16 additions & 0 deletions src/__tests__/Match.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,22 @@ describe('Match', () => {
expect(matches[1]).toBe('[email protected]');
});

it('Should convert regex to global and return matches when it exists', async () => {
const data = [
'this is a line with an email: [email protected]',
'this e-mail [email protected] is on 2nd line and is duplicated: [email protected]',
];

const matches = await Match(/(\S+@\w+\.\w+)/, data);

expect(Array.isArray(matches)).toBe(true);
expect(matches).toStrictEqual([
'[email protected]',
'[email protected]',
'[email protected]',
]);
});

it('Should remove duplicated matches and return when it exists', async () => {
const data = [
'this is a line with an email: [email protected]',
Expand Down

0 comments on commit c9aabd8

Please sign in to comment.