a-calc 0.0.79 → 1.0.2
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.md +162 -64
- package/browser/index.js +1 -1
- package/calc.d.ts +9 -3
- package/cjs/index.cjs +1 -1
- package/es/index.mjs +1 -1
- package/package.json +73 -73
- package/browser/index.html +0 -149
- package/example/index.html +0 -23
- package/example/index.js +0 -8
package/package.json
CHANGED
|
@@ -1,75 +1,75 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
2
|
+
"name": "a-calc",
|
|
3
|
+
"version": "1.0.2",
|
|
4
|
+
"description": "JavaScript的精准四则运算库,支持复杂运算与格式化操作例如: 带单位计算,千分位, 灵活指定小数点位数,指定舍入规则",
|
|
5
|
+
"main": "./cjs/index.cjs",
|
|
6
|
+
"exports": {
|
|
7
|
+
".": {
|
|
8
|
+
"import": "./es/index.mjs",
|
|
9
|
+
"require": "./cjs/index.cjs"
|
|
10
|
+
},
|
|
11
|
+
"./es": {
|
|
12
|
+
"import": "./es/index.mjs",
|
|
13
|
+
"default": "./es/index.mjs"
|
|
14
|
+
},
|
|
15
|
+
"./cjs": {
|
|
16
|
+
"require": "./cjs/index.cjs",
|
|
17
|
+
"default": "./cjs/index.cjs"
|
|
18
|
+
}
|
|
19
|
+
},
|
|
20
|
+
"browser": "./browser/index.js",
|
|
21
|
+
"module": "./es/index.mjs",
|
|
22
|
+
"types": "./calc.d.ts",
|
|
23
|
+
"typings": "./calc.d.ts",
|
|
24
|
+
"scripts": {
|
|
25
|
+
"dev": "rollup -c --environment build:dev",
|
|
26
|
+
"dev:w": "rollup -c -w --environment build:dev",
|
|
27
|
+
"build": "rollup -c --environment build:build & npm run test",
|
|
28
|
+
"build:w": "rollup -c -w --environment build:build",
|
|
29
|
+
"test": "cross-env ava --verbose --tap test/*.mjs"
|
|
30
|
+
},
|
|
31
|
+
"files": [
|
|
32
|
+
"es",
|
|
33
|
+
"cjs",
|
|
34
|
+
"browser",
|
|
35
|
+
"calc.d.ts"
|
|
36
|
+
],
|
|
37
|
+
"repository": {
|
|
38
|
+
"type": "git",
|
|
39
|
+
"url": "git+https://github.com/Autumn-one/a-calc-old.git"
|
|
40
|
+
},
|
|
41
|
+
"keywords": [
|
|
42
|
+
"四则运算",
|
|
43
|
+
"字符串四则运算",
|
|
44
|
+
"数字格式化",
|
|
45
|
+
"千分位",
|
|
46
|
+
"a-calc"
|
|
47
|
+
],
|
|
48
|
+
"author": "Autumn",
|
|
49
|
+
"license": "MPL-2.0",
|
|
50
|
+
"bugs": {
|
|
51
|
+
"url": "https://github.com/Autumn-one/a-calc-old/issues"
|
|
52
|
+
},
|
|
53
|
+
"homepage": "https://github.com/Autumn-one/a-calc-old#readme",
|
|
54
|
+
"devDependencies": {
|
|
55
|
+
"@babel/core": "^7.17.10",
|
|
56
|
+
"@babel/preset-env": "^7.17.10",
|
|
57
|
+
"@rollup/plugin-babel": "^5.3.1",
|
|
58
|
+
"@rollup/plugin-commonjs": "^22.0.0",
|
|
59
|
+
"@rollup/plugin-json": "^4.1.0",
|
|
60
|
+
"@rollup/plugin-node-resolve": "^13.2.1",
|
|
61
|
+
"ava": "^4.2.0",
|
|
62
|
+
"cross-env": "^7.0.3",
|
|
63
|
+
"glob": "^8.0.1",
|
|
64
|
+
"lodash": "^4.17.21",
|
|
65
|
+
"npm-run-all": "^4.1.5",
|
|
66
|
+
"rollup": "^2.70.2",
|
|
67
|
+
"rollup-plugin-livereload": "^2.0.5",
|
|
68
|
+
"rollup-plugin-serve": "^1.1.0",
|
|
69
|
+
"rollup-plugin-terser": "^7.0.2",
|
|
70
|
+
"rollup-plugin-uglify": "^6.0.4",
|
|
71
|
+
"bignumber.js": "^9.0.2"
|
|
72
|
+
},
|
|
73
|
+
"dependencies": {
|
|
74
|
+
}
|
|
75
75
|
}
|
package/browser/index.html
DELETED
|
@@ -1,149 +0,0 @@
|
|
|
1
|
-
<!DOCTYPE html>
|
|
2
|
-
<html>
|
|
3
|
-
<head>
|
|
4
|
-
<meta charset="UTF-8">
|
|
5
|
-
<title>Title</title>
|
|
6
|
-
</head>
|
|
7
|
-
<body>
|
|
8
|
-
<script src="./index.js"></script>
|
|
9
|
-
<script>
|
|
10
|
-
const { calc, fmt } = a_calc;
|
|
11
|
-
|
|
12
|
-
console.log(calc("-2e2 + 3e+2"))
|
|
13
|
-
|
|
14
|
-
// console.log(fmt("321432328686432.32434324200 | ,"))
|
|
15
|
-
|
|
16
|
-
// console.log(fmt( "1元 | =2", {_debug: true, _unit: true } ))
|
|
17
|
-
|
|
18
|
-
// console.log(calc( "2e+2 + 2 | +=2" ,{_debug: true}))
|
|
19
|
-
|
|
20
|
-
// console.log(calc("0.001 + 0.233 * 6 % 2.2 / 8 - 9",{_debug: true}))
|
|
21
|
-
|
|
22
|
-
// console.log(calc("-8.9 + -2.2 / (8.8 % 2)",{_debug: true}))
|
|
23
|
-
|
|
24
|
-
// console.log(calc("+6.6--8+0.002%8.8",{_debug: true}))
|
|
25
|
-
|
|
26
|
-
// console.log( calc( "(((2.22 + 8.8) + 6) * 3 / 222.88) % (6 - 2)" ) );
|
|
27
|
-
// console.log( calc( "-1.2e+3--8.8++2.2" ) );
|
|
28
|
-
|
|
29
|
-
// console.log(calc("+2.2e3-(8.8e2--2)",{_debug:true}))
|
|
30
|
-
|
|
31
|
-
// console.log( calc( "a * b - c", { _debug: true, a: 1.1, b: 8.2, c: 9 } ) );
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
// console.log(calc("obj.a+cc.b * dd.a", {
|
|
35
|
-
// _debug: true,
|
|
36
|
-
// _fillData: {
|
|
37
|
-
// obj: {
|
|
38
|
-
// a: 0.002
|
|
39
|
-
// },
|
|
40
|
-
// cc: {
|
|
41
|
-
// b: 88
|
|
42
|
-
// },
|
|
43
|
-
// dd: {
|
|
44
|
-
// a: 2.002
|
|
45
|
-
// }
|
|
46
|
-
// }
|
|
47
|
-
// }))
|
|
48
|
-
|
|
49
|
-
// console.log(calc(
|
|
50
|
-
// "arr[0].bb % list[1].c + a.b + 8.8",
|
|
51
|
-
// {
|
|
52
|
-
// _debug: true,
|
|
53
|
-
// _fillData: {
|
|
54
|
-
// arr: [{bb: 88.234}],
|
|
55
|
-
// list:[0,{c: 6.6}],
|
|
56
|
-
// a: {b: 9.228}
|
|
57
|
-
// }
|
|
58
|
-
// }
|
|
59
|
-
// ))
|
|
60
|
-
|
|
61
|
-
// console.log(
|
|
62
|
-
// calc(
|
|
63
|
-
// "a + c + 2e2 / b",
|
|
64
|
-
// {
|
|
65
|
-
// _debug: true,
|
|
66
|
-
// a: "-3.8e2",
|
|
67
|
-
// b: "9.9",
|
|
68
|
-
// c: "+2.34e+3"
|
|
69
|
-
// }
|
|
70
|
-
// )
|
|
71
|
-
// );
|
|
72
|
-
|
|
73
|
-
// console.log(calc("0.233 + 8.226 * 77 / 2 * 888 | ,=2"))
|
|
74
|
-
// console.log(calc("-1.2e+3-8.8",{_debug:true}))
|
|
75
|
-
// console.log(calc("0.233%% + 8.226$$ * 77 / 2 * 888 | ,+=2",{_unit: true, _debug: true}))
|
|
76
|
-
// console.log(fmt( "2.88% | >=3", { _unit: true } ))
|
|
77
|
-
|
|
78
|
-
// console.log(fmt("-3.4455644654665445e+26 | >=0",{_debug: true}))
|
|
79
|
-
// console.log(fmt("-3.4455644654665445e+26 | >=0"))
|
|
80
|
-
|
|
81
|
-
// console.log(fmt("-2.12345678123e+8 | ,",{_unit: true}))
|
|
82
|
-
// console.log(fmt("-1 | +"))
|
|
83
|
-
// console.log(calc("2e2 * 2",{_debug: true}))
|
|
84
|
-
// console.log(fmt("num | ,+<=8",{num: 12454353443.432432}))
|
|
85
|
-
|
|
86
|
-
// console.log(calc("223.32432e+22ee + 0.2",{_debug: true,_unit: true}))
|
|
87
|
-
// console.log(fmt("2e2ff | =2",{_debug: true,_unit: true}))
|
|
88
|
-
// console.log(calc("3.24232342e-11 * 8",{_debug: true}))
|
|
89
|
-
// console.log(fmt("a.b | >=8", {a:{b:1.001}}))
|
|
90
|
-
|
|
91
|
-
// console.log(calc("2e2 * 2",{_debug: true}))
|
|
92
|
-
|
|
93
|
-
// console.log(0.0000000000324232342)
|
|
94
|
-
|
|
95
|
-
// console.log(fmt("07987987789.23442231元 | , +=2",{_unit: true}))
|
|
96
|
-
// console.log(
|
|
97
|
-
// fmt("1 + 1",{_fmt:",>=4", _error:"-"})
|
|
98
|
-
// );
|
|
99
|
-
|
|
100
|
-
// console.log(
|
|
101
|
-
// calc("a + b - c * 12131312 | =2,(-)", [
|
|
102
|
-
// { a: 1 },
|
|
103
|
-
// { b: 2, c: 3 }
|
|
104
|
-
// ])
|
|
105
|
-
// );
|
|
106
|
-
|
|
107
|
-
// console.log(calc("1 + 2.2 + 3.3| , esdfds.",{_error: "-",_fmt: "=", esdfds: {
|
|
108
|
-
// dew: 10,
|
|
109
|
-
// }}))
|
|
110
|
-
|
|
111
|
-
// console.log(calc("a + 234% | +,=8",{a: "1.010", _unit:true}))
|
|
112
|
-
// console.log(fmt("10.00% | <=3", {_unit: true}))
|
|
113
|
-
//
|
|
114
|
-
// console.log(calc("2123ddf - +2 | =n",{n: 5,_unit: true}))
|
|
115
|
-
|
|
116
|
-
// console.log(fmt("a | =n",{a: "-1.10%",n:3, _unit: true}))
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
// console.log(fmt("a | +,>=n",{a: "+10000.100%",n:5, _unit: true}))
|
|
120
|
-
|
|
121
|
-
// console.log(calc("0.0012 + +2 * 2 - 100% | +,=4",{_unit: true, _debug: true}))
|
|
122
|
-
|
|
123
|
-
// console.log(calc("12321.21321 * (a * 232%) - 10000000% | +, <=4", {_unit: true, a: 3.33}))
|
|
124
|
-
|
|
125
|
-
// console.log(calc("+23.232400 | <=8",{a: 1232423.23432}))
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
// console.log(calc("1 + o.a / arr[0].d",{
|
|
129
|
-
// o: { a: 2 },
|
|
130
|
-
// arr: [{ d: 8 }]
|
|
131
|
-
// }))
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
// console.log(calc("1 + 1 | +"))
|
|
135
|
-
|
|
136
|
-
// console.log(calc("10000000 + 100000000 | +,=10"))
|
|
137
|
-
|
|
138
|
-
// console.log(calc("1.123$$$ + 2.88% | + =6", {_unit: true}))
|
|
139
|
-
|
|
140
|
-
// console.log(calc("1 + 2sd + d", {
|
|
141
|
-
// d: 8,
|
|
142
|
-
// _error: "-"
|
|
143
|
-
// }))
|
|
144
|
-
//
|
|
145
|
-
// console.log(calc("111111 + 11111 | ,",{_fmt: "=2"}))
|
|
146
|
-
|
|
147
|
-
</script>
|
|
148
|
-
</body>
|
|
149
|
-
</html>
|
package/example/index.html
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
<!DOCTYPE html>
|
|
2
|
-
<html lang="en">
|
|
3
|
-
<head>
|
|
4
|
-
<meta charset="UTF-8">
|
|
5
|
-
<title>Title</title>
|
|
6
|
-
<style>
|
|
7
|
-
* {
|
|
8
|
-
margin: 0;
|
|
9
|
-
padding: 0;
|
|
10
|
-
}
|
|
11
|
-
</style>
|
|
12
|
-
</head>
|
|
13
|
-
<body>
|
|
14
|
-
|
|
15
|
-
<!--<script src="./decimal.js.js"></script>-->
|
|
16
|
-
<script src="../browser/index.js"></script>
|
|
17
|
-
|
|
18
|
-
<script>
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
</script>
|
|
22
|
-
</body>
|
|
23
|
-
</html>
|
package/example/index.js
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { tokenizer } from "../src/tokenizer.js";
|
|
2
|
-
import { token2postfix } from "../src/postfixExpr.js";
|
|
3
|
-
|
|
4
|
-
let t1 = tokenizer("-1 - (-22321 * 3)");
|
|
5
|
-
let t2 = tokenizer("1123 - (0.322 + -33.3) % 66");
|
|
6
|
-
let t3 = tokenizer("+0.888-22*(66--3.33)");
|
|
7
|
-
|
|
8
|
-
console.log(token2postfix(t2))
|