├── .eslintrc.json
├── .gitignore
├── .npmignore
├── .nycrc
├── .travis.yml
├── .vscode
└── settings.json
├── README.md
├── bower.json
├── content
└── thai-baht-text-cover-1.jpg
├── dist
├── thai-baht-text.js
├── thai-baht-text.js.map
└── thai-baht-text.min.js
├── example
├── example_es5.js
├── example_es6.mjs
└── example_umd
│ ├── example_umd.js
│ ├── index.html
│ └── index_git.html
├── index.d.ts
├── package.json
├── src
└── thai-baht-text.ts
├── stryker.config.json
├── tests
└── unit
│ └── thai-baht-text.spec.ts
└── tsconfig.json
/.eslintrc.json:
--------------------------------------------------------------------------------
1 | {
2 | "env": {
3 | "browser": true,
4 | "commonjs": true,
5 | "es6": true,
6 | "node": true
7 | },
8 | "extends": "airbnb-base",
9 | "parserOptions": {
10 | "sourceType": "module"
11 | },
12 | "rules": {
13 | "indent": [
14 | "error",
15 | "tab"
16 | ],
17 | "no-tabs": 0,
18 | "linebreak-style": [
19 | "error",
20 | "unix"
21 | ],
22 | "quotes": [
23 | "error",
24 | "single"
25 | ],
26 | "semi": [
27 | "error",
28 | "never"
29 | ],
30 | "no-console": 0,
31 | "max-len": [
32 | "error",
33 | 200
34 | ]
35 | },
36 | "globals": {
37 | "describe": true,
38 | "it": true
39 | }
40 | }
41 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | /node_modules
2 | coverage
3 | .nyc_output
4 |
5 | # Log
6 | logs
7 | *.log
8 |
9 | # Package manager cahce
10 | yarn.lock
11 | package-lock.json
12 |
13 | old
14 | # Stryker
15 | .stryker-tmp
16 | reports
17 |
--------------------------------------------------------------------------------
/.npmignore:
--------------------------------------------------------------------------------
1 | src
2 | tests
3 | example
4 | content
5 | coverage
6 | node_modules
7 | old
8 |
9 | .vscode
10 | .eslintrc
11 | .nycrc
12 | .travis.yml
13 | .bower.json
14 | .nyc_output
--------------------------------------------------------------------------------
/.nycrc:
--------------------------------------------------------------------------------
1 | {
2 | "include": [
3 | "src/**/*.ts"
4 | ],
5 | "exclude": [
6 | "tests/**/*.spec.js"
7 | ],
8 | "all": true,
9 | "sourceMap": true,
10 | "cache": false,
11 | "check-coverage": true,
12 | "extension": [".ts"]
13 | }
14 |
--------------------------------------------------------------------------------
/.travis.yml:
--------------------------------------------------------------------------------
1 | language: node_js
2 | node_js:
3 | - "node"
4 | - "13"
5 | - "12"
6 | - "10"
7 | script: "npm test"
8 | before_script:
9 | - npm install -g codecov
10 | after_success:
11 | - codecov
12 |
--------------------------------------------------------------------------------
/.vscode/settings.json:
--------------------------------------------------------------------------------
1 | {
2 | "workbench.colorCustomizations": {
3 | "activityBar.background": "#0F1F82",
4 | "titleBar.activeBackground": "#142BB5",
5 | "titleBar.activeForeground": "#F9F9FE"
6 | }
7 | }
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Thai Baht Text JS
2 |
3 | [](https://www.npmjs.com/package/thai-baht-text)
4 | [](https://codecov.io/gh/antronic/thai-baht-text-js)
5 | [](https://www.npmjs.com/package/thai-baht-text)
6 | [](https://opensource.org/licenses/MIT)
7 | 
8 |
9 | 
10 |
11 | [Installation](#%EF%B8%8F-installation--%E0%B8%A7%E0%B8%B4%E0%B8%98%E0%B8%B5%E0%B8%95%E0%B8%B4%E0%B8%94%E0%B8%95%E0%B8%B1%E0%B9%89%E0%B8%87) | [Usage](#%EF%B8%8F-usage--%E0%B8%A7%E0%B8%B4%E0%B8%98%E0%B8%B5%E0%B8%81%E0%B8%B2%E0%B8%A3%E0%B9%83%E0%B8%8A%E0%B9%89%E0%B8%87%E0%B8%B2%E0%B8%99)
12 |
13 |
14 | >### Now, Thai Baht text supports TypeScript 🎉!!
15 |
16 | 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.
17 |
18 | ```Javascript
19 | > 10050
20 | // หนึ่งหมื่นห้าสิบบาทถ้วน
21 | ```
22 |
23 | ## ⚒️ Installation | วิธีติดตั้ง
24 | ```bash
25 | npm install thai-baht-text --save
26 | ```
27 | or
28 | ```bash
29 | yarn add thai-baht-text
30 | ```
31 |
37 |
38 |
39 | ## ⚙️ Usage | วิธีการใช้งาน
40 |
41 | **[Live Demo](#)** (Coming soon)
42 |
43 | ### Node.js
44 | ```javascript
45 | // ----CommonJS----
46 | const ThaiBahtText = require('thai-baht-text') // for CommonJS
47 | // ----ES Module----
48 | import ThaiBahtText from 'thai-baht-text'
49 |
50 | let money = 10050
51 | let moneyText = ThaiBahtText(money)
52 |
53 | console.log(moneyText)
54 | // OUTPUT: หนึ่งหมื่นห้าสิบบาทถ้วน
55 |
56 | money = 12345678988888.50
57 |
58 | console.log(ThaiBahtText(money))
59 | // OUTPUT: สิบสองล้านล้านสามแสนสี่หมื่นห้าพันหกร้อยเจ็ดสิบแปดล้านเก้าแสนแปดหมื่นแปดพันแปดร้อยแปดสิบแปดบาทห้าสิบสตางค์
60 | ```
61 |
62 | ### In the browser
63 |
64 | 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.
65 |
66 | ```html
67 | ...
68 |
69 |
73 |