a-calc 3.0.0-beta.2025120808 → 3.0.0-beta.20260121

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 CHANGED
@@ -1,446 +1,126 @@
1
1
  # a-calc
2
- [![npm version](https://img.shields.io/npm/v/a-calc.svg)](https://www.npmjs.com/package/a-calc) [![Static Badge](https://img.shields.io/bundlephobia/minzip/a-calc?label=minzipped)](https://github.com/Autumn-one/a-calc-old) [![Static Badge](https://img.shields.io/badge/Javascript-5A5A5A?style=flat&logo=javascript&link=https%3A%2F%2Fwww.npmjs.com%2Fpackage%2Fa-calc)](https://github.com/Autumn-one/a-calc-old) [![Static Badge](https://img.shields.io/badge/Typescript-5A5A5A?style=flat&logo=typescript&logoColor=F7DF1E&link=https%3A%2F%2Fwww.npmjs.com%2Fpackage%2Fa-calc)](https://github.com/Autumn-one/a-calc-old) [![npm downloads](https://img.shields.io/npm/dw/a-calc)](https://www.npmjs.com/package/a-calc)
3
2
 
4
- ## Features and Advantages
3
+ [![npm version](https://img.shields.io/npm/v/a-calc.svg)](https://www.npmjs.com/package/a-calc) [![npm downloads](https://img.shields.io/npm/dw/a-calc)](https://www.npmjs.com/package/a-calc)
5
4
 
6
- **:baby_chick:Easy** Push the coding experience to the extreme, the minimalist API is easy to remember.
5
+ 强大易用的 JavaScript 精度计算与格式化库。
7
6
 
8
- **:rocket:Fast** Continuously optimizing details, it now operates very quickly.
7
+ ## 特性
9
8
 
10
- **💪Powerful** Precise number calculation, number formatting, complete rounding rules, unit calculation, robust type hinting.
9
+ - **精确计算** - 解决 JavaScript 浮点数精度问题
10
+ - **强大格式化** - 千分位、百分比、分数、科学计数法
11
+ - **单位计算** - 支持带单位的数字运算
12
+ - **完整舍入** - 去尾、进一、四舍五入、四舍六入
13
+ - **高性能** - 同类库中最快
14
+ - **TypeScript** - 完整类型支持
11
15
 
12
- **:snake:Flexible** The flexible API allows you to write freely, however you want.
16
+ ## 安装
13
17
 
14
- **:corn:Practical** Born from actual business, it covers all practical operations in the business.
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
- ## Import
22
+ ## 快速开始
27
23
 
28
- **commonjs**
24
+ ```javascript
25
+ import { calc, fmt } from "a-calc";
29
26
 
30
- ```js
31
- const {calc, fmt} = require("a-calc")
32
- // or
33
- const {calc, fmt} = require("a-calc/cjs")
34
- ```
27
+ // 精确计算
28
+ calc("0.1 + 0.2"); // "0.3"
35
29
 
36
- **es module**
30
+ // 复杂表达式
31
+ calc("0.1 + 0.2 * 0.3 / 0.4 * (0.5 + 0.6)"); // "0.265"
37
32
 
38
- ```js
39
- import {calc, fmt} from "a-calc"
40
- // or
41
- const {calc, fmt} from "a-calc/es"
42
- ```
33
+ // 变量计算
34
+ calc("a + b", { a: 1, b: 2 }); // "3"
43
35
 
44
- **Browser side**
36
+ // 格式化
37
+ fmt("1000000 | ,"); // "1,000,000"
45
38
 
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>
39
+ // 计算并格式化
40
+ calc("111111 + 11111 | ,=2"); // "122,222.00"
52
41
  ```
53
42
 
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"
43
+ ## 核心 API
64
44
 
65
- // Calculations with units
66
- calc("0.1% + 0.2%", {_unit: true}) // "0.3%"
45
+ ### calc(expr, data?)
67
46
 
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$"
47
+ 计算表达式,支持变量和格式化。
73
48
 
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
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%"
80
53
  ```
81
54
 
82
- ## About the space
55
+ ### fmt(value)
83
56
 
84
- By default, spaces in expressions are not required, unless you use the space or space-all mode or the calc_lite function, which are introduced in later chapters. However, I recommend that you always include spaces in expressions, which look clearer and nicer.
57
+ 格式化数字。
85
58
 
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"
59
+ ```javascript
60
+ fmt("1234567 | ,"); // "1,234,567"
61
+ fmt("0.12345 | =2"); // "0.12"
62
+ fmt("0.5 | %"); // "50%"
108
63
  ```
109
64
 
110
- ## Calculation with units
65
+ ### 格式化参数
111
66
 
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.
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" |
113
79
 
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%"
80
+ ### 舍入规则
117
81
 
118
- calc("1.123$$$ + 2.88% | + =6", {_unit: true}) // "+4.003000$$$"
82
+ | 参数 | 说明 |
83
+ | ---- | ---------------------- |
84
+ | `~-` | 去尾(默认) |
85
+ | `~+` | 进一 |
86
+ | `~5` | 四舍五入 |
87
+ | `~6` | 四舍六入(银行家舍入) |
119
88
 
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%"
89
+ ```javascript
90
+ calc("0.55 | =1 ~5"); // "0.6"
91
+ calc("0.65 | =1 ~6"); // "0.6"
122
92
  ```
123
93
 
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"
94
+ ## 性能对比
151
95
 
152
- // Thousandth place
153
- calc("10000000 + 100000000 | ,") // "110,000,000"
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 |
154
102
 
155
- // Fraction
156
- calc("0.025 + 0.2 | /") // "9/40"
103
+ ## 文档
157
104
 
158
- // Percentage
159
- calc("1 + 1 | %") // "200%"
105
+ - [快速开始](./.docs/QUICK_START.md)
106
+ - [完整文档索引](./.docs/README.md)
107
+ - [贡献指南](./.docs/CONTRIBUTING.md)
160
108
 
161
- // Scientific notation, note that this e can also be capitalized
162
- calc("1 + 1 | !e") // "2e+0"
109
+ ## 开发
163
110
 
164
- // Simultaneously specify decimals and thousandth place while preserving the positive and negative signs
165
- calc("10000000 + 100000000 | +,=10") // "+110,000,000.0000000000"
111
+ ```bash
112
+ pnpm install # 安装依赖
113
+ pnpm dev # 开发模式
114
+ pnpm build # 构建
115
+ pnpm test # 测试
166
116
  ```
167
117
 
168
- ## Four kinds of rounding rules
169
-
170
- The rounding rules are added to the part of the formatting string, and their symbols are:
171
-
172
- - `~-` Truncation, the default rounding rule
173
- - `~+` Increment
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.
176
-
177
- ```js
178
- calc("0.11 + 0.22 | =1 ~+") // "0.4" Keep one place and increment it
179
- calc("0.55 | =1 ~5") // "0.6"
180
- calc("0.65 | =1 ~6") // "0.6"
181
- ```
182
-
183
- This newly added rounding rule seems to make the formatting part longer, but the actual situation is not like this. Generally, the rounding rule of a project is fixed, so the formatting part of the rounding rule should be encapsulated in the default formatting parameters. When it is actually used, there is no need to write this part of the content at all. Refer to the following `default formatting` instructions.
184
-
185
- ## Only format
186
-
187
- ```js
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
191
-
192
- fmt("1000000 | ,") // "1,000,000"
193
- ```
194
-
195
- ## Configure version number printing and library update detection
196
-
197
- You can turn on or off the console printing of the current library version number, and you can also turn on or off console prompts for whether there is a new version update.
198
-
199
- ```typescript
200
- import { calc_util } from "a-calc"
201
- calc_util.print_version(); // Print the version in the console
202
- calc_util.check_update(); // Enable the update detection function. If there are updates, it will remind you in the console.
203
- ```
204
-
205
- ## Advanced techniques
206
-
207
- **Error handling**
208
-
209
- > Typically, using calc directly requires that the input calculation formula is completely correct, and by default a-calc will not help you handle errors in the formula. This can be filtered out by oneself, but in the project, we might not want to do this, so we need an additional advanced API to silently capture and give an appropriate return value when the input formula is incorrect.
210
-
211
- ```js
212
- calc("1 + 2sd + d",{
213
- _fill_data: {d: 3}, // From here, the data source object needs to be assigned to _fill_data. This object can also be an array of objects. At this time, when obtaining data, it is searched item by item from the array, and it stops immediately when the first one is found.
214
- _error: "-", // When the calculation formula is wrong, it returns - as an alternative value.
215
- })
216
-
217
- // The above writing can be simplified a bit.
218
- calc("1 + 2sd + d", {
219
- d: 8,
220
- _error: "-"
221
- }) // This simplification is purely for convenience.
222
- ```
118
+ ## 许可证
223
119
 
224
- **Default formatting**
120
+ [MIT](./LICENSE)
225
121
 
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.
237
-
238
- I suggest that if you decide to bring calc_wrap into the project, you can rename it as calc to save a few characters. The following will show some flexible writing methods and powerful type inference.
239
-
240
- ```typescript
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";
243
-
244
- const state = {
245
- a: 1,
246
- b: 2,
247
- c: 3
248
- };
249
-
250
- // When the passed parameter is a calculation formula without a variable name, it will directly return the calculation result.
251
- calc( "(1 + 2) * 3" ); // Return type: string
252
-
253
- // When the passed parameter is a suspected calculation formula containing a variable name and there is no second data source parameter, a function waiting for a data source to be passed will be returned. Yes, this function is achieved through static type deduction.
254
- calc( "(a + b) * c" ); // Return type: ( data: any ) => string
255
- calc( "(a + b) * c" )( state ); // Return type: string
256
-
257
- // Maybe you want to inject the state first and then enter the expression. This is also possible.
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
266
- ```
267
-
268
- ### Not recommended writing
269
-
270
- `a-calc` can use the template string syntax, but I found that the readability of this writing method is very poor in practice. Unless you really have a sufficiently reasonable reason, it is not recommended to use the template string syntax.
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
- ```
276
-
277
- ## space and space-all modes
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
- ## Compact Method calc_lite
300
-
301
- `calc_lite` is a streamlined version of calc. Its functions are not as comprehensive as calc, but its internal logic is simpler and its performance is stronger than calc (but the gains are limited). Similarly, there are also some drawbacks. The writing experience is not as good as calc, and it is not as powerful as calc. Some functions are not available in calclite: the function does not support unit operations, does not support mode specification, and does not support calculations like `- ( 3 - - ( -2 ) )`.
302
-
303
- The arithmetic and formatting parts of the `calc_lite` function are passed in separately, and all internal units of the calculation must be strictly separated by spaces! This function does not exist to replace `calc`, it is just a streamlined version of calc's logic, sacrificing some infrequently used functionality and writing experience for a limited performance improvement.
304
-
305
- Note that this function will not throw any exceptions. By default, when an error occurs, the function will return `-`.
306
-
307
- ```typescript
308
- import {calc_lite} from "a-calc"
309
-
310
- // The function has a total of 4 parameters, namely calcexpr, fmtexpr, data, err_value = "-", they correspond to the calculation, formatting string, filling data, and return value when an error occurs.
311
- // Only the first parameter must be passed in, the others can be omitted. If you want to skip passing in, you can pass in null or undefined.
312
- calc_lite("a + b", null, {a: 0.1, b: 0.2}) // "0.3"
313
- calc_lite("1 + 2 + b") // "-"
314
- calc_lite("1", "=2") // "1.00"
315
- calc_lite("( 1 + 2 ) * 3") // "9" Spaces must be strictly inserted on both sides of the parentheses.
316
- calc_lite("1+1") // "-" The calculation error is caused by the fact that the units in the calculation are not strictly separated by spaces.
317
- ```
318
-
319
- ## Aggregation Methods
320
-
321
- 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.
322
-
323
- ```typescript
324
- calc_sum("a + b | =2", [{a: 1,b: 2 }, {a: 3, b:4}]) // "10.00"
325
- ```
122
+ ## 链接
326
123
 
327
- ## Performance Comparison
328
-
329
- Performance test results are subject to variation and may differ across different hardware configurations. The final metrics should be considered only as a reference for comparing the relative performance between different libraries.
330
-
331
- | | `a-calc@2.2.10` | `mathjs@12.4.3` | `mathjs@13.0.2` | `math-expression-evaluator@2.0.4` |
332
- | -------------------------------- | --------------- | --------------- | --------------- | --------------------------------- |
333
- | 50,000 calculations runtime(ms) | 423 | 3791 | 610 | 701 |
334
- | 500,000 calculations runtime(ms) | 3650 | 36948 | 5724 | 6764 |
335
-
336
- ## Version changes
337
-
338
- * 2.2.15
339
- - 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)`
340
- * 2.2.7
341
-
342
- - Enhanced documentation will prompt your IDE to display explanations and usage examples for each function as you write them.
343
- - Optimization of parameter passing in the `calc_lite` function has made its usage more flexible now.
344
- * 2.2.0
345
-
346
- - Introduce a simpler and higher performance `calc_lite` function.
347
- * 2.1.0
348
-
349
- - 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.
350
- * 2.0.0
351
-
352
- - Destructive change: The \_unit parameter now only supports boolean type, the previous space value has been moved to the \_mode parameter.
353
- - 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".
354
- - Significant performance improvement, it is now the fastest among similar libraries.
355
- - Expose high-performance function methods, for simple arithmetic expressions you can opt to use straightforward functions for invocation, such as: `plus(1, 1)`
356
- - Added the configuration for the \_mode mode.
357
- - Now it is also possible to configure when the second parameter is an array.
358
- - Exposed primitive methods such as plus, subtract, multiply, divide, modulo, power, integer division and their corresponding memo versions.
359
- - Added support for the `//` floor division operator.
360
- - `**` to right-bound to be consistent with the native JS language rules
361
- * 1.3.9 Solved the problem of failed rounding due to the part of the injection variable in formatting being 0 (Problem reporter: MangMax)
362
- * 1.3.8 Solved the packaging failure problem caused by the upgrade of vite5.x (Problem reporter: 武建鹏)
363
- * 1.3.6
364
- - The priority of the `!n` formatting parameter has been adjusted to the highest, and no other formatting parameters can affect it.
365
- - Added `!u` formatting parameter, which can remove the unit part from the result.
366
- - Type hint enhancement
367
- * 1.3.4
368
- - Fixed the bug of rounding error between rounding off and rounding to nearest even number (bug provider: nanarino)
369
- * 1.3.0
370
- - BREAKING CHANGE: Adjust the invocation method of printing version and checking update function
371
- - Refine Type Hints
372
- - Add more unit tests.
373
- * 1.2.30
374
- - The previous version printed version numbers by default, now it is configurable and disabled by default
375
- - It provides an update detection function. Once enabled, the console will give a hint if there is a new version.
376
- * 1.2.10
377
- - 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.
378
- - Add the functionality of `calc_wrap`, which is a secondary wrapper for the core function `calc` and can be used directly.
379
- * 1.2.6
380
- - 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.
381
- * 1.2.0
382
- - A minor disruptive update, where the previous `-e` and `-n` have been changed to `!e` and `!n`, respectively.
383
- - Document Update
384
- * 1.1.0
385
- - Small breaking change, the previous `\e` scientific counting output is now `-e`, others did not change
386
- - Added `-n` to output the number type
387
- - The limitation on decimal places is supported by the `<` and `>` symbols.
388
- - Fixed several rounding formatting issues.
389
- - The unit tests have increased to 107.
390
- * 1.0.25
391
- - Update the document to simplify the integration of a-calc into Vue3.
392
- * 1.0.23
393
- - Update the document and rewrite the recommended way to integrate a-calc into Vue3.
394
- * 1.0.22
395
- - Optimize decimal rounding logic.
396
- * 1.0.21
397
- - Refine the exported type definitions.
398
- * 1.0.19
399
- - Fix the issue where errors may not be captured when _error is an empty string.
400
- * 1.0.14
401
- - Fix the issue of `**` operator precedence error.
402
- - Fix the issue of extra zeros not being removed when formatting with `<=`.
403
- * 1.0.12
404
- - Document adding library volume description
405
- - Fix the issue where adding the _error parameter when the expression is empty still causes an error, and include corresponding unit tests.
406
- * 1.0.10
407
- - Update document
408
- * 1.0.6
409
- * 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.
410
- * The internal code has been greatly simplified, the parser has been almost completely rewritten, resulting in a more stable user experience.
411
- * 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.
412
- * Support the new operator **.
413
- * Support for the new formatting character % allows numbers to be output as percentages.
414
- * Support for the new formatting character `\e`, which can format numbers in scientific notation.
415
- - Fixed the issue where illegal formatting strings could cause an infinite loop.
416
- - Resolved the problem of 1/0 resulting in Infinity.
417
- - Added several unit tests.
418
- - More detailed type hints.
419
- - Updated documentation, added example code for integrating with Vue3.
420
- * 0.0.80
421
- * Introducing four rounding rules: truncation, rounding up to the nearest integer, round half up, and round half down.
422
- - Enhanced detection of more boundary cases.
423
- - The fmt function allows omitting the format string. This feature enables you to use fmt to remove trailing zeros after the decimal point.
424
- * 0.0.79
425
- * Update document
426
- * 0.0.78
427
- * Support calculation in scientific notation
428
- * Comprehensive unit testing
429
- * Detection of more boundary cases
430
- * 0.0.72
431
- * Support writing single numerical values with units, for example `calc("1yuan", {_unit: true})` or `fmt("1yuan | =2",{_unit: true})`
432
- * Supplement documentation
433
-
434
- ## Attention
435
-
436
- - Do not enclose individual numbers in parentheses.
437
-
438
- ## Video tutorial
439
-
440
- To be determined
441
-
442
- ## Issue submission
443
-
444
- 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.
445
-
446
- [![Stargazers repo roster for @Autumn-one/a-calc](https://reporoster.com/stars/Autumn-one/a-calc-old)](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)
@@ -49,8 +49,9 @@ try{
49
49
  '2.2.12', '2.2.13-dev.20241119', '2.2.13-dev.2024111902',
50
50
  '2.2.13', '2.2.14-dev.20241204', '2.2.14-dev.2024120401',
51
51
  '2.2.14', '2.2.15', '3.0.0-beta.20251208',
52
- '3.0.0-beta.2025120802', '3.0.0-beta.2025120803', '3.0.0-beta.2025120804',
53
- '3.0.0-beta.2025120805', '3.0.0-beta.2025120806', '3.0.0-beta.2025120807', '3.0.0-beta.2025120808'
52
+ '3.0.0-beta.20260105', '3.0.0-beta.2025120802', '3.0.0-beta.2025120803',
53
+ '3.0.0-beta.2025120804', '3.0.0-beta.2025120805', '3.0.0-beta.2025120806',
54
+ '3.0.0-beta.2025120807', '3.0.0-beta.2025120808', '3.0.0-beta.20260121'
54
55
  ]; a_calc_versions;
55
56
  }
56
57
  finally