Comparing version 2.1.0 to 2.1.1
@@ -5,2 +5,9 @@ # Changelog | ||
### [2.1.1](https://github.com/mastermunj/to-words/compare/v2.1.0...v2.1.1) (2020-05-01) | ||
### Bug Fixes | ||
* add build files ([3c7b7e8](https://github.com/mastermunj/to-words/commit/3c7b7e8f0fe7a3f08dc853a93f7ee5210d1b1f61)) | ||
## [2.1.0](https://github.com/mastermunj/to-words/compare/v2.0.3...v2.1.0) (2020-05-01) | ||
@@ -7,0 +14,0 @@ |
@@ -18,3 +18,3 @@ "use strict"; | ||
getLocaleClass() { | ||
return (require(`./locales/${this.options.localeCode}`)).Locale; | ||
return require(`./locales/${this.options.localeCode}`).Locale; | ||
} | ||
@@ -25,3 +25,3 @@ getLocale() { | ||
const LocaleClass = this.getLocaleClass(); | ||
this.locale = new LocaleClass; | ||
this.locale = new LocaleClass(); | ||
} | ||
@@ -45,3 +45,3 @@ catch (e) { | ||
} | ||
const isNegativeNumber = (number < 0); | ||
const isNegativeNumber = number < 0; | ||
if (isNegativeNumber) { | ||
@@ -55,4 +55,4 @@ number = Math.abs(number); | ||
const isNumberZero = number >= 0 && number < 1; | ||
const split = (number + '').split('.'); | ||
let words = this.convertInternal(Number(split[0]), options) + ` ${locale.currency.plural}`; | ||
const split = number.toString().split('.'); | ||
let words = `${this.convertInternal(Number(split[0]), options)} ${locale.currency.plural}`; | ||
if (isNumberZero && options.ignoreZeroCurrency) { | ||
@@ -66,9 +66,12 @@ words = ''; | ||
} | ||
wordsWithDecimal += this.convertInternal(Number(split[1]) * Math.pow(10, 2 - split[1].length), options) + ` ${locale.currency.fractionalUnit.plural}`; | ||
wordsWithDecimal += `${this.convertInternal(Number(split[1]) * Math.pow(10, 2 - split[1].length), options)} ${locale.currency.fractionalUnit.plural}`; | ||
} | ||
const isEmpty = words.length <= 0 && wordsWithDecimal.length <= 0; | ||
return (!isEmpty && isNegativeNumber ? `${locale.texts.minus} ` : '') + words + wordsWithDecimal + (!isEmpty ? ` ${locale.texts.only}` : ''); | ||
return ((!isEmpty && isNegativeNumber ? `${locale.texts.minus} ` : '') + | ||
words + | ||
wordsWithDecimal + | ||
(!isEmpty ? ` ${locale.texts.only}` : '')); | ||
} | ||
else { | ||
const split = (number + '').split('.'); | ||
const split = number.toString().split('.'); | ||
const words = this.convertInternal(Number(split[0]), options); | ||
@@ -90,3 +93,5 @@ let wordsWithDecimal = ''; | ||
const isEmpty = words.length <= 0 && wordsWithDecimal.length <= 0; | ||
return (!isEmpty && isNegativeNumber ? `${locale.texts.minus} ` : '') + words + wordsWithDecimal; | ||
return ((!isEmpty && isNegativeNumber ? `${locale.texts.minus} ` : '') + | ||
words + | ||
wordsWithDecimal); | ||
} | ||
@@ -107,3 +112,3 @@ } | ||
if (number > 0) { | ||
words += ' ' + this.convertInternal(number, options); | ||
words += ` ${this.convertInternal(number, options)}`; | ||
} | ||
@@ -115,7 +120,6 @@ } | ||
if (remainder > 0) { | ||
return this.convertInternal(quotient, options) + ' ' | ||
+ match.value + ' ' + this.convertInternal(remainder, options); | ||
return `${this.convertInternal(quotient, options)} ${match.value} ${this.convertInternal(remainder, options)}`; | ||
} | ||
else { | ||
return this.convertInternal(quotient, options) + ' ' + match.value; | ||
return `${this.convertInternal(quotient, options)} ${match.value}`; | ||
} | ||
@@ -122,0 +126,0 @@ } |
{ | ||
"name": "to-words", | ||
"version": "2.1.0", | ||
"version": "2.1.1", | ||
"description": "Converts numbers (including decimal points) into words & currency.", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
44142
1124