Skip to content

Commit

Permalink
Improve word separators (#542)
Browse files Browse the repository at this point in the history
  • Loading branch information
bconnorwhite committed Jan 15, 2023
1 parent 98ab903 commit f8d968f
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 2 deletions.
4 changes: 2 additions & 2 deletions source/internal.d.ts
Expand Up @@ -44,8 +44,6 @@ export type KeysOfUnion<T> = T extends T ? keyof T : never;

export type UpperCaseCharacters = 'A' | 'B' | 'C' | 'D' | 'E' | 'F' | 'G' | 'H' | 'I' | 'J' | 'K' | 'L' | 'M' | 'N' | 'O' | 'P' | 'Q' | 'R' | 'S' | 'T' | 'U' | 'V' | 'W' | 'X' | 'Y' | 'Z';

export type WordSeparators = '-' | '_' | ' ';

export type StringDigit = '0' | '1' | '2' | '3' | '4' | '5' | '6' | '7' | '8' | '9';

export type Whitespace =
Expand Down Expand Up @@ -76,6 +74,8 @@ export type Whitespace =
| '\u{3000}'
| '\u{FEFF}';

export type WordSeparators = '-' | '_' | Whitespace;

/**
Matches any unknown record.
*/
Expand Down
1 change: 1 addition & 0 deletions test-d/camel-case.ts
Expand Up @@ -75,6 +75,7 @@ expectType<CamelCase<'fooBARBiz', {preserveConsecutiveUppercase: false}>>('fooBa

expectType<CamelCase<'foo BAR-Biz_BUZZ'>>('fooBARBizBUZZ');
expectType<CamelCase<'foo BAR-Biz_BUZZ', {preserveConsecutiveUppercase: false}>>('fooBarBizBuzz');
expectType<CamelCase<'foo\tBAR-Biz_BUZZ', {preserveConsecutiveUppercase: false}>>('fooBarBizBuzz');

expectType<CamelCase<string>>('string' as string);
expectType<CamelCase<string, {preserveConsecutiveUppercase: false}>>('string' as string);
3 changes: 3 additions & 0 deletions test-d/delimiter-case.ts
Expand Up @@ -30,6 +30,9 @@ expectType<'foo#bar#abc#123'>(delimiterFromComplexKebab);
const delimiterFromSpace: DelimiterCase<'foo bar', '#'> = 'foo#bar';
expectType<'foo#bar'>(delimiterFromSpace);

const delimiterFromTab: DelimiterCase<'foo\tbar', '#'> = 'foo#bar';
expectType<'foo#bar'>(delimiterFromTab);

const delimiterFromSnake: DelimiterCase<'foo_bar', '#'> = 'foo#bar';
expectType<'foo#bar'>(delimiterFromSnake);

Expand Down
1 change: 1 addition & 0 deletions test-d/split-words.ts
Expand Up @@ -75,6 +75,7 @@ expectType<SplitWords<' hello world'>>(['hello', 'world']);
expectType<SplitWords<'---Hello--world'>>(['Hello', 'world']);
expectType<SplitWords<'___hello__world'>>(['hello', 'world']);
expectType<SplitWords<'hello world '>>(['hello', 'world']);
expectType<SplitWords<'hello\tworld'>>(['hello', 'world']);
expectType<SplitWords<'Hello--world--'>>(['Hello', 'world']);
expectType<SplitWords<'hello__world___'>>(['hello', 'world']);
expectType<SplitWords<'___ hello -__ _world'>>(['hello', 'world']);
Expand Down

0 comments on commit f8d968f

Please sign in to comment.