-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f497048
commit e55f398
Showing
8 changed files
with
39 additions
and
86 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,12 @@ | ||
interface CasexLetterCaseArgs { | ||
text: string; | ||
letter: string; | ||
text: string; | ||
letter: string; | ||
} | ||
|
||
export function casexLetterCase({ text, letter }: CasexLetterCaseArgs): string { | ||
if (letter === "-") return ""; | ||
if (letter === "*") return text; | ||
if (letter === "-") return ""; | ||
if (letter === "*") return text; | ||
|
||
const isUpperCase = letter === letter.toUpperCase(); | ||
return isUpperCase ? text.toUpperCase() : text.toLowerCase(); | ||
const isUpperCase = letter === letter.toUpperCase(); | ||
return isUpperCase ? text.toUpperCase() : text.toLowerCase(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,9 @@ | ||
import { CasexPattern } from "../types"; | ||
|
||
export function casexPatternFromString(pattern: string): CasexPattern { | ||
const firstSyllable = pattern.substring(0, 2); | ||
const glue = pattern.substring(2, pattern.length - 2); | ||
const secondSyllable = pattern.substring(pattern.length - 2); | ||
const firstSyllable = pattern.substring(0, 2); | ||
const glue = pattern.substring(2, pattern.length - 2); | ||
const secondSyllable = pattern.substring(pattern.length - 2); | ||
|
||
return { firstSyllable, glue, secondSyllable }; | ||
return { firstSyllable, glue, secondSyllable }; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,16 @@ | ||
import { casexLetterCase } from "./casex-letter-case"; | ||
|
||
interface CasexSyllableCaseArgs { | ||
text: string; | ||
syllable: string; | ||
text: string; | ||
syllable: string; | ||
} | ||
|
||
export function casexSyllableCase({ | ||
text, | ||
syllable, | ||
text, | ||
syllable, | ||
}: CasexSyllableCaseArgs): string { | ||
return ( | ||
casexLetterCase({ text: text[0], letter: syllable[0] }) + | ||
casexLetterCase({ text: text.substring(1), letter: syllable[1] }) | ||
); | ||
return ( | ||
casexLetterCase({ text: text[0], letter: syllable[0] }) + | ||
casexLetterCase({ text: text.substring(1), letter: syllable[1] }) | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,20 @@ | ||
const DELIMITERS = "A-Z\\s_-"; | ||
|
||
interface SplitWithDelimitersArgs { | ||
text: string; | ||
delimiters?: string; | ||
text: string; | ||
delimiters?: string; | ||
} | ||
|
||
export function splitWithDelimiters({ | ||
text, | ||
delimiters, | ||
text, | ||
delimiters, | ||
}: SplitWithDelimitersArgs): string[] { | ||
const regex = new RegExp( | ||
// rome-ignore lint/style/useTemplate: <explanation> | ||
"([A-Z]?)([^" + (delimiters || DELIMITERS) + "]*)", | ||
"g", | ||
); | ||
const regex = new RegExp( | ||
// rome-ignore lint/style/useTemplate: <explanation> | ||
"([A-Z]?)([^" + (delimiters || DELIMITERS) + "]*)", | ||
"g", | ||
); | ||
|
||
const matches = text.match(regex) || []; | ||
return matches.filter(Boolean); | ||
const matches = text.match(regex) || []; | ||
return matches.filter(Boolean); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
export interface CasexPattern { | ||
readonly firstSyllable: string; | ||
readonly glue: string; | ||
readonly secondSyllable: string; | ||
readonly firstSyllable: string; | ||
readonly glue: string; | ||
readonly secondSyllable: string; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters