aboutsummaryrefslogtreecommitdiff
path: root/ext/js/language/sandbox/japanese-util.js
diff options
context:
space:
mode:
authortoasted-nutbread <toasted-nutbread@users.noreply.github.com>2023-12-18 23:41:23 -0500
committerGitHub <noreply@github.com>2023-12-19 04:41:23 +0000
commit6b07b1e6e158f718fd30c44878a72c3b6ad83fa0 (patch)
tree0b95307e82416ff154c412b42c8eeaa033dac24f /ext/js/language/sandbox/japanese-util.js
parent1d268edcc3efce723954bcaa7dd376f0352c1a32 (diff)
IIFE updates (#384)
* Remove most IIFEs * Move IIFEs into functions * Don't await background-main
Diffstat (limited to 'ext/js/language/sandbox/japanese-util.js')
-rw-r--r--ext/js/language/sandbox/japanese-util.js42
1 files changed, 18 insertions, 24 deletions
diff --git a/ext/js/language/sandbox/japanese-util.js b/ext/js/language/sandbox/japanese-util.js
index 9d36497a..7d9413a6 100644
--- a/ext/js/language/sandbox/japanese-util.js
+++ b/ext/js/language/sandbox/japanese-util.js
@@ -161,32 +161,26 @@ const VOWEL_TO_KANA_MAPPING = new Map([
['', 'のノ']
]);
-const KANA_TO_VOWEL_MAPPING = (() => {
- /** @type {Map<string, string>} */
- const map = new Map();
- for (const [vowel, characters] of VOWEL_TO_KANA_MAPPING) {
- for (const character of characters) {
- map.set(character, vowel);
- }
+/** @type {Map<string, string>} */
+const KANA_TO_VOWEL_MAPPING = new Map();
+for (const [vowel, characters] of VOWEL_TO_KANA_MAPPING) {
+ for (const character of characters) {
+ KANA_TO_VOWEL_MAPPING.set(character, vowel);
}
- return map;
-})();
-
-const DIACRITIC_MAPPING = (() => {
- const kana = 'うゔ-かが-きぎ-くぐ-けげ-こご-さざ-しじ-すず-せぜ-そぞ-ただ-ちぢ-つづ-てで-とど-はばぱひびぴふぶぷへべぺほぼぽワヷ-ヰヸ-ウヴ-ヱヹ-ヲヺ-カガ-キギ-クグ-ケゲ-コゴ-サザ-シジ-スズ-セゼ-ソゾ-タダ-チヂ-ツヅ-テデ-トド-ハバパヒビピフブプヘベペホボポ';
- /** @type {Map<string, {character: string, type: import('japanese-util').DiacriticType}>} */
- const map = new Map();
- for (let i = 0, ii = kana.length; i < ii; i += 3) {
- const character = kana[i];
- const dakuten = kana[i + 1];
- const handakuten = kana[i + 2];
- map.set(dakuten, {character, type: 'dakuten'});
- if (handakuten !== '-') {
- map.set(handakuten, {character, type: 'handakuten'});
- }
+}
+
+const kana = 'うゔ-かが-きぎ-くぐ-けげ-こご-さざ-しじ-すず-せぜ-そぞ-ただ-ちぢ-つづ-てで-とど-はばぱひびぴふぶぷへべぺほぼぽワヷ-ヰヸ-ウヴ-ヱヹ-ヲヺ-カガ-キギ-クグ-ケゲ-コゴ-サザ-シジ-スズ-セゼ-ソゾ-タダ-チヂ-ツヅ-テデ-トド-ハバパヒビピフブプヘベペホボポ';
+/** @type {Map<string, {character: string, type: import('japanese-util').DiacriticType}>} */
+const DIACRITIC_MAPPING = new Map();
+for (let i = 0, ii = kana.length; i < ii; i += 3) {
+ const character = kana[i];
+ const dakuten = kana[i + 1];
+ const handakuten = kana[i + 2];
+ DIACRITIC_MAPPING.set(dakuten, {character, type: 'dakuten'});
+ if (handakuten !== '-') {
+ DIACRITIC_MAPPING.set(handakuten, {character, type: 'handakuten'});
}
- return map;
-})();
+}
/**