Skip to content

Commit

Permalink
1.3.3
Browse files Browse the repository at this point in the history
  • Loading branch information
PingHuskar committed Aug 17, 2024
1 parent 1318c48 commit 9aa2800
Show file tree
Hide file tree
Showing 6 changed files with 53 additions and 7 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
5. This Number System not working well with large numbers.

## Fixes
- 1.3.3 - Update Version Thai Baht Text JS + add SEP
- 1.2.1 - GoogleSheetsCellCharactersLimit
- 1.2.0 - Dynamic `เอ็ด`
- 1.1.7 - remove `Googolplex`
Expand Down
8 changes: 8 additions & 0 deletions consts.js
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,14 @@ module.exports = {
SPLITPATTERN,
ZERO,
ONE,
TWO,
THREE,
FOUR,
FIVE,
SIX,
SEVEN,
EIGHT,
NINE,
THAINUMBERWORDS,
ONETONINE,
LTHAISATANGWORDS,
Expand Down
25 changes: 25 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,14 @@ const {
SPLITPATTERN,
ZERO,
ONE,
TWO,
THREE,
FOUR,
FIVE,
SIX,
SEVEN,
EIGHT,
NINE,
THAINUMBERWORDS,
ONETONINE,
LTHAISATANGWORDS,
Expand Down Expand Up @@ -408,6 +416,22 @@ const OB = (money) => {
};
}

const SEP = (num, separator = `-`) => {
let ret = BF(num, true)
for (let i of ONETONINE) {
ret = ret.replace(new RegExp(i, `g`), `${i}${separator}`);
}
for (let i of REVERSETHAIDIGITWORDS.filter(x => x !== ``)) {
ret = ret.replace(new RegExp(i, `g`), `${i}${separator}`);
}
ret = ret.replace(new RegExp(MILLION, `g`), `${MILLION}${separator}`)
.replace(new RegExp(SPECIALONE, `g`), `${SPECIALONE}${separator}`)
.replace(new RegExp(SPECIALTWO, `g`), `${SPECIALTWO}${separator}`)
.replace("บาทถ้วน", "")
.replace(new RegExp(`${separator}$`),``);
return ret
}

// if (!DEBUG) {
module.exports = {
VERSION,
Expand Down Expand Up @@ -458,5 +482,6 @@ const OB = (money) => {
HUNDRED,
TEN,
IsValidText,
SEP,
};
// }
13 changes: 12 additions & 1 deletion index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -328,4 +328,15 @@ test(`LNBT`, () => {
expect(BR.LNBT(`JumNumKaoEpu`)).toBe(undefined);
expect(BR.LNBT(1, 0)).toBe(`ศูนย์บาทถ้วน`);
expect(BR.LNBT([`asdf`])).toBe(undefined);
});
});

test(`sep`, () => {
expect(BR.SEP(`11`, `;;;`)).toBe(`สิบ;;;เอ็ด`);
expect(BR.SEP(`11`)).toBe(`สิบ-เอ็ด`)
expect(BR.SEP(`21`)).toBe(`ยี่-สิบ-เอ็ด`)
expect(BR.SEP(`101`)).toBe(`หนึ่ง-ร้อย-เอ็ด`);
expect(BR.SEP(`1001`)).toBe(`หนึ่ง-พัน-เอ็ด`);
expect(BR.SEP(`2501`)).toBe(`สอง-พัน-ห้า-ร้อย-เอ็ด`);
expect(BR.SEP(`501741221`)).toBe(`ห้า-ร้อย-เอ็ด-ล้าน-เจ็ด-แสน-สี่-หมื่น-หนึ่ง-พัน-สอง-ร้อย-ยี่-สิบ-เอ็ด`);
// https://web.facebook.com/kumthai.th/posts/920804870082544
})
9 changes: 5 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "bahtrext",
"version": "1.3.2",
"version": "1.3.3",
"description": "Better BahtText",
"main": "index.js",
"scripts": {
Expand All @@ -26,6 +26,6 @@
"operation-strint": "^1.0.8"
},
"dependencies": {
"thai-baht-text": "^1.0.8"
"thai-baht-text": "^2.0.5"
}
}

0 comments on commit 9aa2800

Please sign in to comment.