Thai Baht Text JS converts numbers into Thai text. It provides flexibility as a cross-platform library for both browser and Node.js, written in TypeScript.
> 10050
// หนึ่งหมื่นห้าสิบบาทถ้วนnpm install thai-baht-text --saveor
yarn add thai-baht-textLive Demo (Coming soon)
// ----CommonJS----
const ThaiBahtText = require('thai-baht-text') // for CommonJS
// ----ES Module----
import ThaiBahtText from 'thai-baht-text'
let money = 10050
let moneyText = ThaiBahtText(money)
console.log(moneyText)
// OUTPUT: หนึ่งหมื่นห้าสิบบาทถ้วน
money = 12345678988888.50
console.log(ThaiBahtText(money))
// OUTPUT: สิบสองล้านล้านสามแสนสี่หมื่นห้าพันหกร้อยเจ็ดสิบแปดล้านเก้าแสนแปดหมื่นแปดพันแปดร้อยแปดสิบแปดบาทห้าสิบสตางค์Since Thai Baht Text JS is built as a UMD module, you can simply add thai-baht-text.min.js as the src in a script tag in the browser without needing to install any additional libraries or polyfills.
...
<script src="https://cdn.jsdelivr.net/npm/thai-baht-text/dist/thai-baht-text.min.js"></script>
<script>
console.log(ThaiBahtText(12500.25))
// หนึ่งหมื่นสองพันห้าร้อยบาทยี่สิบห้าสตางค์
</script>
</body>npm run testto run all tests in this projectnpm run test:watchto run all tests in watch mode. This allows us to develop/refactor code and get fast feedback to ensure we don't break anything.npm run buidto compile and minify the project, then output it to thedistdirectory.
- Return just only number text without unit
- Convert to Thai number
The Thai-Baht-Text JS is open-sourced software licensed under the MIT license.
If you find any bugs or have a feature request, please open a pull request or create an issue.
แปลง เลข เป็น บาทไทย,
thai baht text javascript,
thai baht text js that-baht-text.js that-baht-text.js typescript
Convert number to Thai Baht as Text
แปลงเลขให้เป็นหน่วยบาทไทย
