a-calc 3.0.0-beta.20260105 → 3.0.0-beta.20260124.1
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 +83 -379
- package/a-calc.versions.js +56 -52
- package/browser/index.js +4 -2
- package/calc.d.ts +163 -22
- package/cjs/index.js +4 -2
- package/es/index.js +4 -2
- package/mcp-server/README.md +204 -0
- package/mcp-server/package.json +26 -0
- package/mcp-server/src/index.js +1360 -0
- package/package.json +20 -9
package/README.md
CHANGED
|
@@ -1,422 +1,126 @@
|
|
|
1
1
|
# a-calc
|
|
2
|
-
[](https://www.npmjs.com/package/a-calc) [](https://github.com/Autumn-one/a-calc-old) [](https://github.com/Autumn-one/a-calc-old) [](https://github.com/Autumn-one/a-calc-old) [](https://www.npmjs.com/package/a-calc)
|
|
3
2
|
|
|
4
|
-
|
|
3
|
+
[](https://www.npmjs.com/package/a-calc) [](https://www.npmjs.com/package/a-calc)
|
|
5
4
|
|
|
6
|
-
|
|
5
|
+
强大易用的 JavaScript 精度计算与格式化库。
|
|
7
6
|
|
|
8
|
-
|
|
7
|
+
## 特性
|
|
9
8
|
|
|
10
|
-
|
|
9
|
+
- **精确计算** - 解决 JavaScript 浮点数精度问题
|
|
10
|
+
- **强大格式化** - 千分位、百分比、分数、科学计数法
|
|
11
|
+
- **单位计算** - 支持带单位的数字运算
|
|
12
|
+
- **完整舍入** - 去尾、进一、四舍五入、四舍六入
|
|
13
|
+
- **高性能** - 同类库中最快
|
|
14
|
+
- **TypeScript** - 完整类型支持
|
|
11
15
|
|
|
12
|
-
|
|
16
|
+
## 安装
|
|
13
17
|
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
> Supported operators : + - * / % ** //
|
|
17
|
-
|
|
18
|
-
**Document language:** English | [简体中文](https://github.com/Autumn-one/a-calc-old/blob/main/README_ZH.md)
|
|
19
|
-
|
|
20
|
-
## Installation
|
|
21
|
-
|
|
22
|
-
```
|
|
18
|
+
```bash
|
|
23
19
|
npm install a-calc
|
|
24
20
|
```
|
|
25
21
|
|
|
26
|
-
##
|
|
27
|
-
|
|
28
|
-
**commonjs**
|
|
29
|
-
|
|
30
|
-
```js
|
|
31
|
-
const {calc, fmt} = require("a-calc")
|
|
32
|
-
// or
|
|
33
|
-
const {calc, fmt} = require("a-calc/cjs")
|
|
34
|
-
```
|
|
35
|
-
|
|
36
|
-
**es module**
|
|
37
|
-
|
|
38
|
-
```js
|
|
39
|
-
import {calc, fmt} from "a-calc"
|
|
40
|
-
// or
|
|
41
|
-
const {calc, fmt} from "a-calc/es"
|
|
42
|
-
```
|
|
43
|
-
|
|
44
|
-
**Browser side**
|
|
45
|
-
|
|
46
|
-
```html
|
|
47
|
-
<script src="https://unpkg.com/a-calc@latest/browser/index.js"></script> <!-- cdn -->
|
|
48
|
-
<script src="node_modules/a-calc/browser/index.js"></script> <!-- After installing npm, you can also import it locally. Choose either option. -->
|
|
49
|
-
<script>
|
|
50
|
-
const {calc, fmt} = a_calc
|
|
51
|
-
</script>
|
|
52
|
-
```
|
|
53
|
-
|
|
54
|
-
## Get Started
|
|
55
|
-
|
|
56
|
-
```typescript
|
|
57
|
-
calc("0.1 + 0.2") // "0.3"
|
|
58
|
-
|
|
59
|
-
// A more complex calculation
|
|
60
|
-
calc("0.1 + 0.2 * 0.3 / 0.4 * (0.5 + 0.6)") // "0.265"
|
|
61
|
-
|
|
62
|
-
// Scientific notation calculation
|
|
63
|
-
calc("-2e2 + 3e+2") // "100"
|
|
64
|
-
|
|
65
|
-
// Calculations with units
|
|
66
|
-
calc("0.1% + 0.2%", {_unit: true}) // "0.3%"
|
|
67
|
-
|
|
68
|
-
// Variable operation
|
|
69
|
-
calc("(a * (b + c))", {a: 1, b: 2, c: 3}) // "5"
|
|
70
|
-
calc("(a * (b + c))", [{a: 1, b: 2}, {c: 3}]) // "5"
|
|
71
|
-
calc("a + b", {a: "2$", b: "4$", _unit: true}) // "6$"
|
|
72
|
-
calc("a + b", {_fill_data: [{a: "2$"}, {b: "4$"}], _unit: true}) // "6$"
|
|
73
|
-
|
|
74
|
-
// Calculate and format: Thousands separator
|
|
75
|
-
calc("a + b | ,", {a:324232421123, b: 234234242422321}) // "234,558,474,843,444"
|
|
76
|
-
// Calculate and format: fractions
|
|
77
|
-
calc("2 * 3 | /") // "6/1"
|
|
78
|
-
// Calculate and format: output numbers.
|
|
79
|
-
calc("1 + 1 | !n") // 2
|
|
80
|
-
```
|
|
81
|
-
|
|
82
|
-
## About the space
|
|
83
|
-
|
|
84
|
-
By default, spaces in expressions are not required, unless you use the space or space-all mode, which are introduced in later chapters. However, I recommend that you always include spaces in expressions, which look clearer and nicer.
|
|
85
|
-
|
|
86
|
-
## Fill in variables and calculate (important)
|
|
87
|
-
|
|
88
|
-
```js
|
|
89
|
-
let a = 0.000001
|
|
90
|
-
let b = 888.789
|
|
91
|
-
calc("a + b", {a,b}) // "888.789001"
|
|
92
|
-
|
|
93
|
-
calc("a * (b + c) % d + 7.123", [
|
|
94
|
-
{a: 1, b: 2},
|
|
95
|
-
{c: 3, d: 4}
|
|
96
|
-
]) // "8.123"
|
|
97
|
-
|
|
98
|
-
// A bit more complex
|
|
99
|
-
calc("1 + o.a / arr[0].d",{
|
|
100
|
-
o: { a: 2 },
|
|
101
|
-
arr: [{ d: 8 }]
|
|
102
|
-
}) // "1.25"
|
|
103
|
-
|
|
104
|
-
calc("a + b - c",[
|
|
105
|
-
{a: 1},
|
|
106
|
-
{b: 2, c: 3}
|
|
107
|
-
]) // "0"
|
|
108
|
-
```
|
|
109
|
-
|
|
110
|
-
## Calculation with units
|
|
111
|
-
|
|
112
|
-
> The actual situation is not always ideal, maybe we have to calculate two percentage numbers. Fortunately, a-calc now supports these operations, but please note that the unit will be taken from the first number carrying a unit, and the units later will be ignored.
|
|
113
|
-
|
|
114
|
-
```js
|
|
115
|
-
// Please note that _unit is required and not enabled by default. This is because calculations with units will perform some additional operations, and in contrast, pure numerical calculations are faster.
|
|
116
|
-
calc("1 + 2%", {_unit: true}) // "3%"
|
|
117
|
-
|
|
118
|
-
calc("1.123$$$ + 2.88% | + =6", {_unit: true}) // "+4.003000$$$"
|
|
119
|
-
|
|
120
|
-
// Starting from a-calc@2.0.0, the array form of filling data can also be configured. You can use the configuration object as the first or the last parameter of the array. These are the only two positions that are supported.
|
|
121
|
-
calc("a + b", [{a: "1%", b: "2%"}, {_unit: true}]) // "3%"
|
|
122
|
-
```
|
|
123
|
-
|
|
124
|
-
In actual development, you may hope that the final result does not automatically carry units. In versions after 1.3.6, you can remove units from the result through the formatting parameter `!u`, or you can directly output the number with `!n`.
|
|
125
|
-
|
|
126
|
-
## Calculate and format
|
|
127
|
-
|
|
128
|
-
Formatting supports the following functions: limiting the number of decimal places, preserving positive and negative signs, outputting as a percentage, outputting in scientific notation, outputting, and they can be combined. However, there are some situations where combinations do not work. You can try it yourself, there are too many combination situations, and I won't list them all.
|
|
129
|
-
|
|
130
|
-
**Formatting list:**
|
|
131
|
-
|
|
132
|
-
- `>or>=or<or<=or=number` means to limit the number of decimal places, for example: `<=2` means the number of decimal places should be less than or equal to 2 `>3` means the number of decimal places must be greater than 3, this is equivalent to `>=4`
|
|
133
|
-
- `,` Output as a thousandth place numeric string
|
|
134
|
-
- `/` Output as a fraction
|
|
135
|
-
- `+` The output positive numbers are marked with a `+` sign
|
|
136
|
-
- `%` Output percentage numbers, which can be combined with the option to limit the number of decimals.
|
|
137
|
-
- `!e` Output in scientific notation, e can be capitalized
|
|
138
|
-
- `!n` Output as a number, not a numeric string, n can be capitalized. After version 1.3.6, this has the highest priority, and any other formatting parameters cannot affect this parameter.
|
|
139
|
-
- `!u` Remove units from the result
|
|
140
|
-
|
|
141
|
-
```js
|
|
142
|
-
// Operate the decimal places
|
|
143
|
-
calc("0.1 + 0.2 | =2") // "0.30"
|
|
144
|
-
calc("0.11111 + 0.11111 | <=4") // "0.2222"
|
|
145
|
-
calc("0.11 + 0.11 | <=4") // "0.22"
|
|
146
|
-
calc("0.1 + 0.2 | >= 5") // "0.30000"
|
|
147
|
-
calc("0.0000001+ 0.0000001 | >= 5") // "0.0000002"
|
|
148
|
-
|
|
149
|
-
// Preserve positive and negative signs
|
|
150
|
-
calc("1 + 1 | +") // "+2"
|
|
151
|
-
|
|
152
|
-
// Thousandth place
|
|
153
|
-
calc("10000000 + 100000000 | ,") // "110,000,000"
|
|
22
|
+
## 快速开始
|
|
154
23
|
|
|
155
|
-
|
|
156
|
-
|
|
24
|
+
```javascript
|
|
25
|
+
import { calc, fmt } from "a-calc";
|
|
157
26
|
|
|
158
|
-
//
|
|
159
|
-
calc("1 +
|
|
27
|
+
// 精确计算
|
|
28
|
+
calc("0.1 + 0.2"); // "0.3"
|
|
160
29
|
|
|
161
|
-
//
|
|
162
|
-
calc("1 +
|
|
30
|
+
// 复杂表达式
|
|
31
|
+
calc("0.1 + 0.2 * 0.3 / 0.4 * (0.5 + 0.6)"); // "0.265"
|
|
163
32
|
|
|
164
|
-
//
|
|
165
|
-
calc("
|
|
166
|
-
```
|
|
167
|
-
|
|
168
|
-
## Four kinds of rounding rules
|
|
169
|
-
|
|
170
|
-
The rounding rules are added to the part of the formatting string, and their symbols are:
|
|
33
|
+
// 变量计算
|
|
34
|
+
calc("a + b", { a: 1, b: 2 }); // "3"
|
|
171
35
|
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
- `~5` Rounding
|
|
175
|
-
- `~6` Round to Even, this rounding rule is more accurate than the normal rounding. The rule is different when the number after the rounding is 5. It will check the position after 5. If the number after 5 is not 0, it will increment. If the number after 5 is 0, it will check whether the number before 5 is even or not. If it is even, it will not increment. If it is not even, it will increment.
|
|
36
|
+
// 格式化
|
|
37
|
+
fmt("1000000 | ,"); // "1,000,000"
|
|
176
38
|
|
|
177
|
-
|
|
178
|
-
calc("
|
|
179
|
-
calc("0.55 | =1 ~5") // "0.6"
|
|
180
|
-
calc("0.65 | =1 ~6") // "0.6"
|
|
39
|
+
// 计算并格式化
|
|
40
|
+
calc("111111 + 11111 | ,=2"); // "122,222.00"
|
|
181
41
|
```
|
|
182
42
|
|
|
183
|
-
|
|
43
|
+
## 核心 API
|
|
184
44
|
|
|
185
|
-
|
|
45
|
+
### calc(expr, data?)
|
|
186
46
|
|
|
187
|
-
|
|
188
|
-
calc("0.1 | =2") // "0.10"
|
|
189
|
-
fmt("0.1 | =2") // "0.10"
|
|
190
|
-
// calc has the function of fmt, but fmt has better semantics
|
|
47
|
+
计算表达式,支持变量和格式化。
|
|
191
48
|
|
|
192
|
-
|
|
49
|
+
```javascript
|
|
50
|
+
calc("a * b + c", { a: 1, b: 2, c: 3 }); // "5"
|
|
51
|
+
calc("100 + 200 | ,"); // "300"
|
|
52
|
+
calc("0.1% + 0.2%", { _unit: true }); // "0.3%"
|
|
193
53
|
```
|
|
194
54
|
|
|
195
|
-
|
|
55
|
+
### fmt(value)
|
|
196
56
|
|
|
197
|
-
|
|
57
|
+
格式化数字。
|
|
198
58
|
|
|
199
|
-
```
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
59
|
+
```javascript
|
|
60
|
+
fmt("1234567 | ,"); // "1,234,567"
|
|
61
|
+
fmt("0.12345 | =2"); // "0.12"
|
|
62
|
+
fmt("0.5 | %"); // "50%"
|
|
203
63
|
```
|
|
204
64
|
|
|
205
|
-
|
|
65
|
+
### 格式化参数
|
|
206
66
|
|
|
207
|
-
|
|
67
|
+
| 参数 | 说明 | 示例 |
|
|
68
|
+
| ----- | ------------- | ---------------- |
|
|
69
|
+
| `=N` | 固定 N 位小数 | `=2` → "1.00" |
|
|
70
|
+
| `<=N` | 最多 N 位小数 | `<=2` → "1.1" |
|
|
71
|
+
| `>=N` | 最少 N 位小数 | `>=2` → "1.00" |
|
|
72
|
+
| `,` | 千分位 | `1000` → "1,000" |
|
|
73
|
+
| `+` | 保留正号 | `1` → "+1" |
|
|
74
|
+
| `%` | 百分比 | `0.5` → "50%" |
|
|
75
|
+
| `/` | 分数 | `0.5` → "1/2" |
|
|
76
|
+
| `!e` | 科学计数法 | `1000` → "1e+3" |
|
|
77
|
+
| `!n` | 输出数字类型 | 返回 number |
|
|
78
|
+
| `!u` | 去除单位 | "100%" → "100" |
|
|
208
79
|
|
|
209
|
-
|
|
80
|
+
### 舍入规则
|
|
210
81
|
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
82
|
+
| 参数 | 说明 |
|
|
83
|
+
| ---- | ---------------------- |
|
|
84
|
+
| `~-` | 去尾(默认) |
|
|
85
|
+
| `~+` | 进一 |
|
|
86
|
+
| `~5` | 四舍五入 |
|
|
87
|
+
| `~6` | 四舍六入(银行家舍入) |
|
|
216
88
|
|
|
217
|
-
|
|
218
|
-
calc("1
|
|
219
|
-
|
|
220
|
-
_error: "-"
|
|
221
|
-
}) // This simplification is purely for convenience.
|
|
89
|
+
```javascript
|
|
90
|
+
calc("0.55 | =1 ~5"); // "0.6"
|
|
91
|
+
calc("0.65 | =1 ~6"); // "0.6"
|
|
222
92
|
```
|
|
223
93
|
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
> In actual projects, you can optimize the development experience through default formatting.
|
|
227
|
-
|
|
228
|
-
```js
|
|
229
|
-
calc("111111 + 11111 | ,",{_fmt: "=2"}) // "122,222.00" Obviously , and =2 are combined, and the format string in the expression has a higher priority.
|
|
230
|
-
```
|
|
231
|
-
|
|
232
|
-
## How to encapsulate for the second time in the project?
|
|
233
|
-
|
|
234
|
-
In actual projects, the core calc function may not be extremely convenient. Therefore, `a-calc` provides a built-in function `calc_wrap` for secondary encapsulation after version 1.2.10. Essentially, it is an extension of calc, so it has all the former's capabilities but with more flexible writing methods and powerful type inference.
|
|
235
|
-
|
|
236
|
-
Please note that this may not be the only correct way to encapsulate. I just provided this feature. There is no dogma here. You should adapt flexibly to your own scenarios.
|
|
94
|
+
## 性能对比
|
|
237
95
|
|
|
238
|
-
|
|
96
|
+
| 库 | 50,000 次 | 500,000 次 |
|
|
97
|
+
| ------------------------- | --------- | ---------- |
|
|
98
|
+
| **a-calc** | 423ms | 3650ms |
|
|
99
|
+
| mathjs@13.0.2 | 610ms | 5724ms |
|
|
100
|
+
| math-expression-evaluator | 701ms | 6764ms |
|
|
101
|
+
| mathjs@12.4.3 | 3791ms | 36948ms |
|
|
239
102
|
|
|
240
|
-
|
|
241
|
-
// Note that here we rename calc_wrap as calc, because if you need to use the calc_wrap function, the core calc function is basically not needed, so if this good name is idle, it should be used.
|
|
242
|
-
import { calc_wrap as calc } from "a-calc";
|
|
103
|
+
## 文档
|
|
243
104
|
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
c: 3
|
|
248
|
-
};
|
|
105
|
+
- [快速开始](./.docs/QUICK_START.md)
|
|
106
|
+
- [完整文档索引](./.docs/README.md)
|
|
107
|
+
- [贡献指南](./.docs/CONTRIBUTING.md)
|
|
249
108
|
|
|
250
|
-
|
|
251
|
-
calc( "(1 + 2) * 3" ); // Return type: string
|
|
109
|
+
## 开发
|
|
252
110
|
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
calc( state ); // Return type: ( expr: string | number ) => string
|
|
259
|
-
calc( state )( "(a + b) * c" ); // Return type: string
|
|
260
|
-
|
|
261
|
-
// The original usage is naturally also supported.
|
|
262
|
-
calc( "a + b + c", state ); // Return type: string
|
|
263
|
-
|
|
264
|
-
// You can still mix configuration and data sources together, which is very convenient.
|
|
265
|
-
calc( "a + b + c" )( { ...state, _error: 0 } ); // Return type: string | 0
|
|
111
|
+
```bash
|
|
112
|
+
pnpm install # 安装依赖
|
|
113
|
+
pnpm dev # 开发模式
|
|
114
|
+
pnpm build # 构建
|
|
115
|
+
pnpm test # 测试
|
|
266
116
|
```
|
|
267
117
|
|
|
268
|
-
|
|
118
|
+
## 许可证
|
|
269
119
|
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
```typescript
|
|
273
|
-
calc(`${a} + ${b}`) // This way of writing is not recommended.
|
|
274
|
-
calc("a + b", {a,b}) // Recommended writing, because it is clearer.
|
|
275
|
-
```
|
|
120
|
+
[MIT](./LICENSE)
|
|
276
121
|
|
|
277
|
-
##
|
|
278
|
-
|
|
279
|
-
The two modes of space and space-ALL put forward higher requirements for code writing. space mode requires strict insertion of Spaces between each unit of the calculation part. Space-all not only requires strict insertion of Spaces in the calculation part but also requires insertion of Spaces in the fmt formatting part. Almost the most important effect of this feature is disambiguation, and the second is that it can improve performance slightly.
|
|
280
|
-
|
|
281
|
-
```typescript
|
|
282
|
-
calc("1+1", {_mode: "space"}) // This formulation cannot be calculated because of the lack of Spaces
|
|
283
|
-
calc("1 + 1", {_mode: "space"}) // This is written correctly
|
|
284
|
-
calc("1 + (2 * 3)", {_mode: "space"}) // This is also correct, because of the special treatment of parentheses, which can be next to internal numbers or variable names or separated by Spaces
|
|
285
|
-
|
|
286
|
-
calc("1 + ( 2 * 3 ) | =2 ,", {_mode: "space-all"}) // space is also required between =2 and, after using the space-all mode, there must be at least one space between each formatting unit, and the space can be more than less.
|
|
287
|
-
```
|
|
288
|
-
|
|
289
|
-
## Original method
|
|
290
|
-
|
|
291
|
-
You can also use plus sub mul div and other methods to calculate, although the main problem that a-calc solves is that such methods are not intuitive to write the problem, but if you only have two operands and do not need any formatting then using these methods can bring some performance improvement
|
|
292
|
-
|
|
293
|
-
```typescript
|
|
294
|
-
import {plus, sub, mul, div, mod, pow, idiv} from "a-calc"
|
|
295
|
-
plus(1, 1) // 2
|
|
296
|
-
plus(1, 1, "string") // "2"
|
|
297
|
-
```
|
|
298
|
-
|
|
299
|
-
## Aggregation Methods
|
|
300
|
-
|
|
301
|
-
Sometimes we may need to apply the same calculation to multiple data sources and ultimately aggregate all the results. This can be achieved in one step using calc_sum to obtain the results.
|
|
302
|
-
|
|
303
|
-
```typescript
|
|
304
|
-
calc_sum("a + b | =2", [{a: 1,b: 2 }, {a: 3, b:4}]) // "10.00"
|
|
305
|
-
```
|
|
122
|
+
## 链接
|
|
306
123
|
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
| | `a-calc@2.2.10` | `mathjs@12.4.3` | `mathjs@13.0.2` | `math-expression-evaluator@2.0.4` |
|
|
312
|
-
| -------------------------------- | --------------- | --------------- | --------------- | --------------------------------- |
|
|
313
|
-
| 50,000 calculations runtime(ms) | 423 | 3791 | 610 | 701 |
|
|
314
|
-
| 500,000 calculations runtime(ms) | 3650 | 36948 | 5724 | 6764 |
|
|
315
|
-
|
|
316
|
-
## Version changes
|
|
317
|
-
|
|
318
|
-
* 2.2.15
|
|
319
|
-
- The calc_sum method is provided, which is an aggregation method, similar to: `options_arr.reduce((memo, data) => calc("expr + memo", {expr, memo, _fill_data: data}), 0)`
|
|
320
|
-
* 2.2.7
|
|
321
|
-
|
|
322
|
-
- Enhanced documentation will prompt your IDE to display explanations and usage examples for each function as you write them.
|
|
323
|
-
* 2.1.0
|
|
324
|
-
|
|
325
|
-
- Destructive changes: All memo methods have been removed because the memo method brings more code. However, after multi-scenario testing, it can only bring significant performance improvement in specific scenarios. In some business scenarios, it hardly brings performance improvement because the parser performance is high enough. The running time of cache logic often cancels out the parsing time saved, so the overall benefit is too low.
|
|
326
|
-
* 2.0.0
|
|
327
|
-
|
|
328
|
-
- Destructive change: The \_unit parameter now only supports boolean type, the previous space value has been moved to the \_mode parameter.
|
|
329
|
-
- Destructive change: Previously, the letter case of some formatted sections could be mixed, but now it must be all lowercase. For example, "!u" cannot be written as "!U".
|
|
330
|
-
- Significant performance improvement, it is now the fastest among similar libraries.
|
|
331
|
-
- Expose high-performance function methods, for simple arithmetic expressions you can opt to use straightforward functions for invocation, such as: `plus(1, 1)`
|
|
332
|
-
- Added the configuration for the \_mode mode.
|
|
333
|
-
- Now it is also possible to configure when the second parameter is an array.
|
|
334
|
-
- Exposed primitive methods such as plus, subtract, multiply, divide, modulo, power, integer division and their corresponding memo versions.
|
|
335
|
-
- Added support for the `//` floor division operator.
|
|
336
|
-
- `**` to right-bound to be consistent with the native JS language rules
|
|
337
|
-
* 1.3.9 Solved the problem of failed rounding due to the part of the injection variable in formatting being 0 (Problem reporter: MangMax)
|
|
338
|
-
* 1.3.8 Solved the packaging failure problem caused by the upgrade of vite5.x (Problem reporter: 武建鹏)
|
|
339
|
-
* 1.3.6
|
|
340
|
-
- The priority of the `!n` formatting parameter has been adjusted to the highest, and no other formatting parameters can affect it.
|
|
341
|
-
- Added `!u` formatting parameter, which can remove the unit part from the result.
|
|
342
|
-
- Type hint enhancement
|
|
343
|
-
* 1.3.4
|
|
344
|
-
- Fixed the bug of rounding error between rounding off and rounding to nearest even number (bug provider: nanarino)
|
|
345
|
-
* 1.3.0
|
|
346
|
-
- BREAKING CHANGE: Adjust the invocation method of printing version and checking update function
|
|
347
|
-
- Refine Type Hints
|
|
348
|
-
- Add more unit tests.
|
|
349
|
-
* 1.2.30
|
|
350
|
-
- The previous version printed version numbers by default, now it is configurable and disabled by default
|
|
351
|
-
- It provides an update detection function. Once enabled, the console will give a hint if there is a new version.
|
|
352
|
-
* 1.2.10
|
|
353
|
-
- Remove the Vue integration example. The library itself is not bound to any specific frontend framework, in order to avoid misunderstandings, delete the corresponding integration code.
|
|
354
|
-
- Add the functionality of `calc_wrap`, which is a secondary wrapper for the core function `calc` and can be used directly.
|
|
355
|
-
* 1.2.6
|
|
356
|
-
- Adjust the integrated code of vue3. Since the component instances of vue3 are different in the development environment and the production environment, the production environment cannot obtain the state, but the development environment can.
|
|
357
|
-
* 1.2.0
|
|
358
|
-
- A minor disruptive update, where the previous `-e` and `-n` have been changed to `!e` and `!n`, respectively.
|
|
359
|
-
- Document Update
|
|
360
|
-
* 1.1.0
|
|
361
|
-
- Small breaking change, the previous `\e` scientific counting output is now `-e`, others did not change
|
|
362
|
-
- Added `-n` to output the number type
|
|
363
|
-
- The limitation on decimal places is supported by the `<` and `>` symbols.
|
|
364
|
-
- Fixed several rounding formatting issues.
|
|
365
|
-
- The unit tests have increased to 107.
|
|
366
|
-
* 1.0.25
|
|
367
|
-
- Update the document to simplify the integration of a-calc into Vue3.
|
|
368
|
-
* 1.0.23
|
|
369
|
-
- Update the document and rewrite the recommended way to integrate a-calc into Vue3.
|
|
370
|
-
* 1.0.22
|
|
371
|
-
- Optimize decimal rounding logic.
|
|
372
|
-
* 1.0.21
|
|
373
|
-
- Refine the exported type definitions.
|
|
374
|
-
* 1.0.19
|
|
375
|
-
- Fix the issue where errors may not be captured when _error is an empty string.
|
|
376
|
-
* 1.0.14
|
|
377
|
-
- Fix the issue of `**` operator precedence error.
|
|
378
|
-
- Fix the issue of extra zeros not being removed when formatting with `<=`.
|
|
379
|
-
* 1.0.12
|
|
380
|
-
- Document adding library volume description
|
|
381
|
-
- Fix the issue where adding the _error parameter when the expression is empty still causes an error, and include corresponding unit tests.
|
|
382
|
-
* 1.0.10
|
|
383
|
-
- Update document
|
|
384
|
-
* 1.0.6
|
|
385
|
-
* Destructive change: all exposed camelCase naming has been converted to snake_case, for example, `_fillData` is now `_fill_data`, as snake_case naming is clearer.
|
|
386
|
-
* The internal code has been greatly simplified, the parser has been almost completely rewritten, resulting in a more stable user experience.
|
|
387
|
-
* The original design was for the calc function to have all the functionalities of fmt. However, in versions prior to 1.0.6, although they adhered to this design, calc and fmt were implemented separately. Now fmt is simply an alias for calc.
|
|
388
|
-
* Support the new operator **.
|
|
389
|
-
* Support for the new formatting character % allows numbers to be output as percentages.
|
|
390
|
-
* Support for the new formatting character `\e`, which can format numbers in scientific notation.
|
|
391
|
-
- Fixed the issue where illegal formatting strings could cause an infinite loop.
|
|
392
|
-
- Resolved the problem of 1/0 resulting in Infinity.
|
|
393
|
-
- Added several unit tests.
|
|
394
|
-
- More detailed type hints.
|
|
395
|
-
- Updated documentation, added example code for integrating with Vue3.
|
|
396
|
-
* 0.0.80
|
|
397
|
-
* Introducing four rounding rules: truncation, rounding up to the nearest integer, round half up, and round half down.
|
|
398
|
-
- Enhanced detection of more boundary cases.
|
|
399
|
-
- The fmt function allows omitting the format string. This feature enables you to use fmt to remove trailing zeros after the decimal point.
|
|
400
|
-
* 0.0.79
|
|
401
|
-
* Update document
|
|
402
|
-
* 0.0.78
|
|
403
|
-
* Support calculation in scientific notation
|
|
404
|
-
* Comprehensive unit testing
|
|
405
|
-
* Detection of more boundary cases
|
|
406
|
-
* 0.0.72
|
|
407
|
-
* Support writing single numerical values with units, for example `calc("1yuan", {_unit: true})` or `fmt("1yuan | =2",{_unit: true})`
|
|
408
|
-
* Supplement documentation
|
|
409
|
-
|
|
410
|
-
## Attention
|
|
411
|
-
|
|
412
|
-
- Do not enclose individual numbers in parentheses.
|
|
413
|
-
|
|
414
|
-
## Video tutorial
|
|
415
|
-
|
|
416
|
-
To be determined
|
|
417
|
-
|
|
418
|
-
## Issue submission
|
|
419
|
-
|
|
420
|
-
When providing feedback, please include error examples and as much information about the issue as possible. Avoid submitting overly abstract or general statements as feedback! A new version addressing the problem will typically be released within one working day.
|
|
421
|
-
|
|
422
|
-
[](https://github.com/Autumn-one/a-calc-old/stargazers)
|
|
124
|
+
- [GitHub](https://github.com/Autumn-one/a-calc-old)
|
|
125
|
+
- [npm](https://www.npmjs.com/package/a-calc)
|
|
126
|
+
- [问题反馈](https://github.com/Autumn-one/a-calc-old/issues)
|
package/a-calc.versions.js
CHANGED
|
@@ -1,57 +1,61 @@
|
|
|
1
1
|
try{
|
|
2
2
|
globalThis.a_calc_versions = [
|
|
3
|
-
'0.0.5',
|
|
4
|
-
'0.0.32',
|
|
5
|
-
'0.0.37',
|
|
6
|
-
'0.0.53',
|
|
7
|
-
'0.0.56',
|
|
8
|
-
'0.0.60',
|
|
9
|
-
'0.0.72',
|
|
10
|
-
'0.0.80',
|
|
11
|
-
'1.0.8',
|
|
12
|
-
'1.0.13',
|
|
13
|
-
'1.0.16',
|
|
14
|
-
'1.0.19',
|
|
15
|
-
'1.0.22',
|
|
16
|
-
'1.0.25',
|
|
17
|
-
'1.0.28',
|
|
18
|
-
'1.1.1',
|
|
19
|
-
'1.2.2',
|
|
20
|
-
'1.2.9',
|
|
21
|
-
'1.2.15',
|
|
22
|
-
'1.2.18',
|
|
23
|
-
'1.2.22',
|
|
24
|
-
'1.2.25',
|
|
25
|
-
'1.2.28',
|
|
26
|
-
'1.2.31',
|
|
27
|
-
'1.3.1',
|
|
28
|
-
'1.3.3-dev.2023072601',
|
|
29
|
-
'1.3.5',
|
|
30
|
-
'1.3.8-beta.20231129',
|
|
31
|
-
'1.3.9',
|
|
32
|
-
'1.3.11-dev.20240307',
|
|
33
|
-
'1.3.11-dev.2024030704',
|
|
34
|
-
'1.3.11',
|
|
35
|
-
'1.5.0-dev.20240423',
|
|
36
|
-
'1.5.0-dev.2024042302',
|
|
37
|
-
'1.5.0-dev.2024042305',
|
|
38
|
-
'1.5.0-dev.2024042308',
|
|
39
|
-
'1.5.0-dev.2024042311',
|
|
40
|
-
'1.5.0-dev.2024042402',
|
|
41
|
-
'1.5.0-dev.2024042406',
|
|
42
|
-
'2.0.0-dev.20240514',
|
|
43
|
-
'2.0.0-dev.20240522',
|
|
44
|
-
'2.0.0',
|
|
45
|
-
'2.2.1',
|
|
46
|
-
'2.2.4',
|
|
47
|
-
'2.2.7-dev.20240711',
|
|
48
|
-
'2.2.9',
|
|
49
|
-
'2.2.12',
|
|
50
|
-
'2.2.13',
|
|
51
|
-
'2.2.14',
|
|
52
|
-
'3.0.0-beta.
|
|
53
|
-
'3.0.0-beta.
|
|
54
|
-
'3.0.0-beta.
|
|
3
|
+
'0.0.5', '0.0.28', '0.0.29',
|
|
4
|
+
'0.0.32', '0.0.35', '0.0.36',
|
|
5
|
+
'0.0.37', '0.0.39', '0.0.43',
|
|
6
|
+
'0.0.53', '0.0.54', '0.0.55',
|
|
7
|
+
'0.0.56', '0.0.57', '0.0.58',
|
|
8
|
+
'0.0.60', '0.0.61', '0.0.70',
|
|
9
|
+
'0.0.72', '0.0.78', '0.0.79',
|
|
10
|
+
'0.0.80', '1.0.2', '1.0.6',
|
|
11
|
+
'1.0.8', '1.0.10', '1.0.12',
|
|
12
|
+
'1.0.13', '1.0.14', '1.0.15',
|
|
13
|
+
'1.0.16', '1.0.17', '1.0.18',
|
|
14
|
+
'1.0.19', '1.0.20', '1.0.21',
|
|
15
|
+
'1.0.22', '1.0.23', '1.0.24',
|
|
16
|
+
'1.0.25', '1.0.26', '1.0.27',
|
|
17
|
+
'1.0.28', '1.0.29', '1.1.0',
|
|
18
|
+
'1.1.1', '1.2.0', '1.2.1',
|
|
19
|
+
'1.2.2', '1.2.6', '1.2.8',
|
|
20
|
+
'1.2.9', '1.2.10', '1.2.12',
|
|
21
|
+
'1.2.15', '1.2.16', '1.2.17',
|
|
22
|
+
'1.2.18', '1.2.19', '1.2.20',
|
|
23
|
+
'1.2.22', '1.2.23', '1.2.24',
|
|
24
|
+
'1.2.25', '1.2.26', '1.2.27',
|
|
25
|
+
'1.2.28', '1.2.29', '1.2.30',
|
|
26
|
+
'1.2.31', '1.2.32', '1.3.0',
|
|
27
|
+
'1.3.1', '1.3.2', '1.3.3-dev.20230726',
|
|
28
|
+
'1.3.3-dev.2023072601', '1.3.3', '1.3.4',
|
|
29
|
+
'1.3.5', '1.3.6', '1.3.7',
|
|
30
|
+
'1.3.8-beta.20231129', '1.3.8-beta.2023112902', '1.3.8',
|
|
31
|
+
'1.3.9', '1.3.10-dev.20240306', '1.3.10',
|
|
32
|
+
'1.3.11-dev.20240307', '1.3.11-dev.2024030702', '1.3.11-dev.2024030703',
|
|
33
|
+
'1.3.11-dev.2024030704', '1.3.11-dev.2024030705', '1.3.11-dev.2024030706',
|
|
34
|
+
'1.3.11', '1.3.12', '1.5.0-dev.20240325',
|
|
35
|
+
'1.5.0-dev.20240423', '1.5.0-dev.20240424', '1.5.0-dev.2024032502',
|
|
36
|
+
'1.5.0-dev.2024042302', '1.5.0-dev.2024042303', '1.5.0-dev.2024042304',
|
|
37
|
+
'1.5.0-dev.2024042305', '1.5.0-dev.2024042306', '1.5.0-dev.2024042307',
|
|
38
|
+
'1.5.0-dev.2024042308', '1.5.0-dev.2024042309', '1.5.0-dev.2024042310',
|
|
39
|
+
'1.5.0-dev.2024042311', '1.5.0-dev.2024042312', '1.5.0-dev.2024042401',
|
|
40
|
+
'1.5.0-dev.2024042402', '1.5.0-dev.2024042404', '1.5.0-dev.2024042405',
|
|
41
|
+
'1.5.0-dev.2024042406', '2.0.0-dev.20240511', '2.0.0-dev.20240513',
|
|
42
|
+
'2.0.0-dev.20240514', '2.0.0-dev.20240517', '2.0.0-dev.20240520',
|
|
43
|
+
'2.0.0-dev.20240522', '2.0.0-dev.2024052101', '2.0.0-dev.2024052102',
|
|
44
|
+
'2.0.0', '2.1.0', '2.2.0',
|
|
45
|
+
'2.2.1', '2.2.2', '2.2.3',
|
|
46
|
+
'2.2.4', '2.2.5', '2.2.6',
|
|
47
|
+
'2.2.7-dev.20240711', '2.2.7', '2.2.8',
|
|
48
|
+
'2.2.9', '2.2.10', '2.2.11',
|
|
49
|
+
'2.2.12', '2.2.13-dev.20241119', '2.2.13-dev.2024111902',
|
|
50
|
+
'2.2.13', '2.2.14-dev.20241204', '2.2.14-dev.2024120401',
|
|
51
|
+
'2.2.14', '2.2.15', '3.0.0-beta.20250123',
|
|
52
|
+
'3.0.0-beta.20250123.2', '3.0.0-beta.20250123.3', '3.0.0-beta.20250123.4',
|
|
53
|
+
'3.0.0-beta.20250123.5', '3.0.0-beta.20250123.6', '3.0.0-beta.20250123.7',
|
|
54
|
+
'3.0.0-beta.20250123.9', '3.0.0-beta.20250123.10', '3.0.0-beta.20250123.11',
|
|
55
|
+
'3.0.0-beta.20250123.12', '3.0.0-beta.20251208', '3.0.0-beta.20260105',
|
|
56
|
+
'3.0.0-beta.20260121', '3.0.0-beta.2025120802', '3.0.0-beta.2025120803',
|
|
57
|
+
'3.0.0-beta.2025120804', '3.0.0-beta.2025120805', '3.0.0-beta.2025120806',
|
|
58
|
+
'3.0.0-beta.2025120807', '3.0.0-beta.2025120808', '3.0.0-beta.20250123.12'
|
|
55
59
|
]; a_calc_versions;
|
|
56
60
|
}
|
|
57
61
|
finally
|