diff --git a/src/__tests__/builder.test.ts b/src/__tests__/builder.test.ts index d9e18f8..93c865a 100644 --- a/src/__tests__/builder.test.ts +++ b/src/__tests__/builder.test.ts @@ -1,4 +1,4 @@ -import { buildRegExp } from '../builders'; +import { buildRegExp } from '..'; test('`regexBuilder` flags', () => { expect(buildRegExp('a').flags).toBe(''); diff --git a/src/__tests__/example-email.ts b/src/__tests__/example-email.ts index ad508a6..8c25521 100644 --- a/src/__tests__/example-email.ts +++ b/src/__tests__/example-email.ts @@ -8,7 +8,7 @@ import { oneOrMore, repeat, startOfString, -} from '../index'; +} from '..'; test('example: email validation', () => { const usernameChars = charClass(charRange('a', 'z'), digit, anyOf('._%+-')); diff --git a/src/__tests__/example-hashtags.ts b/src/__tests__/example-hashtags.ts index 55b420c..b5ea3d9 100644 --- a/src/__tests__/example-hashtags.ts +++ b/src/__tests__/example-hashtags.ts @@ -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( diff --git a/src/__tests__/example-hex-color.ts b/src/__tests__/example-hex-color.ts index 31632f7..3e63e93 100644 --- a/src/__tests__/example-hex-color.ts +++ b/src/__tests__/example-hex-color.ts @@ -8,7 +8,7 @@ import { optional, repeat, startOfString, -} from '../index'; +} from '..'; test('example: hex color validation', () => { const hexDigit = charClass(digit, charRange('a', 'f')); diff --git a/src/__tests__/example-ipv4.ts b/src/__tests__/example-ipv4.ts index cea179c..2559c80 100644 --- a/src/__tests__/example-ipv4.ts +++ b/src/__tests__/example-ipv4.ts @@ -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( diff --git a/src/__tests__/example-js-number.ts b/src/__tests__/example-js-number.ts index 89bcf10..683e717 100644 --- a/src/__tests__/example-js-number.ts +++ b/src/__tests__/example-js-number.ts @@ -8,7 +8,7 @@ import { optional, startOfString, zeroOrMore, -} from '../index'; +} from '..'; test('example: validate JavaScript number', () => { const sign = anyOf('+-'); diff --git a/src/__tests__/example-regexp.ts b/src/__tests__/example-regexp.ts index 3f8bc9c..df5de6f 100644 --- a/src/__tests__/example-regexp.ts +++ b/src/__tests__/example-regexp.ts @@ -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( diff --git a/src/__tests__/example-url.ts b/src/__tests__/example-url.ts index 1a693db..14593ac 100644 --- a/src/__tests__/example-url.ts +++ b/src/__tests__/example-url.ts @@ -10,7 +10,7 @@ import { optional, startOfString, zeroOrMore, -} from '../index'; +} from '..'; // Modified from: https://stackoverflow.com/a/2015516 test('example: simple url validation', () => { diff --git a/src/constructs/__tests__/anchors.test.tsx b/src/constructs/__tests__/anchors.test.tsx index 1855c36..fe614d2 100644 --- a/src/constructs/__tests__/anchors.test.tsx +++ b/src/constructs/__tests__/anchors.test.tsx @@ -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(/^/); diff --git a/src/constructs/__tests__/capture.test.tsx b/src/constructs/__tests__/capture.test.tsx index 32d13c6..30ce902 100644 --- a/src/constructs/__tests__/capture.test.tsx +++ b/src/constructs/__tests__/capture.test.tsx @@ -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)/); diff --git a/src/constructs/__tests__/character-class.test.ts b/src/constructs/__tests__/character-class.test.ts index 5c17f8f..b25c39c 100644 --- a/src/constructs/__tests__/character-class.test.ts +++ b/src/constructs/__tests__/character-class.test.ts @@ -1,7 +1,7 @@ -import { oneOrMore, optional, zeroOrMore } from '../quantifiers'; import { any, anyOf, + buildRegExp, charClass, charRange, digit, @@ -9,10 +9,12 @@ import { notDigit, notWhitespace, notWord, + oneOrMore, + optional, whitespace, word, -} from '../character-class'; -import { buildRegExp } from '../../builders'; + zeroOrMore, +} from '../..'; test('`any` character class', () => { expect(any).toEqualRegex(/./); diff --git a/src/constructs/__tests__/choice-of.test.ts b/src/constructs/__tests__/choice-of.test.ts index 1bc4206..c8234d9 100644 --- a/src/constructs/__tests__/choice-of.test.ts +++ b/src/constructs/__tests__/choice-of.test.ts @@ -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/); diff --git a/src/constructs/__tests__/quantifiers.test.tsx b/src/constructs/__tests__/quantifiers.test.tsx index e558485..5f8baa4 100644 --- a/src/constructs/__tests__/quantifiers.test.tsx +++ b/src/constructs/__tests__/quantifiers.test.tsx @@ -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+/); diff --git a/src/constructs/__tests__/repeat.test.tsx b/src/constructs/__tests__/repeat.test.tsx index 1e9c075..be7cc37 100644 --- a/src/constructs/__tests__/repeat.test.tsx +++ b/src/constructs/__tests__/repeat.test.tsx @@ -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}/); diff --git a/src/encoder/__tests__/encoder.test.tsx b/src/encoder/__tests__/encoder.test.tsx index ff5d37b..afc9624 100644 --- a/src/encoder/__tests__/encoder.test.tsx +++ b/src/encoder/__tests__/encoder.test.tsx @@ -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/); @@ -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(/\+/); diff --git a/src/index.ts b/src/index.ts index d7f7514..d14e397 100644 --- a/src/index.ts +++ b/src/index.ts @@ -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';