Skip to content

Commit 31c6985

Browse files
committed
feat: 使用 bignumber.js 替换 big.js
1 parent 80c9344 commit 31c6985

File tree

3 files changed

+12
-18
lines changed

3 files changed

+12
-18
lines changed

package.json

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "decimal-eval",
33
"description": "A tiny, safe, fast JavaScript library for decimal arithmetic expressions.",
4-
"version": "0.1.0",
4+
"version": "0.1.1-beta.0",
55
"main": "index.js",
66
"module": "dist/index.esm.js",
77
"types": "dist/index.d.ts",
@@ -81,7 +81,7 @@
8181
},
8282
"dependencies": {
8383
"@babel/runtime": "^7.14.0",
84-
"big.js": "^6.1.1"
84+
"bignumber.js": "^9.0.1"
8585
},
8686
"devDependencies": {
8787
"@babel/core": "^7.14.3",
@@ -96,7 +96,6 @@
9696
"@rollup/plugin-node-resolve": "^13.0.0",
9797
"@rollup/plugin-replace": "^2.4.2",
9898
"@rollup/plugin-typescript": "^8.2.1",
99-
"@types/big.js": "^6.0.2",
10099
"@types/jest": "^26.0.23",
101100
"@typescript-eslint/eslint-plugin": "^4.24.0",
102101
"@typescript-eslint/parser": "^4.24.0",

src/index.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import Big from 'big.js';
1+
import BigNumber from 'bignumber.js';
22
import DecimalEval, {Parser} from './pure';
33
import {IAdapter} from './transform';
44

@@ -7,16 +7,16 @@ import {IAdapter} from './transform';
77
*/
88
const bigJSAdapter: Readonly<IAdapter> = {
99
'+': (left, right) => {
10-
return new Big(left).plus(right).toString();
10+
return new BigNumber(left).plus(right).toString();
1111
},
1212
'-': (left, right) => {
13-
return new Big(left).minus(right).toString();
13+
return new BigNumber(left).minus(right).toString();
1414
},
1515
'*': (left, right) => {
16-
return new Big(left).times(right).toString();
16+
return new BigNumber(left).times(right).toString();
1717
},
1818
'/': (left, right) => {
19-
return new Big(left).div(right).toString();
19+
return new BigNumber(left).div(right).toString();
2020
}
2121
};
2222

@@ -26,5 +26,5 @@ Parser.useAdapter(bigJSAdapter);
2626
export default DecimalEval;
2727
export * from './pure';
2828
export {
29-
Big
29+
BigNumber
3030
};

yarn.lock

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1354,11 +1354,6 @@
13541354
dependencies:
13551355
"@babel/types" "^7.3.0"
13561356

1357-
"@types/big.js@^6.0.2":
1358-
version "6.0.2"
1359-
resolved "https://registry.nlark.com/@types/big.js/download/@types/big.js-6.0.2.tgz#a86938c1bb4511e69d91f69823cacc3f48ff1fa3"
1360-
integrity sha1-qGk4wbtFEeadkfaYI8rMP0j/H6M=
1361-
13621357
"@types/estree@*":
13631358
version "0.0.47"
13641359
resolved "https://registry.nlark.com/@types/estree/download/@types/estree-0.0.47.tgz?cache=0&sync_timestamp=1621240967551&other_urls=https%3A%2F%2Fregistry.nlark.com%2F%40types%2Festree%2Fdownload%2F%40types%2Festree-0.0.47.tgz#d7a51db20f0650efec24cd04994f523d93172ed4"
@@ -1831,10 +1826,10 @@ bcrypt-pbkdf@^1.0.0:
18311826
dependencies:
18321827
tweetnacl "^0.14.3"
18331828

1834-
big.js@^6.1.1:
1835-
version "6.1.1"
1836-
resolved "https://registry.nlark.com/big.js/download/big.js-6.1.1.tgz?cache=0&sync_timestamp=1620132748267&other_urls=https%3A%2F%2Fregistry.nlark.com%2Fbig.js%2Fdownload%2Fbig.js-6.1.1.tgz#63b35b19dc9775c94991ee5db7694880655d5537"
1837-
integrity sha1-Y7NbGdyXdclJke5dt2lIgGVdVTc=
1829+
bignumber.js@^9.0.1:
1830+
version "9.0.1"
1831+
resolved "https://registry.npm.taobao.org/bignumber.js/download/bignumber.js-9.0.1.tgz#8d7ba124c882bfd8e43260c67475518d0689e4e5"
1832+
integrity sha1-jXuhJMiCv9jkMmDGdHVRjQaJ5OU=
18381833

18391834
bl@^4.1.0:
18401835
version "4.1.0"

0 commit comments

Comments
 (0)