Skip to content

Commit

Permalink
Add some typechecks
Browse files Browse the repository at this point in the history
  • Loading branch information
wtetsu committed Jun 24, 2019
1 parent 67f926c commit 600d61d
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/lib/possessive.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ const normalize = words => {
const doConvert = (word, conversionRule) => {
let result = null;
const w = conversionRule[word];
if (w) {
if (typeof w === "string") {
result = w;
} else {
const firstCode = word.charCodeAt(0);
Expand Down
2 changes: 1 addition & 1 deletion src/lib/shortcache.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ class ShortCache {
}

const index = this.dict[key];
if (index === undefined) {
if (!isFinite(index)) {
return null;
}

Expand Down
2 changes: 1 addition & 1 deletion src/lib/spelling.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ const convert = words => {

const convertWord = word => {
const w = SPELLING[word];
if (w) {
if (typeof w === "string") {
return w;
}
return null;
Expand Down
4 changes: 2 additions & 2 deletions src/lib/transform.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@ import text from "./text";
export default word => {
const list = new UniqList();
const v = verbs[word];
if (v) {
if (typeof v === "string") {
list.push(v);
}
const n = nouns[word];
if (n) {
if (typeof n === "string") {
list.push(n);
}
const otherForms = text.tryToReplaceTrailingStrings(word, replaceTrailingRules);
Expand Down
2 changes: 1 addition & 1 deletion src/main/contentgenerator.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ export default class ContentGenerator {
for (let i = 0; i < words.length; i++) {
const word = words[i];
const desc = descriptions[word];
if (!desc) {
if (typeof desc !== "string") {
continue;
}
data.push({
Expand Down

0 comments on commit 600d61d

Please sign in to comment.