Conversation
change tohalfwidth to normalize that use js built in
There was a problem hiding this comment.
Pull request overview
This PR refactors the toHalfWidth string function to use the standard Unicode normalization API by renaming it to normalize and replacing the custom character conversion logic with JavaScript's built-in String.prototype.normalize() method.
Changes:
- Renamed
toHalfWidthfunction tonormalizewith support for different normalization forms - Updated implementation to use native
String.prototype.normalize()instead of custom character replacement logic - Updated all references across test files and implementation code
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| src/chibiScript/functions/stringFunctions.ts | Renamed function from toHalfWidth to normalize, replaced custom logic with native normalization API |
| src/pages-chibi/implementations/ComicDays/main.ts | Updated function call from toHalfWidth() to normalize() |
| test/src/chibiScript/functions/stringFunctions.test.ts | Updated test suite name and function calls to use new normalize name |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| * Converts full-width ASCII characters or number to its half-width character | ||
| * Converts full-width characters to half-width character | ||
| * @input string | ||
| * @form 'NFC' | 'NFD' | 'NFKC' | 'NFKD' - Normalization form (default: 'NFKC') |
There was a problem hiding this comment.
The JSDoc tag should be @param instead of @form to properly document the function parameter.
| * @form 'NFC' | 'NFD' | 'NFKC' | 'NFKD' - Normalization form (default: 'NFKC') | |
| * @param {'NFC' | 'NFD' | 'NFKC' | 'NFKD'} form - Normalization form (default: 'NFKC') |
| * Converts full-width characters to half-width character | ||
| * @input string | ||
| * @form 'NFC' | 'NFD' | 'NFKC' | 'NFKD' - Normalization form (default: 'NFKC') | ||
| * @returns Its half-width characters or number |
There was a problem hiding this comment.
The @returns description is outdated and doesn't accurately describe the normalize function's behavior. It should describe that the function returns the normalized form of the string according to the specified Unicode normalization form.
| * @returns Its half-width characters or number | |
| * @returns The normalized form of the string according to the specified Unicode normalization form |
No description provided.