aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorsiikamiika <siikamiika@users.noreply.github.com>2019-11-11 21:43:35 +0200
committersiikamiika <siikamiika@users.noreply.github.com>2019-11-23 17:50:46 +0200
commitb02a30a2fddb3b660a62f66541e90dba519cb270 (patch)
tree52dc530e766c0de1bc92084bf141b80c7cffd996
parent1f2eee449e2c1e0baf20dba038da7eaf3424aefe (diff)
explicit checks in while and if
-rw-r--r--ext/bg/js/api.js4
-rw-r--r--ext/bg/js/search-query-parser.js2
2 files changed, 3 insertions, 3 deletions
diff --git a/ext/bg/js/api.js b/ext/bg/js/api.js
index 40e9b6d2..bc9dfba1 100644
--- a/ext/bg/js/api.js
+++ b/ext/bg/js/api.js
@@ -84,7 +84,7 @@ async function apiTextParse(text, optionsContext) {
const translator = utilBackend().translator;
const results = [];
- while (text) {
+ while (text.length > 0) {
const term = [];
const [definitions, sourceLength] = await translator.findTerms(text, {}, options);
if (definitions.length > 0) {
@@ -116,7 +116,7 @@ async function apiTextParseMecab(text, optionsContext) {
for (const parsedLine of rawResults[mecabName]) {
for (const {expression, reading, source} of parsedLine) {
const term = [];
- if (expression && reading) {
+ if (expression !== null && reading !== null) {
for (const {text, furigana} of jpDistributeFuriganaInflected(
expression,
jpKatakanaToHiragana(reading),
diff --git a/ext/bg/js/search-query-parser.js b/ext/bg/js/search-query-parser.js
index 2aee45dd..14b78105 100644
--- a/ext/bg/js/search-query-parser.js
+++ b/ext/bg/js/search-query-parser.js
@@ -122,7 +122,7 @@ class QueryParser {
async setPreview(text) {
const previewTerms = [];
- while (text) {
+ while (text.length > 0) {
const tempText = text.slice(0, 2);
previewTerms.push([{text: Array.from(tempText)}]);
text = text.slice(2);