Skip to content

Commit 8ee1df2

Browse files
author
Khánh Hoàng
committed
fix(types): update README and enhance code documentation
Expanded the README for better clarity and usage examples. Also, provided in-depth documentation in code for a clearer understanding of function use and behavior. Import statements in example codes within function comments have been removed to avoid redundancy.
1 parent 65b4fdc commit 8ee1df2

File tree

4 files changed

+56
-16
lines changed

4 files changed

+56
-16
lines changed

README.md

Lines changed: 41 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,51 @@
1-
# vn-number
1+
# vn-number 🇻🇳
22

3-
A bunch of utility functions that work with number in Vietnamese language
3+
🛠 A bunch of utility functions that work with number in 🇻🇳 Vietnamese language
44

55
## Features
66

7-
- [Zero dependency](https://jsr.io/@hckhanh/vn-number/dependencies)
8-
- Edge runtime built-in support [![Publish](https://github.com/hckhanh/vn-number/actions/workflows/publish.yml/badge.svg)](https://github.com/hckhanh/vn-number/actions/workflows/publish.yml)
7+
- [Zero dependencies](https://jsr.io/@hckhanh/vn-number/dependencies)
8+
- Built-in support for Edge runtime
9+
- Typesafe with TypeScript
10+
- Fully documented
911

1012
## Functions
1113

12-
- Read Vietnamese number (một triệu hai trăm năm mươi nghìn)
13-
- Format number in Vietnamese format (1.250.000)
14-
- Format VN currency (VND) (1.250.000 ₫)
15-
- Format percentage in Vietnamese format (99,1%)
14+
### Read Vietnamese number (một triệu hai trăm năm mươi nghìn)
15+
16+
```ts
17+
import { readVnNumber } from '@hckhanh/vn-number'
18+
19+
const result = readVnNumber(1250000)
20+
console.log(result) // một triệu hai trăm năm mươi nghìn
21+
```
22+
23+
### Format number in Vietnamese format (1.250.000)
24+
25+
```ts
26+
import { formatVnNumber } from '@hckhanh/vn-number'
27+
28+
const result = formatVnNumber(1250000)
29+
console.log(result) // 1.250.000
30+
```
31+
32+
### Format VN currency (VND) (1.250.000 ₫)
33+
34+
```ts
35+
import { formatVnCurrency } from '@hckhanh/vn-number'
36+
37+
const result = formatVnCurrency(1250000)
38+
console.log(result) // 1.250.000 ₫
39+
```
40+
41+
### Format percentage in Vietnamese format (99,1%)
42+
43+
```ts
44+
import { formatVnPercent } from '@hckhanh/vn-number'
45+
46+
const result = formatVnPercent(0.991)
47+
console.log(result) // 99,1%
48+
```
1649

1750
## Release Notes
1851

src/format/number.ts

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,6 @@ function formatNumber(
3535
*
3636
* @example
3737
* ```ts
38-
* import { formatVnNumber } from '@hckhanh/vn-number'
39-
*
4038
* formatVnNumber('19990000') // or formatVnNumber(19990000)
4139
* // output: 19.990.000
4240
* ```
@@ -58,8 +56,6 @@ export function formatVnNumber(
5856
*
5957
* @example
6058
* ```ts
61-
* import { formatVnCurrency } from '@hckhanh/vn-number'
62-
*
6359
* formatVnCurrency('19990000') // or formatVnCurrency(19990000)
6460
* // output: 19.990.000 ₫
6561
* ```
@@ -84,8 +80,6 @@ export function formatVnCurrency(
8480
*
8581
* @example
8682
* ```ts
87-
* import { formatVnPercent } from '@hckhanh/vn-number'
88-
*
8983
* formatVnPercent('0.99') // or formatVnPercent(0.99)
9084
* // output: 99%
9185
* ```

src/read/NumberReader.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,25 @@ import Million from './Million.ts'
44
import Billion from './Billion.ts'
55
import { InvalidNumberTypeError } from './Utils.ts'
66

7+
/**
8+
* Type of number
9+
*/
710
enum NumberType {
11+
/**
12+
* Number of the first group (100.000.000.xxx)
13+
*/
814
Numbers,
15+
/**
16+
* Number in the thousand group (100.000.xxx.000)
17+
*/
918
Thousand,
19+
/**
20+
* Number in the million group (100.xxx.000.000)
21+
*/
1022
Million,
23+
/**
24+
* Number in the billion group (xxx.000.000.000)
25+
*/
1126
Billion
1227
}
1328

src/read/index.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@ import NumberReader from './NumberReader.ts'
66
*
77
* @example
88
* ```ts
9-
* import { readVnNumber } from '@hckhanh/vn-number'
10-
*
119
* readVnNumber('19990000') // or readVnNumber(19990000)
1210
* // output: mười chín triệu chín trăm chín mươi nghìn
1311
* ```

0 commit comments

Comments
 (0)