Skip to content

Commit 85e4b1c

Browse files
committed
refactor: rename notWordBoundery
1 parent f9af296 commit 85e4b1c

File tree

5 files changed

+25
-14
lines changed

5 files changed

+25
-14
lines changed

src/__tests__/example-find-suffixes.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
import { buildRegExp, choiceOf, notWordBoundary, wordBoundary } from '..';
1+
import { buildRegExp, choiceOf, nonWordBoundary, wordBoundary } from '..';
22

33
test('example: find words with suffix', () => {
44
const suffixesToFind = ['acy', 'ism'];
55

66
const regex = buildRegExp([
7-
notWordBoundary, // match suffixes only
7+
nonWordBoundary, // match suffixes only
88
choiceOf(...suffixesToFind),
99
wordBoundary,
1010
]);

src/constructs/__tests__/anchors.test.tsx

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import {
33
digit,
44
endOfString,
55
nonWhitespace,
6-
notWordBoundary,
6+
nonWordBoundary,
77
oneOrMore,
88
startOfString,
99
wordBoundary,
@@ -43,20 +43,20 @@ test('`wordBoundary` matching', () => {
4343
).toMatchGroups('a ba ab aa', ['a', 'ba', 'aa']);
4444
});
4545

46-
test('`notWordBoundary` pattern', () => {
47-
expect(notWordBoundary).toEqualRegex(/\B/);
48-
expect([notWordBoundary, 'a', 'b']).toEqualRegex(/\Bab/);
49-
expect(['a', notWordBoundary, 'b']).toEqualRegex(/a\Bb/);
50-
expect(['a', 'b', notWordBoundary]).toEqualRegex(/ab\B/);
46+
test('`nonWordBoundary` pattern', () => {
47+
expect(nonWordBoundary).toEqualRegex(/\B/);
48+
expect([nonWordBoundary, 'a', 'b']).toEqualRegex(/\Bab/);
49+
expect(['a', nonWordBoundary, 'b']).toEqualRegex(/a\Bb/);
50+
expect(['a', 'b', nonWordBoundary]).toEqualRegex(/ab\B/);
5151
});
5252

53-
test('`notWordBoundary` matching', () => {
54-
expect(buildRegExp([notWordBoundary, 'abc', digit], { global: true })).toMatchGroups(
53+
test('`nonWordBoundary` matching', () => {
54+
expect(buildRegExp([nonWordBoundary, 'abc', digit], { global: true })).toMatchGroups(
5555
'abc1 xabc2 xxabc3',
5656
['abc2', 'abc3'],
5757
);
5858

59-
expect(buildRegExp([digit, 'abc', notWordBoundary], { global: true })).toMatchGroups(
59+
expect(buildRegExp([digit, 'abc', nonWordBoundary], { global: true })).toMatchGroups(
6060
'1abc 2abcx 3abcxx',
6161
['2abc', '3abc'],
6262
);

src/constructs/anchors.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,17 @@ export const wordBoundary: Anchor = {
2424
encode: encodeAnchor,
2525
};
2626

27-
export const notWordBoundary: Anchor = {
27+
export const nonWordBoundary: Anchor = {
2828
type: 'anchor',
2929
symbol: '\\B',
3030
encode: encodeAnchor,
3131
};
3232

33+
/**
34+
* @deprecated Renamed to `nonWordBoundary`.
35+
*/
36+
export const notWordBoundary = nonWordBoundary;
37+
3338
function encodeAnchor(this: Anchor): EncodeResult {
3439
return {
3540
precedence: 'sequence',

src/index.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,13 @@ export type * from './types';
22

33
export { buildPattern, buildRegExp } from './builders';
44

5-
export { endOfString, notWordBoundary, startOfString, wordBoundary } from './constructs/anchors';
5+
export {
6+
endOfString,
7+
nonWordBoundary,
8+
notWordBoundary,
9+
startOfString,
10+
wordBoundary,
11+
} from './constructs/anchors';
612
export { capture } from './constructs/capture';
713
export {
814
any,

website/docs/Examples.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -280,7 +280,7 @@ Ignoring cases where given word is part of a bigger word.
280280
const suffixesToFind = ['acy', 'ism'];
281281

282282
const regex = buildRegExp([
283-
notWordBoundary, // match suffixes only
283+
nonWordBoundary, // match suffixes only
284284
choiceOf(...suffixesToFind),
285285
wordBoundary,
286286
]);

0 commit comments

Comments
 (0)