Skip to content

Commit

Permalink
2.0.0 es6
Browse files Browse the repository at this point in the history
  • Loading branch information
PingHuskar committed Oct 19, 2024
1 parent 097be45 commit 40a33e0
Show file tree
Hide file tree
Showing 152 changed files with 611 additions and 552 deletions.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
![Download/month](https://img.shields.io/npm/dm/bahtrext.svg)
![Total Download](https://img.shields.io/npm/dt/bahtrext.svg)


[![tested with jest](https://img.shields.io/badge/tested_with-jest-99424f.svg?logo=jest)](https://github.com/jestjs/jest)

## Demo / Example
- React
- [BahtGame](https://timely-fenglisu-b68fd6.netlify.app/)
Expand Down
2 changes: 1 addition & 1 deletion test/ABT.test.js → __test__/ABT.test.mjs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const ABT = require("../function/ABT");
import ABT from "../function/ABT.mjs";

test("ABT", () => {
expect(ABT(`lol`)).toBe(undefined);
Expand Down
4 changes: 2 additions & 2 deletions test/BT.test.js → __test__/BT.test.mjs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const BT = require("../function/BT")
const op = require("operation-strint")
import { BT } from "../index.mjs";
import op from "operation-strint";

test(`BT CEIL`, () => {
expect(BT(`4.990001`, false, false, `c`)).toBe(`ห้าบาทถ้วน`);
Expand Down
4 changes: 2 additions & 2 deletions test/BTTB.test.js → __test__/BTTB.test.mjs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const BT = require("../function/BT");
const TB = require("../function/TB");
import { BT } from "../index.mjs";
import { TB } from "../index.mjs";

test("Reverse BahtText", () => {
expect(TB(BT(`123`))).toBe(`123.00`);
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const BulkBahtText = require(`../function/BulkBahtText`);
import BulkBahtText from "../function/BulkBahtText.mjs";

test(`BulkBahtText`, () => {
expect(
Expand Down
2 changes: 1 addition & 1 deletion test/IsValidTB.test.js → __test__/IsValidTB.test.mjs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const IsValidTB = require("../function/IsValidTB");
import { IsValidTB } from "../index.mjs";

test(`IsValidTB`, () => {
expect(IsValidTB(`แปดสิบแปดบาท`)).toBe(true);
Expand Down
2 changes: 1 addition & 1 deletion test/IsValidText.test.js → __test__/IsValidText.test.mjs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const IsValidText = require("../function/IsValidText");
import { IsValidText } from "../index.mjs";

test(`IsValidText`, () => {
expect(
Expand Down
2 changes: 1 addition & 1 deletion test/LNBT.test.js → __test__/LNBT.test.mjs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const LNBT = require(`../function/LNBT`)
import { LNBT } from "../index.mjs";

test(`LNBT`, () => {
expect(LNBT(`Googolplex`)).toBe(`Don't Try This`);
Expand Down
2 changes: 1 addition & 1 deletion test/NEG.test.js → __test__/NEG.test.mjs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const NEG = require("../function/NEG");
import NEG from "../function/NEG.mjs";

test(`NEG`, () => {
expect(NEG(`-0.67`)).toBe(`ลบหกสิบเจ็ดสตางค์`);
Expand Down
2 changes: 1 addition & 1 deletion test/NumText.test.js → __test__/NumText.test.mjs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const NumText = require("../function/NumText")
import NumText from "../function/NumText.mjs";

test("NumText", () => {
expect(NumText(`ไม่เอา123`)).toBe(`ไม่เอาหนึ่งสองสาม`);
Expand Down
2 changes: 1 addition & 1 deletion test/OB.test.js → __test__/OB.test.mjs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const OB = require("../function/OB");
import OB from "../function/OB.mjs";

test(`OB`, () => {
expect(OB(`33`)).toEqual({
Expand Down
4 changes: 2 additions & 2 deletions test/PrintSatangs.test.js → __test__/PrintSatangs.test.mjs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const PrintSatangs = require("../function/PrintSatangs");
const FULLBAHT = require("../const/primitive/FULLBAHT")
import { PrintSatangs } from "../index.mjs";
import { FULLBAHT } from "../const/index.mjs";

test("PrintSatangs", () => {
expect(PrintSatangs(`67`)[0]).toBe(`หกสิบเจ็ดสตางค์`);
Expand Down
2 changes: 1 addition & 1 deletion test/SEP.test.js → __test__/SEP.test.mjs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const SEP = require("../function/SEP");
import { SEP } from "../index.mjs";

test(`sep`, () => {
expect(SEP(`11`, `;;;`)).toBe(`สิบ;;;เอ็ด`);
Expand Down
2 changes: 1 addition & 1 deletion test/SatangNum.test.js → __test__/SatangNum.test.mjs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const SatangNum = require("../function/SatangNum");
import { SatangNum } from "../index.mjs";

test("SatangNum", () => {
expect(SatangNum("ถ้วน")).toBe("00");
Expand Down
2 changes: 1 addition & 1 deletion test/TB.test.js → __test__/TB.test.mjs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const TB = require("../function/TB");
import TB from "../function/TB.mjs";

test(`TB`, () => {
expect(TB(`สิบเอ็ดบาทสิบเอ็ดสตางค์`)).toBe(`11.11`);
Expand Down
7 changes: 4 additions & 3 deletions test/datatype.test.js → __test__/datatype.test.mjs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
const { FULLBAHT, BAHT } = require("../const");
const {
import { FULLBAHT } from "../const/index.mjs";
import BAHT from "../const/index.mjs";
import {
NumText,
BT,
ABT,
Expand All @@ -12,7 +13,7 @@ const {
OB,
LNBT,
SEP,
} = require("../");
} from "../index.mjs";

test(`data type`, () => {
const d = {
Expand Down
2 changes: 1 addition & 1 deletion test/repeat.test.js → __test__/repeat.test.mjs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const repeat = require("../function/repeat");
import { repeat } from "../index.mjs";

test("repeat", () => {
expect(repeat(`ค`, [3])).toBe(`คคค`);
Expand Down
2 changes: 2 additions & 0 deletions app.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
import ABT from "./index.mjs";
console.log(ABT("1234567890"))
14 changes: 7 additions & 7 deletions compare.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const BR = require("./index");
const oc = require("./octal");
const THBText = require("thai-baht-text");
import {BT} from "./index.mjs"
import { toDec } from "./octal.mjs";
import THBText from "thai-baht-text";

let a = 29999999999999999;
let b = 29999999999999999.99;
Expand All @@ -10,13 +10,13 @@ console.log(a.toString() == a);
console.log(a.toString() === b.toString());
console.log(a.toString());
console.log(THBText(a));
console.log(BR.BT("29999999999999999"));
console.log(BT("29999999999999999"));
console.log(THBText(b));
console.log(BR.BT("29999999999999999.99"));
console.log(BT("29999999999999999.99"));

let c = 0o77;
let d = `0o77`
console.log(THBText(c));
console.log(THBText(d));
console.log(oc.toDec(d))
console.log(oc.toDec(c))
console.log(toDec(d))
console.log(toDec(c))
31 changes: 0 additions & 31 deletions compare.test.js

This file was deleted.

31 changes: 31 additions & 0 deletions compare.test.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import {BT} from "./index.mjs"
import THBText from "thai-baht-text"
import { bahttext } from "bahttext";
import { convert } from "numbaht";

// Comment out FAIL Test Cases

test("THBText", () => {
expect(BT("999999999999999")).toBe(THBText(999999999999999));
expect(BT((2 ** 53).toString())).toBe(THBText(2 ** 53));
expect(BT((2 ** 55).toString())).toBe(THBText(2 ** 55));
expect(BT((2 ** 60).toString())).toBe(THBText(2 ** 60));
expect(BT((2 ** 69).toString())).toBe(THBText(2 ** 69));
});

test("jojoee/bahttext", () => {
expect(bahttext(999999999999999)).toBe(BT("999999999999999"));
expect(bahttext(12.33)).toBe(BT("12.33"));
// expect(bahttext(999999999999999.99)).toBe(BT("999999999999999.99"));
// expect(bahttext('999999999999999.99')).toBe(BT("999999999999999.99"));
});

test(`numbaht`, () => {
expect(
convert("หนึ่งร้อยหนึ่ง")
).toBe(`101`);
expect(convert("หนึ่งร้อยเอ็ด")).toBe(`101`);
// expect(convert("สิบห้าร้อยสตางค์")).toBe(undefined);
// expect(convert("สิบห้าร้อย")).toBe(undefined);
// expect(convert("สิบห้าบาทสองสิบสตางค์")).toBe(undefined);
});
4 changes: 0 additions & 4 deletions const/THB.js

This file was deleted.

5 changes: 5 additions & 0 deletions const/THB.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
const THB = new Intl.NumberFormat("th-TH", {
style: "currency",
currency: "THB",
});
export default THB;
20 changes: 0 additions & 20 deletions const/array/FTHAISATANGWORDS.js

This file was deleted.

21 changes: 21 additions & 0 deletions const/array/FTHAISATANGWORDS.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import SPECIALTWO from "../primitive/SPECIALTWO.mjs";
import THREE from "../primitive/THREE.mjs";
import FOUR from "../primitive/FOUR.mjs";
import FIVE from "../primitive/FIVE.mjs";
import SIX from "../primitive/SIX.mjs";
import SEVEN from "../primitive/SEVEN.mjs";
import EIGHT from "../primitive/EIGHT.mjs";
import NINE from "../primitive/NINE.mjs";
const FTHAISATANGWORDS = [
``,
``,
SPECIALTWO,
THREE,
FOUR,
FIVE,
SIX,
SEVEN,
EIGHT,
NINE,
];
export default FTHAISATANGWORDS;
21 changes: 0 additions & 21 deletions const/array/LTHAISATANGWORDS.js

This file was deleted.

23 changes: 23 additions & 0 deletions const/array/LTHAISATANGWORDS.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import SPECIALONE from "../primitive/SPECIALONE.mjs";
import TWO from "../primitive/TWO.mjs";
import THREE from "../primitive/THREE.mjs";
import FOUR from "../primitive/FOUR.mjs";
import FIVE from "../primitive/FIVE.mjs";
import SIX from "../primitive/SIX.mjs";
import SEVEN from "../primitive/SEVEN.mjs";
import EIGHT from "../primitive/EIGHT.mjs";
import NINE from "../primitive/NINE.mjs";

const LTHAISATANGWORDS = [
``,
SPECIALONE,
TWO,
THREE,
FOUR,
FIVE,
SIX,
SEVEN,
EIGHT,
NINE,
];
export default LTHAISATANGWORDS;
20 changes: 0 additions & 20 deletions const/array/ONETONINE.js

This file was deleted.

11 changes: 11 additions & 0 deletions const/array/ONETONINE.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import ONE from "../primitive/ONE.mjs";
import TWO from "../primitive/TWO.mjs";
import THREE from "../primitive/THREE.mjs";
import FOUR from "../primitive/FOUR.mjs";
import FIVE from "../primitive/FIVE.mjs";
import SIX from "../primitive/SIX.mjs";
import SEVEN from "../primitive/SEVEN.mjs";
import EIGHT from "../primitive/EIGHT.mjs";
import NINE from "../primitive/NINE.mjs";
const ONETONINE = [ONE, TWO, THREE, FOUR, FIVE, SIX, SEVEN, EIGHT, NINE];
export default ONETONINE;
14 changes: 0 additions & 14 deletions const/array/REVERSETHAIDIGITWORDS.js

This file was deleted.

15 changes: 15 additions & 0 deletions const/array/REVERSETHAIDIGITWORDS.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import TEN from "../primitive/TEN.mjs";
import HUNDRED from "../primitive/HUNDRED.mjs";
import THOUSAND from "../primitive/THOUSAND.mjs";
import TENTHOUSAND from "../primitive/TENTHOUSAND.mjs";
import HUNDREDTHOUSAND from "../primitive/HUNDREDTHOUSAND.mjs";

const REVERSETHAIDIGITWORDS = [
HUNDREDTHOUSAND,
TENTHOUSAND,
THOUSAND,
HUNDRED,
TEN,
"",
];
export default REVERSETHAIDIGITWORDS;
Loading

0 comments on commit 40a33e0

Please sign in to comment.