bahttext 2.1.2 → 2.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README-en.md CHANGED
@@ -1,19 +1,29 @@
1
1
  # bahttext
2
2
 
3
- [![Codecov](https://img.shields.io/codecov/c/github/jojoee/bahttext.svg)](https://codecov.io/github/jojoee/bahttext)
4
3
  [![Version - npm](https://img.shields.io/npm/v/bahttext.svg)](https://www.npmjs.com/package/bahttext)
5
4
  [![License - npm](https://img.shields.io/npm/l/bahttext.svg)](http://opensource.org/licenses/MIT)
6
5
  [![semantic-release](https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg?style=flat-square)](https://github.com/semantic-release/semantic-release) [![Greenkeeper badge](https://badges.greenkeeper.io/jojoee/bahttext.svg)](https://greenkeeper.io/)
7
-
8
- ![continuous integration](https://github.com/jojoee/bahttext/workflows/continuous%20integration/badge.svg?branch=master)
9
- ![release](https://github.com/jojoee/bahttext/workflows/release/badge.svg?branch=master)
10
- ![runnable](https://github.com/jojoee/bahttext/workflows/runnable/badge.svg?branch=master)
11
- ![runnable old node](https://github.com/jojoee/bahttext/workflows/runnable%20old%20node/badge.svg?branch=master)
6
+ [![Codecov](https://img.shields.io/codecov/c/github/jojoee/bahttext.svg)](https://codecov.io/github/jojoee/bahttext)
12
7
  [![Mutation testing badge](https://img.shields.io/endpoint?style=flat&url=https%3A%2F%2Fbadge-api.stryker-mutator.io%2Fgithub.com%2Fjojoee%2Fbahttext%2Fmaster)](https://dashboard.stryker-mutator.io/reports/github.com/jojoee/bahttext/master)
13
8
 
14
- Language: [ไทย](https://github.com/jojoee/bahttext/blob/master/README.md), [English](https://github.com/jojoee/bahttext/blob/master/README-en.md)
15
-
16
- Change number to Thai pronunciation string, test against [Google Sheets BAHTTEXT function](https://support.google.com/docs/answer/9982303?hl=en), [Demo page](https://jojoee.github.io/bahttext/)
9
+ [![continuous integration](https://github.com/jojoee/bahttext/workflows/continuous%20integration/badge.svg?branch=master)](https://github.com/jojoee/bahttext/actions/workflows/continuous-integration.yml)
10
+ [![release](https://github.com/jojoee/bahttext/workflows/release/badge.svg?branch=master)](https://github.com/jojoee/bahttext/actions/workflows/release.yml)
11
+ [![runnable](https://github.com/jojoee/bahttext/workflows/runnable/badge.svg?branch=master)](https://github.com/jojoee/bahttext/actions/workflows/runnable.yml)
12
+ [![runnable old node](https://github.com/jojoee/bahttext/workflows/runnable%20old%20node/badge.svg?branch=master)](https://github.com/jojoee/bahttext/actions/workflows/runnable-old-node.yml)
13
+
14
+ Only `TH` and `EN` languages are maintained, the rest is auto-generated by ChatGPT API. Language:
15
+ [ไทย](https://github.com/jojoee/bahttext/blob/master/README.md),
16
+ [English](https://github.com/jojoee/bahttext/blob/master/README-en.md),
17
+ [中国大陆](https://github.com/jojoee/bahttext/blob/master/doc/README-cn.md),
18
+ [대한민국](https://github.com/jojoee/bahttext/blob/master/doc/README-kr.md),
19
+ [Việt Nam](https://github.com/jojoee/bahttext/blob/master/doc/README-vn.md),
20
+ [日本](https://github.com/jojoee/bahttext/blob/master/doc/README-jp.md),
21
+ [Россия](https://github.com/jojoee/bahttext/blob/master/doc/README-ru.md),
22
+ [Español](https://github.com/jojoee/bahttext/blob/master/doc/README-la.md),
23
+ [Français](https://github.com/jojoee/bahttext/blob/master/doc/README-fr.md)
24
+
25
+ Change number to Thai pronunciation string, test
26
+ against [Google Sheets BAHTTEXT function](https://support.google.com/docs/answer/9982303?hl=en), [Demo page](https://jojoee.github.io/bahttext/)
17
27
 
18
28
  ## Installation
19
29
 
@@ -66,40 +76,19 @@ bahttext(-0.20) // ลบยี่สิบสตางค์
66
76
  ```
67
77
 
68
78
  ## Note
69
- - [x] Compatible with all browsers
70
- - [x] Node.js version support: 6+
71
- - [x] 0 Dependencies
72
- - [x] Unit test
73
- - [x] Remove duplication between test code and test-case-csv file
74
- - [x] [Demo page](https://jojoee.github.io/bahttext/)
75
- - [x] Support negative number
76
- - [x] Fix semantic-release
77
79
 
78
- ## Other languages
79
- - Python: [jojoee/pybaht](https://github.com/jojoee/pybaht)
80
+ - Compatible with all browsers
81
+ - Node.js version support: 6+
82
+ - 0 Dependencies
83
+ - Demo page
84
+ - Support negative number
80
85
 
81
- ## CMD
86
+ ## Other languages
82
87
 
83
- ```
84
- brew install curl
85
- brew install jq
86
- npm install -g csvtojson
87
- curl -L -o ./misc/testcases.csv https://docs.google.com/spreadsheets/d/e/2PACX-1vTb8PIKzgo07rn9UpcjqE0YrdMAmf4fyDbL2plUieLCyrn_5O3vDvece7UfkaArWQLUSsaw92jVpY_z/pub?gid=0&single=true&output=csv
88
- csvtojson ./misc/testcases.csv | jq > ./misc/testcases.json
89
-
90
- # to update dependency version
91
- npm update --save
92
- npm audit fix --force
93
-
94
- # mutation test
95
- npm install -g stryker-cli
96
- stryker init
97
- export STRYKER_DASHBOARD_API_KEY=<the_project_api_token>
98
- echo $STRYKER_DASHBOARD_API_KEY
99
- npx stryker run
100
- ```
88
+ - Python: [jojoee/pybaht](https://github.com/jojoee/pybaht)
101
89
 
102
90
  ## Reference
91
+
103
92
  - [Google Sheets BAHTTEXT function](https://support.google.com/docs/answer/9982303?hl=en)
104
93
  - [Microsoft Office's BAHTTEXT function](https://support.office.com/en-us/article/BAHTTEXT-function-5ba4d0b4-abd3-4325-8d22-7a92d59aab9c)
105
94
  - Inspired by [earthchie/BAHTTEXT.js](https://github.com/earthchie/BAHTTEXT.js)
package/README.md CHANGED
@@ -1,34 +1,46 @@
1
1
  # bahttext
2
2
 
3
- [![Codecov](https://img.shields.io/codecov/c/github/jojoee/bahttext.svg)](https://codecov.io/github/jojoee/bahttext)
4
3
  [![Version - npm](https://img.shields.io/npm/v/bahttext.svg)](https://www.npmjs.com/package/bahttext)
5
4
  [![License - npm](https://img.shields.io/npm/l/bahttext.svg)](http://opensource.org/licenses/MIT)
6
5
  [![semantic-release](https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg?style=flat-square)](https://github.com/semantic-release/semantic-release) [![Greenkeeper badge](https://badges.greenkeeper.io/jojoee/bahttext.svg)](https://greenkeeper.io/)
7
- ![continuous integration](https://github.com/jojoee/bahttext/workflows/continuous%20integration/badge.svg?branch=master)
8
- ![release](https://github.com/jojoee/bahttext/workflows/release/badge.svg?branch=master)
9
- ![runnable](https://github.com/jojoee/bahttext/workflows/runnable/badge.svg?branch=master)
10
- ![runnable old node](https://github.com/jojoee/bahttext/workflows/runnable%20old%20node/badge.svg?branch=master)
6
+ [![Codecov](https://img.shields.io/codecov/c/github/jojoee/bahttext.svg)](https://codecov.io/github/jojoee/bahttext)
11
7
  [![Mutation testing badge](https://img.shields.io/endpoint?style=flat&url=https%3A%2F%2Fbadge-api.stryker-mutator.io%2Fgithub.com%2Fjojoee%2Fbahttext%2Fmaster)](https://dashboard.stryker-mutator.io/reports/github.com/jojoee/bahttext/master)
12
8
 
13
- ภาษา: [ไทย](https://github.com/jojoee/bahttext/blob/master/README.md), [English](https://github.com/jojoee/bahttext/blob/master/README-en.md)
14
-
15
- เปลี่ยนตัวเลข เป็นคำอ่านภาษาไทย, โมดูลตัวนี้ได้ทำการทดสอบกับ [Google Sheets BAHTTEXT function](https://support.google.com/docs/answer/9982303?hl=en), [Demo page](https://jojoee.github.io/bahttext/) เรียบร้อยแล้ว
9
+ [![continuous integration](https://github.com/jojoee/bahttext/workflows/continuous%20integration/badge.svg?branch=master)](https://github.com/jojoee/bahttext/actions/workflows/continuous-integration.yml)
10
+ [![release](https://github.com/jojoee/bahttext/workflows/release/badge.svg?branch=master)](https://github.com/jojoee/bahttext/actions/workflows/release.yml)
11
+ [![runnable](https://github.com/jojoee/bahttext/workflows/runnable/badge.svg?branch=master)](https://github.com/jojoee/bahttext/actions/workflows/runnable.yml)
12
+ [![runnable old node](https://github.com/jojoee/bahttext/workflows/runnable%20old%20node/badge.svg?branch=master)](https://github.com/jojoee/bahttext/actions/workflows/runnable-old-node.yml)
13
+
14
+ Only `TH` and `EN` languages are maintained, the rest is auto-generated by ChatGPT API. Language:
15
+ [ไทย](https://github.com/jojoee/bahttext/blob/master/README.md),
16
+ [English](https://github.com/jojoee/bahttext/blob/master/README-en.md),
17
+ [中国大陆](https://github.com/jojoee/bahttext/blob/master/doc/README-cn.md),
18
+ [대한민국](https://github.com/jojoee/bahttext/blob/master/doc/README-kr.md),
19
+ [Việt Nam](https://github.com/jojoee/bahttext/blob/master/doc/README-vn.md),
20
+ [日本](https://github.com/jojoee/bahttext/blob/master/doc/README-jp.md),
21
+ [Россия](https://github.com/jojoee/bahttext/blob/master/doc/README-ru.md),
22
+ [Español](https://github.com/jojoee/bahttext/blob/master/doc/README-la.md),
23
+ [Français](https://github.com/jojoee/bahttext/blob/master/doc/README-fr.md)
24
+
25
+ เปลี่ยนตัวเลข เป็นคำอ่านภาษาไทย,
26
+ โมดูลตัวนี้ได้ทำการทดสอบกับ [Google Sheets BAHTTEXT function](https://support.google.com/docs/answer/9982303?hl=en), [Demo page](https://jojoee.github.io/bahttext/)
27
+ เรียบร้อยแล้ว
16
28
 
17
29
  ## ติดตั้ง
18
30
 
19
31
  ```
20
- // ติดตั้งด้วย CommonJS
32
+ // CommonJS
21
33
  npm install bahttext
22
34
  const { bahttext } = require('bahttext')
23
35
 
24
- // ติดตั้งด้วย Bower
36
+ // Bower
25
37
  bower install bahttext
26
38
  <script src="bower_components/bahttext/src/index.js"></script>
27
39
 
28
- // ติดตั้งด้วย githack
40
+ // githack
29
41
  <script src="https://raw.githack.com/jojoee/bahttext/master/src/index.js"></script>
30
42
 
31
- // ติดตั้งด้วย ES6
43
+ // ES6
32
44
  npm install bahttext
33
45
  import { bahttext } from "bahttext"
34
46
  ```
@@ -65,40 +77,20 @@ bahttext(-0.20) // ลบยี่สิบสตางค์
65
77
  ```
66
78
 
67
79
  ## ฟีเจอร์
68
- - [x] สามารถใช้งานได้ทุก เบราว์เซอร์
69
- - [x] สามารถใช้งานได้ตั้งแต่ Node.js version 6+
70
- - [x] 0 Dependencies
71
- - [x] ทำการทดสอบแบบ unit test
72
- - [x] ลดการซ้ำซ้อนของการเขียน ระหว่าง code และ ไฟล์ csv ในการทำการทดสอบ
73
- - [x] [หน้าตัวอย่างการใช้งาน](https://jojoee.github.io/bahttext/)
74
- - [x] สนับสนุนการใช้งานกับตัวเลขติดลบ
75
- - [x] แก้ไข semantic-release
76
80
 
77
- ## ภาษาอื่นๆ
78
- - Python: [jojoee/pybaht](https://github.com/jojoee/pybaht)
81
+ - สามารถใช้งานได้ทุก เบราว์เซอร์
82
+ - สามารถใช้งานได้ตั้งแต่ Node.js version 6+
83
+ - 0 Dependencies
84
+ - หน้าตัวอย่างการใช้งาน
85
+ - สนับสนุนการใช้งานกับตัวเลขติดลบ
79
86
 
80
- ## CMD
87
+ ## ภาษาอื่นๆ
81
88
 
82
- ```
83
- brew install curl
84
- brew install jq
85
- npm install -g csvtojson
86
- curl -L -o ./misc/testcases.csv https://docs.google.com/spreadsheets/d/e/2PACX-1vTb8PIKzgo07rn9UpcjqE0YrdMAmf4fyDbL2plUieLCyrn_5O3vDvece7UfkaArWQLUSsaw92jVpY_z/pub?gid=0&single=true&output=csv
87
- csvtojson ./misc/testcases.csv | jq > ./misc/testcases.json
88
-
89
- # to update dependency version
90
- npm update --save
91
- npm audit fix --force
92
-
93
- # mutation test
94
- npm install -g stryker-cli
95
- stryker init
96
- export STRYKER_DASHBOARD_API_KEY=<the_project_api_token>
97
- echo $STRYKER_DASHBOARD_API_KEY
98
- npx stryker run
99
- ```
89
+ - Python: [jojoee/pybaht](https://github.com/jojoee/pybaht)
100
90
 
101
91
  ## อ้างอิง
92
+
102
93
  - [Google Sheets BAHTTEXT function](https://support.google.com/docs/answer/9982303?hl=en)
103
94
  - [Microsoft Office's BAHTTEXT function](https://support.office.com/en-us/article/BAHTTEXT-function-5ba4d0b4-abd3-4325-8d22-7a92d59aab9c)
104
95
  - แรงบัลดาลใจจาก [earthchie/BAHTTEXT.js](https://github.com/earthchie/BAHTTEXT.js)
96
+
package/package.json CHANGED
@@ -1,19 +1,20 @@
1
1
  {
2
2
  "name": "bahttext",
3
- "version": "2.1.2",
3
+ "version": "2.2.0",
4
4
  "description": "Change number to Thai pronunciation string",
5
5
  "main": "src/index.js",
6
- "typings": "src/index.js",
6
+ "typings": "src/index.d.ts",
7
7
  "scripts": {
8
8
  "jest": "jest",
9
9
  "jest.watch": "jest --watch",
10
10
  "coverage.check": "jest --coverage",
11
+ "build": "tsc",
11
12
  "semantic-release": "semantic-release",
12
13
  "standard": "standard",
13
14
  "standard.fix": "standard --fix",
14
15
  "test": "jest",
15
16
  "test.watch": "jest --watch",
16
- "validate": "npm run standard && npm run coverage.check"
17
+ "validate": "npm run standard && npm run coverage.check && npm run build"
17
18
  },
18
19
  "repository": {
19
20
  "type": "git",
@@ -36,10 +37,15 @@
36
37
  "devDependencies": {
37
38
  "@stryker-mutator/core": "^6.3.1",
38
39
  "@stryker-mutator/jest-runner": "^6.3.1",
40
+ "@to-da-moon/thai-baht-lib": "^0.0.12",
41
+ "baht": "^0.7.1",
39
42
  "jest": "^26.6.3",
40
43
  "jest-expect-message": "^1.0.2",
41
44
  "semantic-release": "^19.0.5",
42
- "standard": "^15.0.1"
45
+ "standard": "^15.0.1",
46
+ "thai-baht-text": "^1.0.8",
47
+ "thai-baht-text-ts": "^1.1.0",
48
+ "typescript": "*"
43
49
  },
44
50
  "jest": {
45
51
  "setupFilesAfterEnv": [
package/src/index.d.ts ADDED
@@ -0,0 +1,35 @@
1
+ declare namespace _default {
2
+ export { bahttext };
3
+ }
4
+ export default _default;
5
+ /**
6
+ * Change number to Thai pronunciation string
7
+ *
8
+ * @public
9
+ * @param {number} num
10
+ * @returns {string}
11
+ */
12
+ export function bahttext(num: number): string;
13
+ /**
14
+ * @private
15
+ * @param {number[]} nums
16
+ * @returns {string}
17
+ */
18
+ export function bahtxtNum2Word(nums: number[]): string;
19
+ /**
20
+ * @private
21
+ * @todo improve performance
22
+ * @param {string} str
23
+ * @returns {string}
24
+ */
25
+ export function bahtxtGrammarFix(str: string): string;
26
+ /**
27
+ * bahtxtCombine baht and satang
28
+ * and also adding unit
29
+ *
30
+ * @private
31
+ * @param {string} baht
32
+ * @param {string} satang
33
+ * @returns {string}
34
+ */
35
+ export function bahtxtCombine(baht: string, satang: string): string;
package/src/index.js CHANGED
@@ -5,6 +5,7 @@ const bahtxtConst = {
5
5
  }
6
6
 
7
7
  /**
8
+ * @private
8
9
  * @param {number[]} nums
9
10
  * @returns {string}
10
11
  */
@@ -32,61 +33,54 @@ function bahtxtNum2Word (nums) {
32
33
  }
33
34
 
34
35
  /**
36
+ * @private
35
37
  * @todo improve performance
36
38
  * @param {string} str
37
39
  * @returns {string}
38
40
  */
39
41
  function bahtxtGrammarFix (str) {
40
- let result = str
41
-
42
- result = result.replace(/หนึ่งสิบ/g, 'สิบ')
43
- result = result.replace(/สองสิบ/g, 'ยี่สิบ')
44
- result = result.replace(/สิบหนึ่ง/g, 'สิบเอ็ด')
45
-
46
- return result
42
+ return str.replace(/หนึ่งสิบ/g, 'สิบ')
43
+ .replace(/สองสิบ/g, 'ยี่สิบ')
44
+ .replace(/สิบหนึ่ง/g, 'สิบเอ็ด')
47
45
  }
48
46
 
49
47
  /**
50
48
  * bahtxtCombine baht and satang
51
49
  * and also adding unit
52
50
  *
51
+ * @private
53
52
  * @param {string} baht
54
53
  * @param {string} satang
55
54
  * @returns {string}
56
55
  */
57
56
  function bahtxtCombine (baht, satang) {
58
- let result = ''
59
-
60
- if (baht === '' && satang === '') {
61
- result = bahtxtConst.defaultResult
62
- } else if (baht !== '' && satang === '') {
63
- result = baht + 'บาท' + 'ถ้วน'
64
- } else if (baht === '' && satang !== '') {
65
- result = satang + 'สตางค์'
57
+ if (!baht && !satang) {
58
+ return bahtxtConst.defaultResult
59
+ } else if (baht && !satang) {
60
+ return baht + 'บาท' + 'ถ้วน'
61
+ } else if (!baht && satang) {
62
+ return satang + 'สตางค์'
66
63
  } else {
67
- result = baht + 'บาท' + satang + 'สตางค์'
64
+ return baht + 'บาท' + satang + 'สตางค์'
68
65
  }
69
-
70
- return result
71
66
  }
72
67
 
73
68
  /**
74
69
  * Change number to Thai pronunciation string
75
70
  *
71
+ * @public
76
72
  * @param {number} num
77
73
  * @returns {string}
78
74
  */
79
75
  function bahttext (num) {
80
- // no null
81
- if (!num) return bahtxtConst.defaultResult
82
- // no boolean
83
- if (typeof num === 'boolean') return bahtxtConst.defaultResult
84
- // must be number only
85
- if (isNaN(Number(num))) return bahtxtConst.defaultResult
86
- // not less than Number.MIN_SAFE_INTEGER
87
- if (num < Number.MIN_SAFE_INTEGER) return bahtxtConst.defaultResult
88
- // no more than Number.MAX_SAFE_INTEGER
89
- if (num > Number.MAX_SAFE_INTEGER) return bahtxtConst.defaultResult
76
+ if (!num || // no null
77
+ typeof num === 'boolean' || // no boolean
78
+ isNaN(Number(num)) || // must be number only
79
+ num < Number.MIN_SAFE_INTEGER || // not less than Number.MIN_SAFE_INTEGER
80
+ num > Number.MAX_SAFE_INTEGER // no more than Number.MAX_SAFE_INTEGER
81
+ ) {
82
+ return bahtxtConst.defaultResult
83
+ }
90
84
 
91
85
  // set
92
86
  const positiveNum = Math.abs(num)
@@ -94,7 +88,7 @@ function bahttext (num) {
94
88
  // split baht and satang e.g. 432.214567 >> 432, 21
95
89
  const bahtStr = Math.floor(positiveNum).toString()
96
90
  /** @type {string} */
97
- const satangStr = (positiveNum % 1 * 100).toFixed(2).split('.')[0]
91
+ const satangStr = (positiveNum % 1 * 100).toFixed(0)
98
92
 
99
93
  /** @type {number[]} */
100
94
  const bahtArr = Array.from(bahtStr).map(Number)
package/src/index.test.js CHANGED
@@ -4,9 +4,24 @@ const {
4
4
  bahtxtCombine: combine
5
5
  } = require('./index')
6
6
  const defaultResult = 'ศูนย์บาทถ้วน'
7
- const testCases = require('../misc/testcases.json')
7
+ const groupedTestCasesKey = 'categoryCase'
8
+ const googleSheetTestCases = require('../misc/testcases.json').map(item => {
9
+ item[groupedTestCasesKey] = `${item.category}-${item.case}`
10
+ return item
11
+ })
8
12
  jest.autoMockOff()
9
13
 
14
+ // TODO: move to somewhere else
15
+ // TODO: write test
16
+ function groupBy (arr, key) {
17
+ return arr.reduce((acc, curr) => {
18
+ acc[curr[key]] = (acc[curr[key]] || []).concat(curr)
19
+ return acc
20
+ }, {})
21
+ }
22
+
23
+ const groupedTestCases = groupBy(googleSheetTestCases, groupedTestCasesKey)
24
+
10
25
  // TODO: to be implemented
11
26
  describe('num2Word', () => {
12
27
  test('test', () => {
@@ -91,11 +106,14 @@ describe('bahttext', () => {
91
106
  }
92
107
  })
93
108
 
94
- test('numbers are imported from Google Sheet', () => {
95
- for (let i = 0; i < testCases.length; i++) {
96
- const customMessage = JSON.stringify(testCases[i])
97
- const number = Number(testCases[i].number)
98
- expect(bahttext(number), customMessage).toBe(testCases[i].text)
99
- }
100
- })
109
+ // numbers are imported from Google Sheets
110
+ for (const [groupedName, testCases] of Object.entries(groupedTestCases)) {
111
+ test(`imported Google Sheets: ${groupedName}`, () => {
112
+ for (let i = 0; i < testCases.length; i++) {
113
+ const customMessage = JSON.stringify(testCases[i])
114
+ const number = Number(testCases[i].number)
115
+ expect(bahttext(number), customMessage).toBe(testCases[i].text)
116
+ }
117
+ })
118
+ }
101
119
  })
package/bower.json DELETED
@@ -1,21 +0,0 @@
1
- {
2
- "name": "bahttext",
3
- "homepage": "https://github.com/jojoee/bahttext",
4
- "authors": [
5
- "Nathachai Thongniran <inid3a@gmail.com>"
6
- ],
7
- "description": "Change number to Thai pronunciation string",
8
- "main": "src/index.js",
9
- "keywords": [
10
- "baht",
11
- "thai"
12
- ],
13
- "license": "MIT",
14
- "ignore": [
15
- "**/.*",
16
- "node_modules",
17
- "bower_components",
18
- "test",
19
- "tests"
20
- ]
21
- }
package/index.html DELETED
@@ -1,127 +0,0 @@
1
- <!DOCTYPE html>
2
- <html lang="en">
3
- <head>
4
- <meta charset="UTF-8">
5
- <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
- <meta http-equiv="X-UA-Compatible" content="ie=edge">
7
- <title>bahttext.js</title>
8
- <link href='//fonts.googleapis.com/css?family=Raleway:400,300,600' rel='stylesheet' type='text/css'>
9
- <link rel="stylesheet" href="//cdnjs.cloudflare.com/ajax/libs/skeleton/2.0.4/skeleton.min.css">
10
- <link rel="stylesheet" href="//cdn.datatables.net/1.10.16/css/jquery.dataTables.min.css">
11
- <style>
12
- table {
13
- table-layout: fixed
14
- }
15
- td {
16
- overflow: hidden;
17
- white-space: nowrap;
18
- text-overflow: ellipsis;
19
- }
20
- </style>
21
- </head>
22
- <body>
23
- <div class="container">
24
- <div class="row">
25
- <h2>bahttext.js</h2>
26
- <hr>
27
-
28
- <input type="text" id="number" class="u-full-width" placeholder="number">
29
- <div id="result" class="u-full-width"></div><br>
30
- <button id="random">
31
- Random
32
- </button>
33
- <hr>
34
-
35
- <h4>Example</h4>
36
- <table id="example" class="display" cellspacing="0" width="100%">
37
- <thead>
38
- <tr>
39
- <th>category</th>
40
- <th>case</th>
41
- <th>number</th>
42
- <th>text</th>
43
- </tr>
44
- </thead>
45
- <tfoot>
46
- <tr>
47
- <th>category</th>
48
- <th>case</th>
49
- <th>number</th>
50
- <th>text</th>
51
- </tr>
52
- </tfoot>
53
- </table>
54
- </div>
55
- </div>
56
- <script src="//ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
57
- <script src="//cdn.datatables.net/1.10.16/js/jquery.dataTables.min.js"></script>
58
- <script src="//cdnjs.cloudflare.com/ajax/libs/random-js/1.0.8/random.min.js"></script>
59
- <script src="./src/index.js"></script>
60
- <script>
61
- // random
62
- const r = new Random(Random.engines.mt19937().autoSeed())
63
-
64
- const $number = $('#number')
65
- const $result = $('#result')
66
- const $random = $('#random')
67
- const $exmaple = $('#example')
68
-
69
- function updateResult() {
70
- const val = $number.val()
71
- const num = parseFloat(val)
72
- const html = bahttext(num)
73
-
74
- $result.html(html)
75
- }
76
-
77
- function randomNumber() {
78
- const num = r.real(Number.MIN_SAFE_INTEGER, Number.MAX_SAFE_INTEGER)
79
- $number.val(num)
80
- updateResult()
81
- }
82
-
83
- $(document).ready(function() {
84
- // init
85
- randomNumber()
86
-
87
- // number
88
- $number.on('input', function(e) {
89
- updateResult()
90
- })
91
-
92
- // random
93
- $random.click(function(e) {
94
- randomNumber()
95
- })
96
-
97
- // example
98
- $exmaple.DataTable({
99
- paging: false,
100
- searching: false,
101
- ordering: false,
102
- ajax: {
103
- url: 'misc/testcases.json',
104
- dataSrc: ''
105
- },
106
- columns: [
107
- {
108
- data: 'category',
109
- width: '10%'
110
- },
111
- {
112
- data: 'case',
113
- width: '16%'
114
- },
115
- {
116
- data: 'number',
117
- width: '22%'
118
- },
119
- {
120
- data: 'text'
121
- }
122
- ]
123
- })
124
- })
125
- </script>
126
- </body>
127
- </html>
package/stryker.conf.json DELETED
@@ -1,25 +0,0 @@
1
- {
2
- "$schema": "./node_modules/@stryker-mutator/core/schema/stryker-schema.json",
3
- "_comment": "This config was generated using 'stryker init'. Please take a look at: https://stryker-mutator.io/docs/stryker-js/configuration/ for more information.",
4
- "packageManager": "npm",
5
- "reporters": [
6
- "json",
7
- "progress",
8
- "html",
9
- "dashboard"
10
- ],
11
- "testRunner": "jest",
12
- "testRunner_comment": "Take a look at https://stryker-mutator.io/docs/stryker-js/jest-runner for information about the jest plugin.",
13
- "thresholds": {
14
- "high": 85,
15
- "low": 80,
16
- "break": 75
17
- },
18
- "dashboard": {
19
- "project": "github.com/jojoee/bahttext",
20
- "version": "master",
21
- "baseUrl": "https://dashboard.stryker-mutator.io/api/reports",
22
- "reportType": "full"
23
- },
24
- "coverageAnalysis": "perTest"
25
- }