Skip to content

Commit

Permalink
Update readVnNumber to accept BigInt
Browse files Browse the repository at this point in the history
Expanded input types for the `readVnNumber` function to additionally include BigInt. This function, which previously only accepted string or number data types, can now process larger integers. Changes also include a minor refinement in the comment documentation for better readability.
  • Loading branch information
hckhanh committed Feb 26, 2024
1 parent 8d38a21 commit f05c9ec
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 3 deletions.
2 changes: 1 addition & 1 deletion deno.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@hckhanh/vn-number",
"version": "1.1.1",
"version": "1.1.2",
"exports": "./src/index.ts",
"exclude": [
".github/",
Expand Down
4 changes: 4 additions & 0 deletions src/read/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,8 @@ describe('index', function () {
it('should read number 2.000.000.000 in number', function () {
expect(readVnNumber(2000000000)).to.equal('hai tỷ')
})

it('should read number 2.500.000.000 in BigIn', function () {
expect(readVnNumber(BigInt(2500000000))).to.equal('hai tỷ năm trăm triệu')
})
})
5 changes: 3 additions & 2 deletions src/read/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,13 @@ import NumberReader from './NumberReader.ts'
* ```ts
* import { readVnNumber } from '@hckhanh/vn-number'
*
* readVnNumber('19990000') // or readVnNumber(19990000) // output: mười chín triệu chín trăm chín mươi nghìn
* readVnNumber('19990000') // or readVnNumber(19990000)
* // output: mười chín triệu chín trăm chín mươi nghìn
* ```
*
* @param number the number to read. It can be string or number type
* @return the Vietnamese number in string.
*/
export function readVnNumber(number: string | number): string {
export function readVnNumber(number: string | number | BigInt): string {
return NumberReader.read(number)
}

0 comments on commit f05c9ec

Please sign in to comment.