bahtrext
v2.5.5
Published
BahtText Stringify
Maintainers
Readme
BahtRext
OpenTelemetry
This project is instrumented with OpenTelemetry. To enable tracing, you will need to configure the OTLP exporter by setting the following environment variables:
OTEL_EXPORTER_OTLP_ENDPOINTOTEL_EXPORTER_OTLP_HEADERS
For more information, please refer to the OpenTelemetry documentation.
Install
ES6
npm install [email protected]ES5
npm install [email protected]Demo / Example
Must Read
- Checkout Test Cases in
index.test.js 101ควรจะถูกอ่านอย่างไร ?หนึ่งร้อยหนึ่งบาทถ้วนGoogle Sheetsสัญญากู้เงินของธนาคาร* ลองมากู้ได้เลยครับ ถ้าไม่ใช่บอกผมด้วย- jojoee/bahttext
- จะอ่านว่า
เอ็ดเมื่อหลักสิบมีค่า เช่นสิบเอ็ด,ยี่สิบเอ็ด
หนึ่งร้อยเอ็ดบาทถ้วนหนึ่งร้อยหนึ่งบาทถ้วนหรือหนึ่งร้อยเอ็ดบาทถ้วนก็ได้ ให้เข้าใจได้ตรงกัน
Beliefs
- Money in Thai Baht can be translate to word
- Default Decimal places is 2 digits; 3+ digits are optional.
- Support Negative Number as Other Baht JS Library
- All Synchronous function
- This Number System not working well with large numbers. Is there a better way to read numbers in Thai?
Quick API Snippets
import { MillionScaleText, CompactScaleText } from "bahtrext";
// Source content example: "1 ใน 5,566,857,732,147,160,000,000"
const shortText = MillionScaleText("5,566,857,732,147,160,000,000");
// shortText => "ห้าพันห้าร้อยหกสิบหกล้านล้านล้าน"
const compactText = CompactScaleText(
"1035531362097366437658125676806059750189964336484946134542090486895029450514590979495591124336086177139938812952029085090597851627520000000"
);
// compactText => "1.036 ตามด้วยคำว่า \"ล้าน\" 23 ครั้ง"Test Regex
😊 Plz Consider
- Line Sticker
- Give A Star
- ProductHunt
- Write a Review
- Submit Test Case(s)
- GitHub Sponsors
Author
Changes
- 2.5.5 - update Thai numeral exports to Unicode representations, enhance internal auto-correction, and improve parameter handling and regex patterns
- 2.5.4 - add
CompactScaleTexthelper for compact scale wording - 2.5.3 - add
MillionScaleTexthelper for compact ล้าน-scale wording - 2.3.4 - Infinity
- 2.2.0 - ES6 [1.7.2]
- 1.7.1 - apply
Rest Parameters=> add functionBulkReplace,applyReplacements - 1.7.0 - add class
BR - 1.6.2 - [Refact.ai] model gpt-4o-mini + human refactor
- 1.6.1 - allow literal separator (,)
- 1.6.0 - add Hexadecimal
- 1.5.0 - add Binary Literal
- 1.4.3 - 1.4.4 - Refactor
- 1.4.2 - add NEG
- 1.3.3 - Update Version Thai Baht Text JS + add SEP
- 1.2.1 - GoogleSheetsCellCharactersLimit
- 1.2.0 - Dynamic
เอ็ด - 1.1.7 - remove
Googolplex - 1.1.3 - add LNBT
- 1.1.1
- Fix TB validation
- BF is main function
- ABT for dynamic type
- 1.1.0 - TB Ready for Production?!
- 1.0.9 - add TB (reverse BT)
- 1.0.8 - add SatangNum
- 1.0.6 - BT is main function
Flow
flowchart TD
A(ABT) -->|input type| B{Type}
B --> |Number| C(iTHBText)
B --> |String| D{Allow Negative ?}
D --> |True| E(NEG)
D --> |False| F(BF)
E --> F(BF)
F --> G(BT)
G --> |Convert Number to Decimal| H(BahtText)
H --> I(MoneyLaundering)
I --> J(splitIntFrac)
J --> |moneyFull| K[/moneyFull/]
J --> |moneyInt| L[/moneyInt/]
J --> |moneyFrac| M[/moneyFrac/]
K --> |moneyFull| N{Match Zero ?}
N --> |True| P[/Zero/]
P --> ZZZ(return)
M --> |moneyFrac| O(PrintSatangs)
O --> |satang_part| R
L --> |moneyInt| Q(PrintBaht)
Q --> |baht_part| R(Concat)
R --> ZZZ