antronic / thai-baht-text-js

Convert number to Thai Baht as Text, แปลง เลข เป็น บาทไทย, thai baht text javascript

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Thai Baht Text JS

NPM Download codecov-svg NPM Version license-svg ts

Thai Baht Text JS

Installation | Usage

Now, Thai Baht text supports TypeScript 🎉!!

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
// หนึ่งหมื่นห้าสิบบาทถ้วน

⚒️ Installation | วิธีติดตั้ง

npm install thai-baht-text --save

or

yarn add thai-baht-text

⚙️ Usage | วิธีการใช้งาน

Live Demo (Coming soon)

Node.js

// ----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: สิบสองล้านล้านสามแสนสี่หมื่นห้าพันหกร้อยเจ็ดสิบแปดล้านเก้าแสนแปดหมื่นแปดพันแปดร้อยแปดสิบแปดบาทห้าสิบสตางค์

In the browser

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>

More infomation

🧑‍💻 Development

  • npm run test to run all tests in this project
  • npm run test:watch to 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 buid to compile and minify the project, then output it to the dist directory.

🗺️ Features plan

  • Return just only number text without unit
  • Convert to Thai number

License

The Thai-Baht-Text JS is open-sourced software licensed under the MIT license.

✉️ Dear you,

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

แปลงเลขให้เป็นหน่วยบาทไทย

About

Convert number to Thai Baht as Text, แปลง เลข เป็น บาทไทย, thai baht text javascript


Languages

Language:TypeScript 73.8%Language:JavaScript 21.1%Language:HTML 5.1%