-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: Replace humanize string with own implementation. (#250)
* chore: Add a more precise test for the error message formatting. * fix: Replace humanize-string with own implementation. * chore: Add new contributors.
- Loading branch information
Hannes Leutloff
authored
Jan 20, 2021
1 parent
8749102
commit da09278
Showing
6 changed files
with
932 additions
and
440 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 |
---|---|---|
@@ -0,0 +1,24 @@ | ||
const formatErrorMessage = function ({ errorName }: { | ||
errorName: string; | ||
}): string { | ||
const almostFormattedErrorMessage = errorName. | ||
split(''). | ||
map((character: string, index: number): string => { | ||
if (index === 0) { | ||
return character.toUpperCase(); | ||
} | ||
|
||
if (character.toUpperCase() === character) { | ||
return ` ${character.toLowerCase()}`; | ||
} | ||
|
||
return character; | ||
}). | ||
join(''); | ||
|
||
return `${almostFormattedErrorMessage}.`; | ||
}; | ||
|
||
export { | ||
formatErrorMessage | ||
}; |
Oops, something went wrong.