New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More

bahttext

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

bahttext - npm Package Compare versions

Comparing version 2.1.2 to 2.1.3

{
"name": "bahttext",
"version": "2.1.2",
"version": "2.1.3",
"description": "Change number to Thai pronunciation string",

@@ -39,6 +39,10 @@ "main": "src/index.js",

"@stryker-mutator/jest-runner": "^6.3.1",
"@to-da-moon/thai-baht-lib": "^0.0.12",
"baht": "^0.7.1",
"jest": "^26.6.3",
"jest-expect-message": "^1.0.2",
"semantic-release": "^19.0.5",
"standard": "^15.0.1"
"standard": "^15.0.1",
"thai-baht-text": "^1.0.8",
"thai-baht-text-ts": "^1.1.0"
},

@@ -45,0 +49,0 @@ "jest": {

@@ -40,9 +40,5 @@ const bahtxtConst = {

function bahtxtGrammarFix (str) {
let result = str
result = result.replace(/หนึ่งสิบ/g, 'สิบ')
result = result.replace(/สองสิบ/g, 'ยี่สิบ')
result = result.replace(/สิบหนึ่ง/g, 'สิบเอ็ด')
return result
return str.replace(/หนึ่งสิบ/g, 'สิบ')
.replace(/สองสิบ/g, 'ยี่สิบ')
.replace(/สิบหนึ่ง/g, 'สิบเอ็ด')
}

@@ -59,15 +55,11 @@

function bahtxtCombine (baht, satang) {
let result = ''
if (baht === '' && satang === '') {
result = bahtxtConst.defaultResult
} else if (baht !== '' && satang === '') {
result = baht + 'บาท' + 'ถ้วน'
} else if (baht === '' && satang !== '') {
result = satang + 'สตางค์'
if (!baht && !satang) {
return bahtxtConst.defaultResult
} else if (baht && !satang) {
return baht + 'บาท' + 'ถ้วน'
} else if (!baht && satang) {
return satang + 'สตางค์'
} else {
result = baht + 'บาท' + satang + 'สตางค์'
return baht + 'บาท' + satang + 'สตางค์'
}
return result
}

@@ -82,12 +74,10 @@

function bahttext (num) {
// no null
if (!num) return bahtxtConst.defaultResult
// no boolean
if (typeof num === 'boolean') return bahtxtConst.defaultResult
// must be number only
if (isNaN(Number(num))) return bahtxtConst.defaultResult
// not less than Number.MIN_SAFE_INTEGER
if (num < Number.MIN_SAFE_INTEGER) return bahtxtConst.defaultResult
// no more than Number.MAX_SAFE_INTEGER
if (num > Number.MAX_SAFE_INTEGER) return bahtxtConst.defaultResult
if (!num || // no null
typeof num === 'boolean' || // no boolean
isNaN(Number(num)) || // must be number only
num < Number.MIN_SAFE_INTEGER || // not less than Number.MIN_SAFE_INTEGER
num > Number.MAX_SAFE_INTEGER // no more than Number.MAX_SAFE_INTEGER
) {
return bahtxtConst.defaultResult
}

@@ -100,3 +90,3 @@ // set

/** @type {string} */
const satangStr = (positiveNum % 1 * 100).toFixed(2).split('.')[0]
const satangStr = (positiveNum % 1 * 100).toFixed(0)

@@ -103,0 +93,0 @@ /** @type {number[]} */