Skip to content

Commit

Permalink
Add errors, remove comment
Browse files Browse the repository at this point in the history
  • Loading branch information
MarvNC committed Jan 20, 2024
1 parent 4338c12 commit 7128072
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions src/util/textHandling/parseCantoneseReadings.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,17 @@ function parseCantoneseReadings(text, readings) {
);
}
}
// Check if remaining text in either array
if (textIndex !== textArray.length) {
throw new Error(
`Unexpected text "${textArray[textIndex]}" at index ${textIndex}`
);
}
if (readingIndex !== readingsArray.length) {
throw new Error(
`Unexpected reading "${readingsArray[readingIndex]}" at index ${readingIndex}`
);
}

return resultArray;
}
Expand All @@ -68,10 +79,6 @@ function splitString(input, punctuations) {
let current = '';
for (const char of input) {
if (/[a-zA-Z0-9]/.test(char)) {
// if (current) {
// resultArray.push(current);
// current = '';
// }
current += char;
} else if (punctuations[char]) {
if (current) {
Expand Down

0 comments on commit 7128072

Please sign in to comment.