-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
14 changed files
with
735 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
{ | ||
// 使用 IntelliSense 了解相关属性。 | ||
// 悬停以查看现有属性的描述。 | ||
// 欲了解更多信息,请访问: https://go.microsoft.com/fwlink/?linkid=830387 | ||
"version": "0.2.0", | ||
"configurations": [ | ||
{ | ||
"name": "test2 vite build", | ||
"request": "launch", | ||
"runtimeArgs": ["build"], | ||
"runtimeExecutable": "pnpm", | ||
"skipFiles": ["<node_internals>/**"], | ||
"type": "node" | ||
}, | ||
{ | ||
"type": "node", | ||
"request": "launch", | ||
"name": "启动程序", | ||
"skipFiles": ["<node_internals>/**"], | ||
"program": "${file}" | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
"editor.defaultFormatter": "esbenp.prettier-vscode", | ||
"editor.formatOnSave": true, | ||
"editor.codeActionsOnSave": { | ||
"source.fixAll": true | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
## 描述 | ||
|
||
解决浮动运算问题,避免小数点后产生多位数和计算精度丢失,使得 javascript 能够精确执行加、减、乘、除运算。 | ||
|
||
## 安装 | ||
|
||
```bash | ||
npm i -S @jucttr/number --registry=https://registry.npmjs.org/ | ||
``` | ||
|
||
## 使用 | ||
|
||
## 参考 | ||
|
||
https://github.com/nefe/number-precision |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import { describe, expect, test } from 'vitest' | ||
import { addComma } from '../src/addComma' | ||
|
||
describe('addComma', () => { | ||
test('非数字', () => { | ||
expect(addComma(NaN)).toBe('NaN') | ||
}) | ||
|
||
test('测试正整数', () => { | ||
expect(addComma(5)).toBe('5') | ||
expect(addComma(95)).toBe('95') | ||
expect(addComma(995)).toBe('995') | ||
expect(addComma(1995)).toBe('1,995') | ||
expect(addComma(9945995)).toBe('9,945,995') | ||
expect(addComma(123349945995)).toBe('123,349,945,995') | ||
}) | ||
|
||
test('负正整数', () => { | ||
expect(addComma(-1)).toBe('-1') | ||
expect(addComma(-123)).toBe('-123') | ||
expect(addComma(-1234)).toBe('-1,234') | ||
expect(addComma(-9945995)).toBe('-9,945,995') | ||
}) | ||
|
||
test('小数', () => { | ||
expect(addComma(1.1)).toBe('1.1') | ||
expect(addComma(1.11)).toBe('1.11') | ||
expect(addComma(1.111)).toBe('1.111') | ||
expect(addComma(1.1111)).toBe('1.1111') | ||
expect(addComma(11111.11111)).toBe('11,111.11111') | ||
expect(addComma(1234.11111)).toBe('1,234.11111') | ||
expect(addComma(-12345.11111)).toBe('-12,345.11111') | ||
}) | ||
}) |
Oops, something went wrong.