Skip to content

Commit

Permalink
add comments to hira2kana
Browse files Browse the repository at this point in the history
  • Loading branch information
boarwell committed Mar 24, 2022
1 parent a4292df commit e1ad847
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions src/main.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,24 @@
const BETWEEN_KATAKANA_HIRAGANA = 96;

/**
* converts the first character to a Katakana (if it is Hiragana).
*
* if the argument is not Hiragane, it would return unexpected value.
* to avoid this, use isHiragana().
*
* @example
* // returns 'ア'
* hira2kata('あ')
*
* @example
* // returns '吷'
* hira2kata('受')
*
* @example
* // returns '受'
* const c = '受';
* isHiragana(c) ? hira2kana(c) : c;
*/
export const hira2kata = (c: string): string =>
String.fromCodePoint(c.codePointAt(0)! + BETWEEN_KATAKANA_HIRAGANA);

Expand Down

0 comments on commit e1ad847

Please sign in to comment.