summaryrefslogtreecommitdiff
path: root/ext/mixed/js/japanese.js
diff options
context:
space:
mode:
authortoasted-nutbread <toasted-nutbread@users.noreply.github.com>2020-11-29 13:09:02 -0500
committerGitHub <noreply@github.com>2020-11-29 13:09:02 -0500
commit34451ebf7122a2a5d140696215411abfb0dfe188 (patch)
treee9eddb52f133269853059372045dea510e8d02dc /ext/mixed/js/japanese.js
parenta8cd03cbecf4015483ce3479e589e65ce7eece45 (diff)
JapaneseUtil normalization (#1076)
* Use JapaneseUtil as a class which is manually instantiated * Use alias function for toKana
Diffstat (limited to 'ext/mixed/js/japanese.js')
-rw-r--r--ext/mixed/js/japanese.js21
1 files changed, 7 insertions, 14 deletions
diff --git a/ext/mixed/js/japanese.js b/ext/mixed/js/japanese.js
index 2177ceee..4bd0dc65 100644
--- a/ext/mixed/js/japanese.js
+++ b/ext/mixed/js/japanese.js
@@ -15,7 +15,7 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
-const jp = (() => {
+const JapaneseUtil = (() => {
const ITERATION_MARK_CODE_POINT = 0x3005;
const HIRAGANA_SMALL_TSU_CODE_POINT = 0x3063;
const KATAKANA_SMALL_TSU_CODE_POINT = 0x30c3;
@@ -179,19 +179,8 @@ const jp = (() => {
}
}
- function getWanakana() {
- try {
- if (typeof wanakana !== 'undefined') {
- // eslint-disable-next-line no-undef
- return wanakana;
- }
- } catch (e) {
- // NOP
- }
- return null;
- }
-
+ // eslint-disable-next-line no-shadow
class JapaneseUtil {
constructor(wanakana=null) {
this._wanakana = wanakana;
@@ -258,6 +247,10 @@ const jp = (() => {
// Conversion functions
+ convertToKana(text) {
+ return this._getWanakana().toKana(text);
+ }
+
convertKatakanaToHiragana(text) {
let result = '';
const offset = (HIRAGANA_CONVERSION_RANGE[0] - KATAKANA_CONVERSION_RANGE[0]);
@@ -591,5 +584,5 @@ const jp = (() => {
}
- return new JapaneseUtil(getWanakana());
+ return JapaneseUtil;
})();