Skip to content

Commit

Permalink
fix: blocking to big numbers
Browse files Browse the repository at this point in the history
* now returnung null insted of a text at dictionaryNumber, if not dict
* checking for dictionary number after pack is done
* ignoring dictionary use on last pack which lead to a null error
  • Loading branch information
Hypnotist1148 committed Oct 15, 2020
1 parent edfe644 commit 1cdbeca
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ dictionaryNumbers = (param) => {
23: "Centillion"
}
const _r = _var[param]
if (!_r) return "";
if (!_r) return null;
return _r
}

Expand Down Expand Up @@ -103,11 +103,14 @@ gtftdn = (param) => {
number = number.slice(0, (number.length >= 3 ? number.length - 3 : 0))
} while (number.length > 0)

if (!dictionaryNumbers(packs.length)) throw Error("number is to big - more than Centillion")

for (var i = packs.length; i > 0; i--) {
const pack = packs[i - 1].toString()
// might needs improvment - as of not yet existing Standard dictionary numbers
// check by dictionaryNumbers() - if it returns a empty string, we know that we don't need to format it differently
text += `${gtftdn(pack)} ${dictionaryNumbers(i)} `
if (i < 2) text += `${gtftdn(pack)}`
else text += `${gtftdn(pack)} ${dictionaryNumbers(i)} `
}

// little bit of formatting
Expand Down

0 comments on commit 1cdbeca

Please sign in to comment.