diff options
author | toasted-nutbread <toasted-nutbread@users.noreply.github.com> | 2020-02-01 20:51:30 -0500 |
---|---|---|
committer | toasted-nutbread <toasted-nutbread@users.noreply.github.com> | 2020-02-02 10:09:19 -0500 |
commit | f23e0c9c95a7c0803694ea91b0ea55079e8f52d6 (patch) | |
tree | 5b81d21fc503b04a2b0adcf2d2e3758f5f85d775 /ext/bg/js | |
parent | 539ad6fb0aca99605b853e496159c1fb535ce633 (diff) |
Validate Deinflector.ruleTypes
Diffstat (limited to 'ext/bg/js')
-rw-r--r-- | ext/bg/js/deinflector.js | 20 |
1 files changed, 11 insertions, 9 deletions
diff --git a/ext/bg/js/deinflector.js b/ext/bg/js/deinflector.js index 33b2a8b3..e2ced965 100644 --- a/ext/bg/js/deinflector.js +++ b/ext/bg/js/deinflector.js @@ -76,17 +76,19 @@ class Deinflector { const ruleTypes = Deinflector.ruleTypes; let value = 0; for (const rule of rules) { - value |= ruleTypes[rule]; + const ruleBits = ruleTypes.get(rule); + if (typeof ruleBits === 'undefined') { continue; } + value |= ruleBits; } return value; } } -Deinflector.ruleTypes = { - 'v1': 0b0000001, // Verb ichidan - 'v5': 0b0000010, // Verb godan - 'vs': 0b0000100, // Verb suru - 'vk': 0b0001000, // Verb kuru - 'adj-i': 0b0010000, // Adjective i - 'iru': 0b0100000 // Intermediate -iru endings for progressive or perfect tense -}; +Deinflector.ruleTypes = new Map([ + ['v1', 0b0000001], // Verb ichidan + ['v5', 0b0000010], // Verb godan + ['vs', 0b0000100], // Verb suru + ['vk', 0b0001000], // Verb kuru + ['adj-i', 0b0010000], // Adjective i + ['iru', 0b0100000] // Intermediate -iru endings for progressive or perfect tense +]); |