a-calc 3.0.0-beta.2025120807 → 3.0.0-beta.20260105
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 +1 -25
- package/a-calc.versions.js +2 -1
- package/browser/index.js +8 -1
- package/calc.d.ts +369 -72
- package/cjs/index.js +8 -1
- package/es/index.js +8 -1
- package/package.json +14 -4
package/README.md
CHANGED
|
@@ -81,7 +81,7 @@ calc("1 + 1 | !n") // 2
|
|
|
81
81
|
|
|
82
82
|
## About the space
|
|
83
83
|
|
|
84
|
-
By default, spaces in expressions are not required, unless you use the space or space-all mode
|
|
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
85
|
|
|
86
86
|
## Fill in variables and calculate (important)
|
|
87
87
|
|
|
@@ -296,26 +296,6 @@ plus(1, 1) // 2
|
|
|
296
296
|
plus(1, 1, "string") // "2"
|
|
297
297
|
```
|
|
298
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
299
|
## Aggregation Methods
|
|
320
300
|
|
|
321
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.
|
|
@@ -340,10 +320,6 @@ Performance test results are subject to variation and may differ across differen
|
|
|
340
320
|
* 2.2.7
|
|
341
321
|
|
|
342
322
|
- 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
323
|
* 2.1.0
|
|
348
324
|
|
|
349
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.
|
package/a-calc.versions.js
CHANGED
|
@@ -50,7 +50,8 @@ try{
|
|
|
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
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'
|
|
53
|
+
'3.0.0-beta.2025120805', '3.0.0-beta.2025120806', '3.0.0-beta.2025120807',
|
|
54
|
+
'3.0.0-beta.2025120808', '3.0.0-beta.20260104', '3.0.0-beta.20260105'
|
|
54
55
|
]; a_calc_versions;
|
|
55
56
|
}
|
|
56
57
|
finally
|