Skip to content

Commit

Permalink
fix: ignore case changes for numbers
Browse files Browse the repository at this point in the history
  • Loading branch information
pi0 committed Jul 27, 2022
1 parent 2393fb0 commit 9927800
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 1 deletion.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ Converts first character to lower case

- Splits string by the splitters provided (default: `['-', '_', '/', '.]`)
- Splits when case changes from lower to upper or upper to lower
- Ignores numbers for case changes
- Case is preserved in returned value
- Is an irreversible function since splitters are omitted

Expand Down
7 changes: 6 additions & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
export function isUppercase (char: string = '') {
const NUNBER_CHAR_RE = /[0-9]/

export function isUppercase (char: string = ''): boolean | null {
if (NUNBER_CHAR_RE.test(char)) {
return null
}
return char.toUpperCase() === char
}

Expand Down
1 change: 1 addition & 0 deletions test/scule.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ describe('splitByCase', () => {
FooBarBaz: ['Foo', 'Bar', 'Baz'],
'foo_bar-baz/qux': ['foo', 'bar', 'baz', 'qux'],
'foo--bar-Baz': ['foo', '', 'bar', 'Baz'],
'foo123-bar': ['foo123', 'bar'],
FOOBar: ['FOO', 'Bar'],
ALink: ['A', 'Link']
}
Expand Down

0 comments on commit 9927800

Please sign in to comment.