Skip to content

refactor: add missing exports #63

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

Merged
merged 2 commits into from
Feb 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
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
2 changes: 1 addition & 1 deletion src/__tests__/builder.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { buildRegExp } from '../builders';
import { buildRegExp } from '..';

test('`regexBuilder` flags', () => {
expect(buildRegExp('a').flags).toBe('');
Expand Down
2 changes: 1 addition & 1 deletion src/__tests__/example-email.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {
oneOrMore,
repeat,
startOfString,
} from '../index';
} from '..';

test('example: email validation', () => {
const usernameChars = charClass(charRange('a', 'z'), digit, anyOf('._%+-'));
Expand Down
3 changes: 1 addition & 2 deletions src/__tests__/example-hashtags.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { buildRegExp } from '../builders';
import { capture, oneOrMore, word } from '../index';
import { buildRegExp, capture, oneOrMore, word } from '..';

test('example: extracting hashtags', () => {
const regex = buildRegExp(
Expand Down
2 changes: 1 addition & 1 deletion src/__tests__/example-hex-color.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {
optional,
repeat,
startOfString,
} from '../index';
} from '..';

test('example: hex color validation', () => {
const hexDigit = charClass(digit, charRange('a', 'f'));
Expand Down
10 changes: 1 addition & 9 deletions src/__tests__/example-ipv4.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,4 @@
import {
buildRegExp,
charRange,
choiceOf,
digit,
endOfString,
repeat,
startOfString,
} from '../index';
import { buildRegExp, charRange, choiceOf, digit, endOfString, repeat, startOfString } from '..';

test('example: IPv4 address validator', () => {
const octet = choiceOf(
Expand Down
2 changes: 1 addition & 1 deletion src/__tests__/example-js-number.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {
optional,
startOfString,
zeroOrMore,
} from '../index';
} from '..';

test('example: validate JavaScript number', () => {
const sign = anyOf('+-');
Expand Down
2 changes: 1 addition & 1 deletion src/__tests__/example-regexp.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { buildRegExp, choiceOf, endOfString, repeat, startOfString } from '../index';
import { buildRegExp, choiceOf, endOfString, repeat, startOfString } from '..';

test('example: mixing with RegExp literals (IPv4 address validator)', () => {
const octet = choiceOf(
Expand Down
2 changes: 1 addition & 1 deletion src/__tests__/example-url.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import {
optional,
startOfString,
zeroOrMore,
} from '../index';
} from '..';

// Modified from: https://stackoverflow.com/a/2015516
test('example: simple url validation', () => {
Expand Down
3 changes: 1 addition & 2 deletions src/constructs/__tests__/anchors.test.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { endOfString, startOfString } from '../anchors';
import { oneOrMore } from '../quantifiers';
import { endOfString, oneOrMore, startOfString } from '../..';

test('`startOfString` basic cases', () => {
expect(startOfString).toEqualRegex(/^/);
Expand Down
3 changes: 1 addition & 2 deletions src/constructs/__tests__/capture.test.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { capture } from '../capture';
import { oneOrMore } from '../quantifiers';
import { capture, oneOrMore } from '../..';

test('`capture` base cases', () => {
expect(capture('a')).toEqualRegex(/(a)/);
Expand Down
8 changes: 5 additions & 3 deletions src/constructs/__tests__/character-class.test.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,20 @@
import { oneOrMore, optional, zeroOrMore } from '../quantifiers';
import {
any,
anyOf,
buildRegExp,
charClass,
charRange,
digit,
inverted,
notDigit,
notWhitespace,
notWord,
oneOrMore,
optional,
whitespace,
word,
} from '../character-class';
import { buildRegExp } from '../../builders';
zeroOrMore,
} from '../..';

test('`any` character class', () => {
expect(any).toEqualRegex(/./);
Expand Down
4 changes: 1 addition & 3 deletions src/constructs/__tests__/choice-of.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
import { oneOrMore, zeroOrMore } from '../quantifiers';
import { repeat } from '../repeat';
import { choiceOf } from '../choice-of';
import { choiceOf, oneOrMore, repeat, zeroOrMore } from '../..';

test('`choiceOf` using basic strings', () => {
expect(choiceOf('a')).toEqualRegex(/a/);
Expand Down
4 changes: 1 addition & 3 deletions src/constructs/__tests__/quantifiers.test.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
import { buildRegExp } from '../../builders';
import { any, digit } from '../character-class';
import { oneOrMore, optional, zeroOrMore } from '../quantifiers';
import { any, buildRegExp, digit, oneOrMore, optional, zeroOrMore } from '../..';

test('`oneOrMore` quantifier', () => {
expect(oneOrMore('a')).toEqualRegex(/a+/);
Expand Down
4 changes: 1 addition & 3 deletions src/constructs/__tests__/repeat.test.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
import { digit } from '../character-class';
import { oneOrMore, zeroOrMore } from '../quantifiers';
import { repeat } from '../repeat';
import { digit, oneOrMore, repeat, zeroOrMore } from '../..';

test('`repeat` quantifier', () => {
expect(['a', repeat('b', { min: 1, max: 5 })]).toEqualRegex(/ab{1,5}/);
Expand Down
17 changes: 11 additions & 6 deletions src/encoder/__tests__/encoder.test.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
import { buildPattern, buildRegExp } from '../../builders';
import { capture } from '../../constructs/capture';
import { choiceOf } from '../../constructs/choice-of';
import { oneOrMore, optional, zeroOrMore } from '../../constructs/quantifiers';
import { repeat } from '../../constructs/repeat';
import {
buildPattern,
buildRegExp,
capture,
choiceOf,
oneOrMore,
optional,
repeat,
zeroOrMore,
} from '../..';

test('basic quantifies', () => {
expect('a').toEqualRegex(/a/);
Expand All @@ -26,7 +31,7 @@ test('basic quantifies', () => {
expect([optional('a'), 'b', oneOrMore('d')]).toEqualRegex(/a?bd+/);
});

test('`buildPattern` escapes special characters', () => {
test('`buildRegExp` escapes special characters', () => {
expect('.').toEqualRegex(/\./);
expect('*').toEqualRegex(/\*/);
expect('+').toEqualRegex(/\+/);
Expand Down
3 changes: 3 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ export {
charRange,
charClass,
inverted,
notDigit,
notWhitespace,
notWord,
} from './constructs/character-class';
export { choiceOf } from './constructs/choice-of';
export { oneOrMore, optional, zeroOrMore } from './constructs/quantifiers';
Expand Down