From d0412c0b76a4215251b7f9489fdb546a2c47a3bb Mon Sep 17 00:00:00 2001 From: Chadin Chaipornpisuth Date: Thu, 3 Oct 2024 22:48:41 +0700 Subject: [PATCH] refactor --- const/THB.js | 4 + const/array/FTHAISATANGWORDS.js | 20 ++ const/array/LTHAISATANGWORDS.js | 21 ++ const/array/ONETONINE.js | 20 ++ const/array/REVERSETHAIDIGITWORDS.js | 12 + const/array/THAI2ARABICNumerals.js | 12 + const/array/THAINUMBERWORDS.js | 25 ++ const/array/large_numbers.js | 70 ++++++ const/index.js | 96 ++++++++ const/primitive/BAHT.js | 1 + const/primitive/DEBUG.js | 1 + const/primitive/EIGHT.js | 1 + const/primitive/FIVE.js | 1 + const/primitive/FOUR.js | 1 + const/primitive/FULLBAHT.js | 1 + .../GoogleSheetsCellCharactersLimit.js | 1 + const/primitive/HUNDRED.js | 1 + const/primitive/HUNDREDTHOUSAND.js | 1 + const/primitive/MAX_SAFE_INTEGER.js | 1 + const/primitive/MILLION.js | 1 + const/primitive/NINE.js | 1 + const/primitive/ONE.js | 1 + const/primitive/READAS.js | 1 + const/primitive/SATANG.js | 1 + const/primitive/SEVEN.js | 1 + const/primitive/SIX.js | 1 + const/primitive/SPECIALONE.js | 1 + const/primitive/SPECIALTWO.js | 1 + const/primitive/TEN.js | 1 + const/primitive/TENTHOUSAND.js | 1 + const/primitive/THOUSAND.js | 1 + const/primitive/THREE.js | 1 + const/primitive/TWO.js | 1 + const/primitive/VERSION.js | 1 + const/primitive/ZERO.js | 1 + const/primitive/negative.js | 1 + const/regex/ElevenToNineteenRegex.js | 1 + const/regex/LAST6DIGITPATTERN.js | 1 + const/regex/OneToTenTextRegex.js | 2 + const/regex/SPLITPATTERN.js | 1 + const/regex/TwentyToNinetyNine.js | 2 + const/regex/ValidSATANGRegex.js | 2 + const/regex/defaultBulkBahtTextPat.js | 1 + const/regex/defaultBulkBahtTextSkips.js | 1 + const/regex/octalRegex1.js | 1 + const/regex/octalRegex2.js | 1 + consts.js | 233 ------------------ index.js | 2 +- index.test.js | 2 +- octal.js | 2 +- package-lock.json | 4 +- package.json | 2 +- 52 files changed, 326 insertions(+), 239 deletions(-) create mode 100644 const/THB.js create mode 100644 const/array/FTHAISATANGWORDS.js create mode 100644 const/array/LTHAISATANGWORDS.js create mode 100644 const/array/ONETONINE.js create mode 100644 const/array/REVERSETHAIDIGITWORDS.js create mode 100644 const/array/THAI2ARABICNumerals.js create mode 100644 const/array/THAINUMBERWORDS.js create mode 100644 const/array/large_numbers.js create mode 100644 const/index.js create mode 100644 const/primitive/BAHT.js create mode 100644 const/primitive/DEBUG.js create mode 100644 const/primitive/EIGHT.js create mode 100644 const/primitive/FIVE.js create mode 100644 const/primitive/FOUR.js create mode 100644 const/primitive/FULLBAHT.js create mode 100644 const/primitive/GoogleSheetsCellCharactersLimit.js create mode 100644 const/primitive/HUNDRED.js create mode 100644 const/primitive/HUNDREDTHOUSAND.js create mode 100644 const/primitive/MAX_SAFE_INTEGER.js create mode 100644 const/primitive/MILLION.js create mode 100644 const/primitive/NINE.js create mode 100644 const/primitive/ONE.js create mode 100644 const/primitive/READAS.js create mode 100644 const/primitive/SATANG.js create mode 100644 const/primitive/SEVEN.js create mode 100644 const/primitive/SIX.js create mode 100644 const/primitive/SPECIALONE.js create mode 100644 const/primitive/SPECIALTWO.js create mode 100644 const/primitive/TEN.js create mode 100644 const/primitive/TENTHOUSAND.js create mode 100644 const/primitive/THOUSAND.js create mode 100644 const/primitive/THREE.js create mode 100644 const/primitive/TWO.js create mode 100644 const/primitive/VERSION.js create mode 100644 const/primitive/ZERO.js create mode 100644 const/primitive/negative.js create mode 100644 const/regex/ElevenToNineteenRegex.js create mode 100644 const/regex/LAST6DIGITPATTERN.js create mode 100644 const/regex/OneToTenTextRegex.js create mode 100644 const/regex/SPLITPATTERN.js create mode 100644 const/regex/TwentyToNinetyNine.js create mode 100644 const/regex/ValidSATANGRegex.js create mode 100644 const/regex/defaultBulkBahtTextPat.js create mode 100644 const/regex/defaultBulkBahtTextSkips.js create mode 100644 const/regex/octalRegex1.js create mode 100644 const/regex/octalRegex2.js delete mode 100644 consts.js diff --git a/const/THB.js b/const/THB.js new file mode 100644 index 0000000..ebc972f --- /dev/null +++ b/const/THB.js @@ -0,0 +1,4 @@ +module.exports = THB = new Intl.NumberFormat("th-TH", { + style: "currency", + currency: "THB", +}); \ No newline at end of file diff --git a/const/array/FTHAISATANGWORDS.js b/const/array/FTHAISATANGWORDS.js new file mode 100644 index 0000000..a20da21 --- /dev/null +++ b/const/array/FTHAISATANGWORDS.js @@ -0,0 +1,20 @@ +const SPECIALTWO = require(`../primitive/SPECIALTWO`) +const THREE = require(`../primitive/THREE`); +const FOUR = require(`../primitive/FOUR`); +const FIVE = require(`../primitive/FIVE`); +const SIX = require(`../primitive/SIX`); +const SEVEN = require(`../primitive/SEVEN`); +const EIGHT = require(`../primitive/EIGHT`); +const NINE = require(`../primitive/NINE`); +module.exports = FTHAISATANGWORDS = [ + ``, + ``, + SPECIALTWO, + THREE, + FOUR, + FIVE, + SIX, + SEVEN, + EIGHT, + NINE, +]; diff --git a/const/array/LTHAISATANGWORDS.js b/const/array/LTHAISATANGWORDS.js new file mode 100644 index 0000000..514b906 --- /dev/null +++ b/const/array/LTHAISATANGWORDS.js @@ -0,0 +1,21 @@ +const SPECIALONE = require(`../primitive/SPECIALONE`) +const TWO = require(`../primitive/TWO`) +const THREE = require(`../primitive/THREE`) +const FOUR = require(`../primitive/FOUR`) +const FIVE = require(`../primitive/FIVE`) +const SIX = require(`../primitive/SIX`) +const SEVEN = require(`../primitive/SEVEN`) +const EIGHT = require(`../primitive/EIGHT`) +const NINE = require(`../primitive/NINE`) +module.exports = LTHAISATANGWORDS = [ + ``, + SPECIALONE, + TWO, + THREE, + FOUR, + FIVE, + SIX, + SEVEN, + EIGHT, + NINE, +]; \ No newline at end of file diff --git a/const/array/ONETONINE.js b/const/array/ONETONINE.js new file mode 100644 index 0000000..7495c10 --- /dev/null +++ b/const/array/ONETONINE.js @@ -0,0 +1,20 @@ +const ONE = require(`../primitive/ONE`); +const TWO = require(`../primitive/TWO`); +const THREE = require(`../primitive/THREE`); +const FOUR = require(`../primitive/FOUR`); +const FIVE = require(`../primitive/FIVE`); +const SIX = require(`../primitive/SIX`); +const SEVEN = require(`../primitive/SEVEN`); +const EIGHT = require(`../primitive/EIGHT`); +const NINE = require(`../primitive/NINE`); +module.exports = ONETONINE = [ + ONE, + TWO, + THREE, + FOUR, + FIVE, + SIX, + SEVEN, + EIGHT, + NINE, +]; \ No newline at end of file diff --git a/const/array/REVERSETHAIDIGITWORDS.js b/const/array/REVERSETHAIDIGITWORDS.js new file mode 100644 index 0000000..5960677 --- /dev/null +++ b/const/array/REVERSETHAIDIGITWORDS.js @@ -0,0 +1,12 @@ +const HUNDRED = require(`../primitive/HUNDRED`); +const THOUSAND = require(`../primitive/THOUSAND`); +const TENTHOUSAND = require(`../primitive/TENTHOUSAND`); +const HUNDREDTHOUSAND = require(`../primitive/HUNDREDTHOUSAND`); +module.exports = REVERSETHAIDIGITWORDS = [ + HUNDREDTHOUSAND, + TENTHOUSAND, + THOUSAND, + HUNDRED, + TEN, + "", +]; diff --git a/const/array/THAI2ARABICNumerals.js b/const/array/THAI2ARABICNumerals.js new file mode 100644 index 0000000..6a9a748 --- /dev/null +++ b/const/array/THAI2ARABICNumerals.js @@ -0,0 +1,12 @@ +module.exports = THAI2ARABICNumerals = [ + { th: `๐`, a: `0` }, + { th: `๑`, a: `1` }, + { th: `๒`, a: `2` }, + { th: `๓`, a: `3` }, + { th: `๔`, a: `4` }, + { th: `๕`, a: `5` }, + { th: `๖`, a: `6` }, + { th: `๗`, a: `7` }, + { th: `๘`, a: `8` }, + { th: `๙`, a: `9` }, +] \ No newline at end of file diff --git a/const/array/THAINUMBERWORDS.js b/const/array/THAINUMBERWORDS.js new file mode 100644 index 0000000..eab445b --- /dev/null +++ b/const/array/THAINUMBERWORDS.js @@ -0,0 +1,25 @@ +const ZERO = require(`../primitive/ZERO`); +const ONE = require(`../primitive/ONE`); +const TWO = require(`../primitive/TWO`); +const THREE = require(`../primitive/THREE`); +const FOUR = require(`../primitive/FOUR`); +const FIVE = require(`../primitive/FIVE`); +const SIX = require(`../primitive/SIX`); +const SEVEN = require(`../primitive/SEVEN`); +const EIGHT = require(`../primitive/EIGHT`); +const NINE = require(`../primitive/NINE`); +const TEN = require(`../primitive/TEN`) + +module.exports = THAINUMBERWORDS = [ + ZERO, + ONE, + TWO, + THREE, + FOUR, + FIVE, + SIX, + SEVEN, + EIGHT, + NINE, + TEN, +]; diff --git a/const/array/large_numbers.js b/const/array/large_numbers.js new file mode 100644 index 0000000..74e4043 --- /dev/null +++ b/const/array/large_numbers.js @@ -0,0 +1,70 @@ +module.exports = large_numbers = [ + { name: "Million", powof10: 6 }, + { name: "Billion", powof10: 9 }, + { name: "Trillion", powof10: 12 }, + { name: "Quadrillion", powof10: 15 }, + { name: "Quintillion", powof10: 18 }, + { name: "Sextillion", powof10: 21 }, + { name: "Septillion", powof10: 24 }, + { name: "Octillion", powof10: 27 }, + { name: "Nonillion", powof10: 30 }, + { name: "Decillion", powof10: 33 }, + { name: "Undecillion", powof10: 36 }, + { name: "Duodecillion", powof10: 39 }, + { name: "Tredecillion", powof10: 42 }, + { name: "Quattuordecillion", powof10: 45 }, + { name: "Quindecillion", powof10: 48 }, + { name: "Sedecillion", powof10: 51 }, + { name: "Septendecillion", powof10: 54 }, + { name: "Octodecillion", powof10: 57 }, + { name: "Novendecillion", powof10: 60 }, + { name: "Vigintillion", powof10: 63 }, + { name: "Unvigintillion", powof10: 66 }, + { name: "Duovigintillion", powof10: 69 }, + { name: "Tresvigintillion", powof10: 72 }, + { name: "Quattuorvigintillion", powof10: 75 }, + { name: "Quinvigintillion", powof10: 78 }, + { name: "Sesvigintillion", powof10: 81 }, + { name: "Septemvigintillion", powof10: 84 }, + { name: "Octovigintillion", powof10: 87 }, + { name: "Novemvigintillion", powof10: 90 }, + { name: "Trigintillion", powof10: 93 }, + { name: "Untrigintillion", powof10: 96 }, + { name: "Duotrigintillion", powof10: 99 }, + { name: "Trestrigintillion", powof10: 102 }, + { name: "Quattuortrigintillion", powof10: 105 }, + { name: "Quintrigintillion", powof10: 108 }, + { name: "Sestrigintillion", powof10: 111 }, + { name: "Septentrigintillion", powof10: 114 }, + { name: "Octotrigintillion", powof10: 117 }, + { name: "Noventrigintillion", powof10: 120 }, + { name: "Quadragintillion", powof10: 123 }, + { name: "Quinquagintillion", powof10: 153 }, + { name: "Sexagintillion", powof10: 183 }, + { name: "Septuagintillion", powof10: 213 }, + { name: "Octogintillion", powof10: 243 }, + { name: "Nonagintillion", powof10: 273 }, + { name: "Centillion", powof10: 303 }, + { name: "Uncentillion", powof10: 306 }, + { name: "Decicentillion", powof10: 333 }, + { name: "Undecicentillion", powof10: 336 }, + { name: "Viginticentillion", powof10: 363 }, + { name: "Unviginticentillion", powof10: 366 }, + { name: "Trigintacentillion", powof10: 393 }, + { name: "Quadragintacentillion", powof10: 423 }, + { name: "Quinquagintacentillion", powof10: 453 }, + { name: "Sexagintacentillion", powof10: 483 }, + { name: "Septuagintacentillion", powof10: 513 }, + { name: "Octogintacentillion", powof10: 543 }, + { name: "Nonagintacentillion", powof10: 573 }, + { name: "Ducentillion", powof10: 603 }, + { name: "Trecentillion", powof10: 903 }, + { name: "Quadringentillion", powof10: 1203 }, + { name: "Quingentillion", powof10: 1503 }, + { name: "Sescentillion", powof10: 1803 }, + { name: "Septingentillion", powof10: 2103 }, + { name: "Octingentillion", powof10: 2403 }, + { name: "Nongentillion", powof10: 2703 }, + { name: "Millinillion", powof10: 3003 }, + { name: "Googol", powof10: 100 }, +]; diff --git a/const/index.js b/const/index.js new file mode 100644 index 0000000..66456ee --- /dev/null +++ b/const/index.js @@ -0,0 +1,96 @@ +const DEBUG = require('./primitive/DEBUG') +const GoogleSheetsCellCharactersLimit = require("./primitive/GoogleSheetsCellCharactersLimit"); +const VERSION = require(`./primitive/VERSION`); +const negative = require(`./primitive/negative`); +const SPECIALONE = require("./primitive/SPECIALONE"); +const SPECIALTWO = require("./primitive/SPECIALTWO"); +const TEN = require("./primitive/TEN"); +const BAHT = require("./primitive/BAHT"); +const MILLION = require("./primitive/MILLION"); +const FULLBAHT = require("./primitive/FULLBAHT"); +const SATANG = require("./primitive/SATANG"); +const READAS = require("./primitive/READAS"); + +const LAST6DIGITPATTERN = require(`./regex/LAST6DIGITPATTERN`); +const SPLITPATTERN = require(`./regex/SPLITPATTERN`); + +const ZERO = require(`./primitive/ZERO`); +const ONE = require(`./primitive/ONE`); +const TWO = require(`./primitive/TWO`) +const THREE = require(`./primitive/THREE`) +const FOUR = require(`./primitive/FOUR`); +const FIVE = require(`./primitive/FIVE`); +const SIX = require(`./primitive/SIX`); +const SEVEN = require(`./primitive/SEVEN`); +const EIGHT = require(`./primitive/EIGHT`); +const NINE = require(`./primitive/NINE`); +const THAINUMBERWORDS = require(`./array/THAINUMBERWORDS`) +const ONETONINE = require(`./array/ONETONINE`); +const LTHAISATANGWORDS = require(`./array/LTHAISATANGWORDS`); +const FTHAISATANGWORDS = require(`./array/FTHAISATANGWORDS`); +const HUNDRED = require(`./primitive/HUNDRED`); +const THOUSAND = require(`./primitive/THOUSAND`); +const TENTHOUSAND = require(`./primitive/TENTHOUSAND`); +const HUNDREDTHOUSAND = require(`./primitive/HUNDREDTHOUSAND`); +const REVERSETHAIDIGITWORDS = require(`./array/REVERSETHAIDIGITWORDS`); +const THAI2ARABICNumerals = require(`./array/THAI2ARABICNumerals`); +const ValidSATANGRegex = require(`./regex/ValidSATANGRegex`) +const defaultBulkBahtTextPat = require(`./regex/defaultBulkBahtTextPat`); +const defaultBulkBahtTextSkips = require(`./regex/defaultBulkBahtTextSkips`); +const OneToTenTextRegex = require(`./regex/OneToTenTextRegex`); +const ElevenToNineteenRegex = require(`./regex/ElevenToNineteenRegex`); +const TwentyToNinetyNine = require(`./regex/TwentyToNinetyNine`) + +const large_numbers = require(`./array/large_numbers`); +const MAX_SAFE_INTEGER = require(`./primitive/MAX_SAFE_INTEGER`); +const octalRegex1 = require(`./regex/octalRegex1`); +const octalRegex2 = require(`./regex/octalRegex2`); +let THB = require(`./THB`); + +module.exports = { + DEBUG, + GoogleSheetsCellCharactersLimit, + VERSION, + SPECIALONE, + SPECIALTWO, + TEN, + BAHT, + MILLION, + FULLBAHT, + SATANG, + READAS, + LAST6DIGITPATTERN, + SPLITPATTERN, + ZERO, + ONE, + TWO, + THREE, + FOUR, + FIVE, + SIX, + SEVEN, + EIGHT, + NINE, + THAINUMBERWORDS, + ONETONINE, + LTHAISATANGWORDS, + FTHAISATANGWORDS, + HUNDRED, + THOUSAND, + TENTHOUSAND, + HUNDREDTHOUSAND, + REVERSETHAIDIGITWORDS, + THAI2ARABICNumerals, + ValidSATANGRegex, + defaultBulkBahtTextPat, + defaultBulkBahtTextSkips, + OneToTenTextRegex, + ElevenToNineteenRegex, + TwentyToNinetyNine, + large_numbers, + octalRegex1, + octalRegex2, + MAX_SAFE_INTEGER, + THB, + negative, +}; \ No newline at end of file diff --git a/const/primitive/BAHT.js b/const/primitive/BAHT.js new file mode 100644 index 0000000..cb4f31f --- /dev/null +++ b/const/primitive/BAHT.js @@ -0,0 +1 @@ +module.exports = BAHT = `บาท`; \ No newline at end of file diff --git a/const/primitive/DEBUG.js b/const/primitive/DEBUG.js new file mode 100644 index 0000000..0dee2b2 --- /dev/null +++ b/const/primitive/DEBUG.js @@ -0,0 +1 @@ +module.exports = DEBUG = false; \ No newline at end of file diff --git a/const/primitive/EIGHT.js b/const/primitive/EIGHT.js new file mode 100644 index 0000000..62b2bb4 --- /dev/null +++ b/const/primitive/EIGHT.js @@ -0,0 +1 @@ +module.exports = EIGHT = `แปด`; \ No newline at end of file diff --git a/const/primitive/FIVE.js b/const/primitive/FIVE.js new file mode 100644 index 0000000..7c828db --- /dev/null +++ b/const/primitive/FIVE.js @@ -0,0 +1 @@ +module.exports = FIVE = `ห้า`; \ No newline at end of file diff --git a/const/primitive/FOUR.js b/const/primitive/FOUR.js new file mode 100644 index 0000000..1afed5c --- /dev/null +++ b/const/primitive/FOUR.js @@ -0,0 +1 @@ +module.exports = FOUR = `สี่`; \ No newline at end of file diff --git a/const/primitive/FULLBAHT.js b/const/primitive/FULLBAHT.js new file mode 100644 index 0000000..2d8ca48 --- /dev/null +++ b/const/primitive/FULLBAHT.js @@ -0,0 +1 @@ +module.exports = FULLBAHT = `ถ้วน`; diff --git a/const/primitive/GoogleSheetsCellCharactersLimit.js b/const/primitive/GoogleSheetsCellCharactersLimit.js new file mode 100644 index 0000000..b470634 --- /dev/null +++ b/const/primitive/GoogleSheetsCellCharactersLimit.js @@ -0,0 +1 @@ +module.exports = GoogleSheetsCellCharactersLimit = 50000; \ No newline at end of file diff --git a/const/primitive/HUNDRED.js b/const/primitive/HUNDRED.js new file mode 100644 index 0000000..a9a1c4d --- /dev/null +++ b/const/primitive/HUNDRED.js @@ -0,0 +1 @@ +module.exports = HUNDRED = `ร้อย`; \ No newline at end of file diff --git a/const/primitive/HUNDREDTHOUSAND.js b/const/primitive/HUNDREDTHOUSAND.js new file mode 100644 index 0000000..d273392 --- /dev/null +++ b/const/primitive/HUNDREDTHOUSAND.js @@ -0,0 +1 @@ +module.exports = HUNDREDTHOUSAND = `แสน`; \ No newline at end of file diff --git a/const/primitive/MAX_SAFE_INTEGER.js b/const/primitive/MAX_SAFE_INTEGER.js new file mode 100644 index 0000000..757abf6 --- /dev/null +++ b/const/primitive/MAX_SAFE_INTEGER.js @@ -0,0 +1 @@ +module.exports = MAX_SAFE_INTEGER = 9007199254740991; \ No newline at end of file diff --git a/const/primitive/MILLION.js b/const/primitive/MILLION.js new file mode 100644 index 0000000..75edcfa --- /dev/null +++ b/const/primitive/MILLION.js @@ -0,0 +1 @@ +module.exports = MILLION = `ล้าน`; \ No newline at end of file diff --git a/const/primitive/NINE.js b/const/primitive/NINE.js new file mode 100644 index 0000000..fc083f4 --- /dev/null +++ b/const/primitive/NINE.js @@ -0,0 +1 @@ +module.exports = NINE = `เก้า`; \ No newline at end of file diff --git a/const/primitive/ONE.js b/const/primitive/ONE.js new file mode 100644 index 0000000..b861f4c --- /dev/null +++ b/const/primitive/ONE.js @@ -0,0 +1 @@ +module.exports = ONE = `หนึ่ง`; \ No newline at end of file diff --git a/const/primitive/READAS.js b/const/primitive/READAS.js new file mode 100644 index 0000000..d9498a0 --- /dev/null +++ b/const/primitive/READAS.js @@ -0,0 +1 @@ +module.exports = READAS = `อ่านว่า`; \ No newline at end of file diff --git a/const/primitive/SATANG.js b/const/primitive/SATANG.js new file mode 100644 index 0000000..9558139 --- /dev/null +++ b/const/primitive/SATANG.js @@ -0,0 +1 @@ +module.exports = SATANG = `สตางค์`; \ No newline at end of file diff --git a/const/primitive/SEVEN.js b/const/primitive/SEVEN.js new file mode 100644 index 0000000..69461dc --- /dev/null +++ b/const/primitive/SEVEN.js @@ -0,0 +1 @@ +module.exports = SEVEN = `เจ็ด`; \ No newline at end of file diff --git a/const/primitive/SIX.js b/const/primitive/SIX.js new file mode 100644 index 0000000..637db2c --- /dev/null +++ b/const/primitive/SIX.js @@ -0,0 +1 @@ +module.exports = SIX = `หก`; \ No newline at end of file diff --git a/const/primitive/SPECIALONE.js b/const/primitive/SPECIALONE.js new file mode 100644 index 0000000..d6ff520 --- /dev/null +++ b/const/primitive/SPECIALONE.js @@ -0,0 +1 @@ +module.exports = SPECIALONE = `เอ็ด`; \ No newline at end of file diff --git a/const/primitive/SPECIALTWO.js b/const/primitive/SPECIALTWO.js new file mode 100644 index 0000000..1641203 --- /dev/null +++ b/const/primitive/SPECIALTWO.js @@ -0,0 +1 @@ +module.exports = SPECIALTWO = `ยี่`; \ No newline at end of file diff --git a/const/primitive/TEN.js b/const/primitive/TEN.js new file mode 100644 index 0000000..2324426 --- /dev/null +++ b/const/primitive/TEN.js @@ -0,0 +1 @@ +module.exports = TEN = `สิบ`; \ No newline at end of file diff --git a/const/primitive/TENTHOUSAND.js b/const/primitive/TENTHOUSAND.js new file mode 100644 index 0000000..394bc28 --- /dev/null +++ b/const/primitive/TENTHOUSAND.js @@ -0,0 +1 @@ +module.exports = TENTHOUSAND = `หมื่น`; \ No newline at end of file diff --git a/const/primitive/THOUSAND.js b/const/primitive/THOUSAND.js new file mode 100644 index 0000000..2c50fbb --- /dev/null +++ b/const/primitive/THOUSAND.js @@ -0,0 +1 @@ +module.exports = THOUSAND = `พัน`; \ No newline at end of file diff --git a/const/primitive/THREE.js b/const/primitive/THREE.js new file mode 100644 index 0000000..e70cbf3 --- /dev/null +++ b/const/primitive/THREE.js @@ -0,0 +1 @@ +module.exports = THREE = `สาม`; \ No newline at end of file diff --git a/const/primitive/TWO.js b/const/primitive/TWO.js new file mode 100644 index 0000000..d1605eb --- /dev/null +++ b/const/primitive/TWO.js @@ -0,0 +1 @@ +module.exports = TWO = `สอง`; \ No newline at end of file diff --git a/const/primitive/VERSION.js b/const/primitive/VERSION.js new file mode 100644 index 0000000..f246a58 --- /dev/null +++ b/const/primitive/VERSION.js @@ -0,0 +1 @@ +module.exports = VERSION = `1.4.3`; \ No newline at end of file diff --git a/const/primitive/ZERO.js b/const/primitive/ZERO.js new file mode 100644 index 0000000..7d0f800 --- /dev/null +++ b/const/primitive/ZERO.js @@ -0,0 +1 @@ +module.exports = ZERO = `ศูนย์`; \ No newline at end of file diff --git a/const/primitive/negative.js b/const/primitive/negative.js new file mode 100644 index 0000000..54ac975 --- /dev/null +++ b/const/primitive/negative.js @@ -0,0 +1 @@ +module.exports = negative = `ลบ`; \ No newline at end of file diff --git a/const/regex/ElevenToNineteenRegex.js b/const/regex/ElevenToNineteenRegex.js new file mode 100644 index 0000000..c81cc2b --- /dev/null +++ b/const/regex/ElevenToNineteenRegex.js @@ -0,0 +1 @@ +module.exports = ElevenToNineteenRegex = /^สิบ(เอ็ด|สอง|สาม|สี่|ห้า|หก|เจ็ด|แปด|เก้า)$/; diff --git a/const/regex/LAST6DIGITPATTERN.js b/const/regex/LAST6DIGITPATTERN.js new file mode 100644 index 0000000..3afc104 --- /dev/null +++ b/const/regex/LAST6DIGITPATTERN.js @@ -0,0 +1 @@ +module.exports = LAST6DIGITPATTERN = /\d{1,6}$/g;; \ No newline at end of file diff --git a/const/regex/OneToTenTextRegex.js b/const/regex/OneToTenTextRegex.js new file mode 100644 index 0000000..6e30592 --- /dev/null +++ b/const/regex/OneToTenTextRegex.js @@ -0,0 +1,2 @@ +module.exports = OneToTenTextRegex = + /^(หนึ่ง|สอง|สาม|สี่|ห้า|หก|เจ็ด|แปด|เก้า|สิบ)$/; \ No newline at end of file diff --git a/const/regex/SPLITPATTERN.js b/const/regex/SPLITPATTERN.js new file mode 100644 index 0000000..6b8b8f1 --- /dev/null +++ b/const/regex/SPLITPATTERN.js @@ -0,0 +1 @@ +module.exports = SPLITPATTERN = /^(\d*)(\.\d{0,2}0*)?$/; \ No newline at end of file diff --git a/const/regex/TwentyToNinetyNine.js b/const/regex/TwentyToNinetyNine.js new file mode 100644 index 0000000..521fcf7 --- /dev/null +++ b/const/regex/TwentyToNinetyNine.js @@ -0,0 +1,2 @@ +module.exports = TwentyToNinetyNine = + /^(ยี่|สาม|สี่|ห้า|หก|เจ็ด|แปด|เก้า)สิบ(เอ็ด|สอง|สาม|สี่|ห้า|หก|เจ็ด|แปด|เก้า)?$/; \ No newline at end of file diff --git a/const/regex/ValidSATANGRegex.js b/const/regex/ValidSATANGRegex.js new file mode 100644 index 0000000..cb038c9 --- /dev/null +++ b/const/regex/ValidSATANGRegex.js @@ -0,0 +1,2 @@ +module.exports = ValidSATANGRegex = + /((ยี่|สาม|สี่|ห้า|หก|เจ็ด|แปด|เก้า)?(สิบ)(เอ็ด|สอง|สาม|สี่|ห้า|หก|เจ็ด|แปด|เก้า)?)สตางค์|(หนึ่ง|สอง|สาม|สี่|ห้า|หก|เจ็ด|แปด|เก้า|สิบ)สตางค์|(ถ้วน)/gs; \ No newline at end of file diff --git a/const/regex/defaultBulkBahtTextPat.js b/const/regex/defaultBulkBahtTextPat.js new file mode 100644 index 0000000..8a1a5d7 --- /dev/null +++ b/const/regex/defaultBulkBahtTextPat.js @@ -0,0 +1 @@ +module.exports = defaultBulkBahtTextPat = /\b(\d+)(\.\d{0,2}0*)?\b/g; \ No newline at end of file diff --git a/const/regex/defaultBulkBahtTextSkips.js b/const/regex/defaultBulkBahtTextSkips.js new file mode 100644 index 0000000..b20a183 --- /dev/null +++ b/const/regex/defaultBulkBahtTextSkips.js @@ -0,0 +1 @@ +module.exports = defaultBulkBahtTextSkips = [/\b5+\+?\b/]; \ No newline at end of file diff --git a/const/regex/octalRegex1.js b/const/regex/octalRegex1.js new file mode 100644 index 0000000..cd462d8 --- /dev/null +++ b/const/regex/octalRegex1.js @@ -0,0 +1 @@ +module.exports = octalRegex1 = /^0o?[0-7]+$/i; \ No newline at end of file diff --git a/const/regex/octalRegex2.js b/const/regex/octalRegex2.js new file mode 100644 index 0000000..041a9d7 --- /dev/null +++ b/const/regex/octalRegex2.js @@ -0,0 +1 @@ +module.exports = octalRegex2 = /^0+[0-7]+$/i; \ No newline at end of file diff --git a/consts.js b/consts.js deleted file mode 100644 index ce1cd3a..0000000 --- a/consts.js +++ /dev/null @@ -1,233 +0,0 @@ -const DEBUG = false; - -const GoogleSheetsCellCharactersLimit = 50000; -const VERSION = `1.4.2`; - -const negative = `ลบ`; - -const SPECIALONE = `เอ็ด`; -const SPECIALTWO = `ยี่`; -const TEN = `สิบ`; -const BAHT = `บาท`; -const MILLION = `ล้าน`; -const FULLBAHT = `ถ้วน`; -const SATANG = `สตางค์`; -const READAS = `อ่านว่า`; - -const LAST6DIGITPATTERN = /\d{1,6}$/g; -const SPLITPATTERN = /^(\d*)(\.\d{0,2}0*)?$/; - -const ZERO = `ศูนย์`; -const ONE = `หนึ่ง`; -const TWO = `สอง`; -const THREE = `สาม`; -const FOUR = `สี่`; -const FIVE = `ห้า`; -const SIX = `หก`; -const SEVEN = `เจ็ด`; -const EIGHT = `แปด`; -const NINE = `เก้า`; -const THAINUMBERWORDS = [ - ZERO, - ONE, - TWO, - THREE, - FOUR, - FIVE, - SIX, - SEVEN, - EIGHT, - NINE, - TEN, -]; -const ONETONINE = [ONE, TWO, THREE, FOUR, FIVE, SIX, SEVEN, EIGHT, NINE]; -const LTHAISATANGWORDS = [ - ``, - SPECIALONE, - TWO, - THREE, - FOUR, - FIVE, - SIX, - SEVEN, - EIGHT, - NINE, -]; -const FTHAISATANGWORDS = [ - ``, - ``, - SPECIALTWO, - THREE, - FOUR, - FIVE, - SIX, - SEVEN, - EIGHT, - NINE, -]; -const HUNDRED = `ร้อย`; -const THOUSAND = `พัน`; -const TENTHOUSAND = `หมื่น`; -const HUNDREDTHOUSAND = `แสน`; -const REVERSETHAIDIGITWORDS = [ - HUNDREDTHOUSAND, - TENTHOUSAND, - THOUSAND, - HUNDRED, - TEN, - "", -]; - -const THAI2ARABICNumerals = [ - { th: `๐`, a: `0` }, - { th: `๑`, a: `1` }, - { th: `๒`, a: `2` }, - { th: `๓`, a: `3` }, - { th: `๔`, a: `4` }, - { th: `๕`, a: `5` }, - { th: `๖`, a: `6` }, - { th: `๗`, a: `7` }, - { th: `๘`, a: `8` }, - { th: `๙`, a: `9` }, -]; - -const ValidSATANGRegex = - /((ยี่|สาม|สี่|ห้า|หก|เจ็ด|แปด|เก้า)?(สิบ)(เอ็ด|สอง|สาม|สี่|ห้า|หก|เจ็ด|แปด|เก้า)?)สตางค์|(หนึ่ง|สอง|สาม|สี่|ห้า|หก|เจ็ด|แปด|เก้า|สิบ)สตางค์|(ถ้วน)/gs; - -const defaultBulkBahtTextPat = /\b(\d+)(\.\d{0,2}0*)?\b/g; -const defaultBulkBahtTextSkips = [/\b5+\+?\b/]; - - -const OneToTenTextRegex = /^(หนึ่ง|สอง|สาม|สี่|ห้า|หก|เจ็ด|แปด|เก้า|สิบ)$/; -const ElevenToNineteenRegex = /^สิบ(เอ็ด|สอง|สาม|สี่|ห้า|หก|เจ็ด|แปด|เก้า)$/; -const TwentyToNinetyNine = - /^(ยี่|สาม|สี่|ห้า|หก|เจ็ด|แปด|เก้า)สิบ(เอ็ด|สอง|สาม|สี่|ห้า|หก|เจ็ด|แปด|เก้า)?$/; - -const large_numbers = [ - { name: "Million", powof10: 6 }, - { name: "Billion", powof10: 9 }, - { name: "Trillion", powof10: 12 }, - { name: "Quadrillion", powof10: 15 }, - { name: "Quintillion", powof10: 18 }, - { name: "Sextillion", powof10: 21 }, - { name: "Septillion", powof10: 24 }, - { name: "Octillion", powof10: 27 }, - { name: "Nonillion", powof10: 30 }, - { name: "Decillion", powof10: 33 }, - { name: "Undecillion", powof10: 36 }, - { name: "Duodecillion", powof10: 39 }, - { name: "Tredecillion", powof10: 42 }, - { name: "Quattuordecillion", powof10: 45 }, - { name: "Quindecillion", powof10: 48 }, - { name: "Sedecillion", powof10: 51 }, - { name: "Septendecillion", powof10: 54 }, - { name: "Octodecillion", powof10: 57 }, - { name: "Novendecillion", powof10: 60 }, - { name: "Vigintillion", powof10: 63 }, - { name: "Unvigintillion", powof10: 66 }, - { name: "Duovigintillion", powof10: 69 }, - { name: "Tresvigintillion", powof10: 72 }, - { name: "Quattuorvigintillion", powof10: 75 }, - { name: "Quinvigintillion", powof10: 78 }, - { name: "Sesvigintillion", powof10: 81 }, - { name: "Septemvigintillion", powof10: 84 }, - { name: "Octovigintillion", powof10: 87 }, - { name: "Novemvigintillion", powof10: 90 }, - { name: "Trigintillion", powof10: 93 }, - { name: "Untrigintillion", powof10: 96 }, - { name: "Duotrigintillion", powof10: 99 }, - { name: "Trestrigintillion", powof10: 102 }, - { name: "Quattuortrigintillion", powof10: 105 }, - { name: "Quintrigintillion", powof10: 108 }, - { name: "Sestrigintillion", powof10: 111 }, - { name: "Septentrigintillion", powof10: 114 }, - { name: "Octotrigintillion", powof10: 117 }, - { name: "Noventrigintillion", powof10: 120 }, - { name: "Quadragintillion", powof10: 123 }, - { name: "Quinquagintillion", powof10: 153 }, - { name: "Sexagintillion", powof10: 183 }, - { name: "Septuagintillion", powof10: 213 }, - { name: "Octogintillion", powof10: 243 }, - { name: "Nonagintillion", powof10: 273 }, - { name: "Centillion", powof10: 303 }, - { name: "Uncentillion", powof10: 306 }, - { name: "Decicentillion", powof10: 333 }, - { name: "Undecicentillion", powof10: 336 }, - { name: "Viginticentillion", powof10: 363 }, - { name: "Unviginticentillion", powof10: 366 }, - { name: "Trigintacentillion", powof10: 393 }, - { name: "Quadragintacentillion", powof10: 423 }, - { name: "Quinquagintacentillion", powof10: 453 }, - { name: "Sexagintacentillion", powof10: 483 }, - { name: "Septuagintacentillion", powof10: 513 }, - { name: "Octogintacentillion", powof10: 543 }, - { name: "Nonagintacentillion", powof10: 573 }, - { name: "Ducentillion", powof10: 603 }, - { name: "Trecentillion", powof10: 903 }, - { name: "Quadringentillion", powof10: 1203 }, - { name: "Quingentillion", powof10: 1503 }, - { name: "Sescentillion", powof10: 1803 }, - { name: "Septingentillion", powof10: 2103 }, - { name: "Octingentillion", powof10: 2403 }, - { name: "Nongentillion", powof10: 2703 }, - { name: "Millinillion", powof10: 3003 }, - { name: "Googol", powof10: 100 }, -]; - -const MAX_SAFE_INTEGER = 9007199254740991; - -const octalRegex1 = /^0o?[0-7]+$/i; -const octalRegex2 = /^0+[0-7]+$/i; - -let THB = new Intl.NumberFormat("th-TH", { - style: "currency", - currency: "THB", -}); - -module.exports = { - DEBUG, - GoogleSheetsCellCharactersLimit, - VERSION, - SPECIALONE, - SPECIALTWO, - TEN, - BAHT, - MILLION, - FULLBAHT, - SATANG, - READAS, - LAST6DIGITPATTERN, - SPLITPATTERN, - ZERO, - ONE, - TWO, - THREE, - FOUR, - FIVE, - SIX, - SEVEN, - EIGHT, - NINE, - THAINUMBERWORDS, - ONETONINE, - LTHAISATANGWORDS, - FTHAISATANGWORDS, - HUNDRED, - THOUSAND, - TENTHOUSAND, - HUNDREDTHOUSAND, - REVERSETHAIDIGITWORDS, - THAI2ARABICNumerals, - ValidSATANGRegex, - defaultBulkBahtTextPat, - defaultBulkBahtTextSkips, - OneToTenTextRegex, - ElevenToNineteenRegex, - TwentyToNinetyNine, - large_numbers, - octalRegex1, - octalRegex2, - MAX_SAFE_INTEGER, - THB, - negative, -}; \ No newline at end of file diff --git a/index.js b/index.js index 6ed42a0..a9628e0 100644 --- a/index.js +++ b/index.js @@ -34,7 +34,7 @@ const { MAX_SAFE_INTEGER, THB, negative, -} = require("./consts.js"); +} = require("./const"); const { isOctal, toDec } = require("./octal.js"); const op = require(`operation-strint`) diff --git a/index.test.js b/index.test.js index 73ead7f..5aeb107 100644 --- a/index.test.js +++ b/index.test.js @@ -1,7 +1,7 @@ const { FULLBAHT, BAHT -} = require("./consts") +} = require("./const") const { NumText, BT, diff --git a/octal.js b/octal.js index eacff13..96c2831 100644 --- a/octal.js +++ b/octal.js @@ -1,4 +1,4 @@ -const {octalRegex1, octalRegex2} = require('./consts') +const {octalRegex1, octalRegex2} = require('./const') const op = require(`operation-strint`) const isOctal = (money) => { if (typeof(money) !== `string`) return undefined; diff --git a/package-lock.json b/package-lock.json index b66fd0f..c59a6ec 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "bahtrext", - "version": "1.4.1", + "version": "1.4.3", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "bahtrext", - "version": "1.4.1", + "version": "1.4.2", "license": "ISC", "dependencies": { "operation-strint": "^1.0.8", diff --git a/package.json b/package.json index ba17a8c..7b5eead 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "bahtrext", - "version": "1.4.2", + "version": "1.4.3", "description": "BahtText Stringify", "main": "index.js", "scripts": {