@pie-lib/math-evaluator 2.2.1-beta.0 → 2.4.0

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/CHANGELOG.json CHANGED
@@ -1,457 +1 @@
1
- [
2
- {
3
- "type": "fix",
4
- "scope": null,
5
- "subject": "rm child prepack in favour of root prepack",
6
- "merge": null,
7
- "header": "fix: rm child prepack in favour of root prepack",
8
- "body": null,
9
- "footer": null,
10
- "notes": [],
11
- "hash": "381d8d6485269b641d8d4655148966d2e70803be",
12
- "gitTags": "",
13
- "committerDate": "2019-03-15 09:51:11 +0000",
14
- "isTagged": true,
15
- "tag": "@pie-lib/math-evaluator@0.3.9"
16
- },
17
- {
18
- "type": "chore",
19
- "scope": null,
20
- "subject": "get packages to call changelog function on prepack",
21
- "merge": null,
22
- "header": "chore: get packages to call changelog function on prepack",
23
- "body": null,
24
- "footer": null,
25
- "notes": [],
26
- "hash": "8828f01f2d16d29404ba837c1de40d09e7230ec5",
27
- "gitTags": "",
28
- "committerDate": "2019-03-14 12:40:05 +0000",
29
- "isTagged": true,
30
- "tag": "@pie-lib/math-evaluator@0.3.5"
31
- },
32
- {
33
- "type": "chore",
34
- "scope": null,
35
- "subject": "call changelog on prepack",
36
- "merge": null,
37
- "header": "chore: call changelog on prepack",
38
- "body": null,
39
- "footer": null,
40
- "notes": [],
41
- "hash": "b672c012de096c55b765a765f758da3fc5df2f90",
42
- "gitTags": "",
43
- "committerDate": "2019-03-13 23:00:44 +0000",
44
- "isTagged": true,
45
- "tag": "@pie-lib/math-evaluator@0.3.4"
46
- },
47
- {
48
- "type": "chore",
49
- "scope": null,
50
- "subject": "generate changelog.json instead of markdown",
51
- "merge": null,
52
- "header": "chore: generate changelog.json instead of markdown",
53
- "body": null,
54
- "footer": null,
55
- "notes": [],
56
- "hash": "eaa5019a11f70c53425d55856bd3b940237f8c7d",
57
- "gitTags": "",
58
- "committerDate": "2019-03-13 17:24:09 +0000",
59
- "isTagged": true,
60
- "tag": "@pie-lib/math-evaluator@0.3.2"
61
- },
62
- {
63
- "type": "feat",
64
- "scope": null,
65
- "subject": "libs version bump",
66
- "merge": null,
67
- "header": "feat: libs version bump",
68
- "body": null,
69
- "footer": null,
70
- "notes": [],
71
- "hash": "4edc4bebdd7694efe5b18230c0dd5215591d4a28",
72
- "gitTags": "",
73
- "committerDate": "2019-01-30 22:14:28 +0000",
74
- "isTagged": true,
75
- "tag": "@pie-lib/math-evaluator@0.3.0"
76
- },
77
- {
78
- "type": "fix",
79
- "scope": null,
80
- "subject": "math-expressions import",
81
- "merge": null,
82
- "header": "fix: math-expressions import",
83
- "body": null,
84
- "footer": null,
85
- "notes": [],
86
- "hash": "10d25b98d80d0295e5386320d885107a10f9b7d1",
87
- "gitTags": "",
88
- "committerDate": "2019-01-30 22:14:28 +0000",
89
- "isTagged": true,
90
- "tag": "@pie-lib/math-evaluator@0.3.0"
91
- },
92
- {
93
- "type": "fix",
94
- "scope": null,
95
- "subject": "use plain module from math-expressions",
96
- "merge": null,
97
- "header": "fix: use plain module from math-expressions",
98
- "body": null,
99
- "footer": null,
100
- "notes": [],
101
- "hash": "a8f0647adb9cf9419c12f742914a34b570f3f661",
102
- "gitTags": "",
103
- "committerDate": "2019-01-16 21:44:10 +0000",
104
- "isTagged": true,
105
- "tag": "@pie-lib/math-evaluator@0.3.0"
106
- },
107
- {
108
- "type": "chore",
109
- "scope": "math-evaluator",
110
- "subject": "unit test adjustments and fixes",
111
- "merge": null,
112
- "header": "chore(math-evaluator): unit test adjustments and fixes",
113
- "body": null,
114
- "footer": null,
115
- "notes": [],
116
- "hash": "38fc44c3f06549efe72b5d1608aad0ca9f0b98fe",
117
- "gitTags": "",
118
- "committerDate": "2018-11-09 13:48:04 +0200",
119
- "isTagged": true,
120
- "tag": "@pie-lib/math-evaluator@0.2.0"
121
- },
122
- {
123
- "type": "feat",
124
- "scope": "math-evaluator",
125
- "subject": "finalized for first release",
126
- "merge": null,
127
- "header": "feat(math-evaluator): finalized for first release",
128
- "body": null,
129
- "footer": null,
130
- "notes": [],
131
- "hash": "e696925b36d047b689174fabf25950c17e53abdf",
132
- "gitTags": "",
133
- "committerDate": "2018-11-08 08:57:08 +0200",
134
- "isTagged": true,
135
- "tag": "@pie-lib/math-evaluator@0.2.0"
136
- },
137
- {
138
- "type": "feat",
139
- "scope": "math-evaluator",
140
- "subject": "finalized feature for first release",
141
- "merge": null,
142
- "header": "feat(math-evaluator): finalized feature for first release",
143
- "body": null,
144
- "footer": null,
145
- "notes": [],
146
- "hash": "f02d7b36a7c3e8ae1d9e5950cd8a173250ec2905",
147
- "gitTags": "",
148
- "committerDate": "2018-11-07 12:17:28 +0200",
149
- "isTagged": true,
150
- "tag": "@pie-lib/math-evaluator@0.2.0"
151
- },
152
- {
153
- "type": "fix",
154
- "scope": "math-evaluator",
155
- "subject": "small unit test adjustments",
156
- "merge": null,
157
- "header": "fix(math-evaluator): small unit test adjustments",
158
- "body": null,
159
- "footer": null,
160
- "notes": [],
161
- "hash": "92a2eab125b023374c6d69dcf191a49b7f78b122",
162
- "gitTags": "",
163
- "committerDate": "2018-10-23 14:00:09 +0300",
164
- "isTagged": true,
165
- "tag": "@pie-lib/math-evaluator@0.1.0"
166
- },
167
- {
168
- "type": "feat",
169
- "scope": "math-evaluator",
170
- "subject": "feature added",
171
- "merge": null,
172
- "header": "feat(math-evaluator): feature added",
173
- "body": null,
174
- "footer": null,
175
- "notes": [],
176
- "hash": "0703e9e94b4126c943d6af5e2b1cc45ec2454115",
177
- "gitTags": "",
178
- "committerDate": "2018-10-22 09:48:19 +0300",
179
- "isTagged": true,
180
- "tag": "@pie-lib/math-evaluator@0.1.0"
181
- },
182
- {
183
- "type": "chore",
184
- "scope": null,
185
- "subject": "prettify it",
186
- "merge": null,
187
- "header": "chore: prettify it",
188
- "body": null,
189
- "footer": null,
190
- "notes": [],
191
- "hash": "32b365bcd81976fbe8ecb6c7c0574d6a9226a4aa",
192
- "gitTags": "",
193
- "committerDate": "2019-04-10 10:27:22 +0300",
194
- "isTagged": true,
195
- "tag": "@pie-lib/math-evaluator@0.4.0"
196
- },
197
- {
198
- "type": "feat",
199
- "scope": "math-evaluator",
200
- "subject": "introduce partial rationalization, polynomial equation fixes and allowDecimals option",
201
- "merge": null,
202
- "header": "feat(math-evaluator): introduce partial rationalization, polynomial equation fixes and allowDecimals option",
203
- "body": null,
204
- "footer": null,
205
- "notes": [],
206
- "hash": "78fe0a11eaaf23db7134e08d2b2ed2a2cd1b427b",
207
- "gitTags": "",
208
- "committerDate": "2019-04-10 10:22:39 +0300",
209
- "isTagged": true,
210
- "tag": "@pie-lib/math-evaluator@0.4.0"
211
- },
212
- {
213
- "type": "chore",
214
- "scope": null,
215
- "subject": "update unit tests for math-evaluator",
216
- "merge": null,
217
- "header": "chore: update unit tests for math-evaluator",
218
- "body": null,
219
- "footer": null,
220
- "notes": [],
221
- "hash": "b478b0fb87da0d321fe1af40a5cdef1b7bb0d1d3",
222
- "gitTags": "",
223
- "committerDate": "2019-05-13 15:02:24 +0300",
224
- "isTagged": true,
225
- "tag": "@pie-lib/math-evaluator@0.5.0"
226
- },
227
- {
228
- "type": "feat",
229
- "scope": "math-evaluator",
230
- "subject": "re-define what allowDecimals means - thousand separator support with decimal dot support",
231
- "merge": null,
232
- "header": "feat(math-evaluator): re-define what allowDecimals means - thousand separator support with decimal dot support",
233
- "body": null,
234
- "footer": null,
235
- "notes": [],
236
- "hash": "f79ff3b9b239716076fc9b1fd79868ab74680894",
237
- "gitTags": "",
238
- "committerDate": "2019-05-13 14:59:36 +0300",
239
- "isTagged": true,
240
- "tag": "@pie-lib/math-evaluator@0.5.0"
241
- },
242
- {
243
- "type": "chore",
244
- "scope": "merge",
245
- "subject": "merged with develop",
246
- "merge": null,
247
- "header": "chore(merge): merged with develop",
248
- "body": null,
249
- "footer": null,
250
- "notes": [],
251
- "hash": "e68506cf63b2a17973821bb0cfef40828faccd1f",
252
- "gitTags": "",
253
- "committerDate": "2019-05-21 06:26:54 +0300",
254
- "isTagged": true,
255
- "tag": "@pie-lib/math-evaluator@0.5.1"
256
- },
257
- {
258
- "type": "fix",
259
- "scope": "math-evaluator",
260
- "subject": "fix equals sign treatment in expressions",
261
- "merge": null,
262
- "header": "fix(math-evaluator): fix equals sign treatment in expressions",
263
- "body": null,
264
- "footer": null,
265
- "notes": [],
266
- "hash": "f81e9245ad3fefd0895c510cd3e2b2f3d4d11843",
267
- "gitTags": " (origin/fix/math-evaluator-expression-fixes)",
268
- "committerDate": "2019-06-25 15:43:58 +0300",
269
- "isTagged": true,
270
- "tag": "@pie-lib/math-evaluator@0.5.4"
271
- },
272
- {
273
- "type": "chore",
274
- "scope": null,
275
- "subject": "added two failing tests for math-evaluator",
276
- "merge": null,
277
- "header": "chore: added two failing tests for math-evaluator",
278
- "body": null,
279
- "footer": null,
280
- "notes": [],
281
- "hash": "326a94b419dc16c3a23b80d155e0b0a3e32a7b28",
282
- "gitTags": "",
283
- "committerDate": "2019-06-24 18:26:25 +0300",
284
- "isTagged": true,
285
- "tag": "@pie-lib/math-evaluator@0.5.4"
286
- },
287
- {
288
- "type": "feat",
289
- "scope": "math-evaluator",
290
- "subject": "change math-expressions to pie fork",
291
- "merge": null,
292
- "header": "feat(math-evaluator): change math-expressions to pie fork",
293
- "body": null,
294
- "footer": null,
295
- "notes": [],
296
- "hash": "06e8b617fd8f3d54057850d3964616165bdf7ad7",
297
- "gitTags": "",
298
- "committerDate": "2019-11-22 16:17:54 +0200",
299
- "isTagged": true,
300
- "tag": "@pie-lib/math-evaluator@0.6.0"
301
- },
302
- {
303
- "type": "fix",
304
- "scope": "math-evaluator",
305
- "subject": "finalize fix for PIE-188, custom and unrecognized latex commands",
306
- "merge": null,
307
- "header": "fix(math-evaluator): finalize fix for PIE-188, custom and unrecognized latex commands",
308
- "body": null,
309
- "footer": null,
310
- "notes": [],
311
- "hash": "b37184d6a1a7676fe25372b2388dd60fad94638d",
312
- "gitTags": "",
313
- "committerDate": "2019-11-22 12:32:30 +0200",
314
- "isTagged": true,
315
- "tag": "@pie-lib/math-evaluator@0.6.0"
316
- },
317
- {
318
- "type": "fix",
319
- "scope": "math-evaluator",
320
- "subject": "finalize fix for PIE-188",
321
- "merge": null,
322
- "header": "fix(math-evaluator): finalize fix for PIE-188",
323
- "body": null,
324
- "footer": null,
325
- "notes": [],
326
- "hash": "d7bd4a1d0576d1c6e2fbf6b46ad5c6a12ad70133",
327
- "gitTags": "",
328
- "committerDate": "2019-11-22 12:14:12 +0200",
329
- "isTagged": true,
330
- "tag": "@pie-lib/math-evaluator@0.6.0"
331
- },
332
- {
333
- "type": "fix",
334
- "scope": "math-evaluator",
335
- "subject": "PIE-188 related fixes and tests",
336
- "merge": null,
337
- "header": "fix(math-evaluator): PIE-188 related fixes and tests",
338
- "body": null,
339
- "footer": null,
340
- "notes": [],
341
- "hash": "76424c677a8d0147e7654ca27098d682da9a42bb",
342
- "gitTags": "",
343
- "committerDate": "2019-11-19 13:16:36 +0200",
344
- "isTagged": true,
345
- "tag": "@pie-lib/math-evaluator@0.6.0"
346
- },
347
- {
348
- "type": "fix",
349
- "scope": null,
350
- "subject": "bump @pie-framework/math-expressions@^2.1.0 ch6456",
351
- "merge": null,
352
- "header": "fix: bump @pie-framework/math-expressions@^2.1.0 ch6456",
353
- "body": null,
354
- "footer": null,
355
- "notes": [],
356
- "hash": "d57971f1f1dd2943ced3ffa3dec0a324ba04e487",
357
- "gitTags": " (origin/fix/ch6456-percent)",
358
- "committerDate": "2019-12-20 11:14:25 +0000",
359
- "isTagged": true,
360
- "tag": "@pie-lib/math-evaluator@0.6.5"
361
- },
362
- {
363
- "type": "fix",
364
- "scope": null,
365
- "subject": "bump @pie-framework/math-expressions@2.2.0 [ch7119]",
366
- "merge": null,
367
- "header": "fix: bump @pie-framework/math-expressions@2.2.0 [ch7119]",
368
- "body": null,
369
- "footer": null,
370
- "notes": [],
371
- "hash": "b7fa81033d2980228e5f07f44904c63e0aea84c1",
372
- "gitTags": "",
373
- "committerDate": "2020-01-27 11:07:32 +0000",
374
- "isTagged": true,
375
- "tag": "@pie-lib/math-evaluator@0.6.6"
376
- },
377
- {
378
- "type": "fix",
379
- "scope": null,
380
- "subject": "throw error if number missing factor",
381
- "merge": null,
382
- "header": "fix: throw error if number missing factor",
383
- "body": null,
384
- "footer": null,
385
- "notes": [],
386
- "hash": "3b23b28e851d07c49c414b05d747141d415e960e",
387
- "gitTags": " (origin/develop, origin/HEAD, develop)",
388
- "committerDate": "2020-01-28 11:27:09 +0000",
389
- "isTagged": true,
390
- "tag": "@pie-lib/math-evaluator@0.6.7"
391
- },
392
- {
393
- "type": "fix",
394
- "scope": null,
395
- "subject": "add module prop to package.json",
396
- "merge": null,
397
- "header": "fix: add module prop to package.json",
398
- "body": null,
399
- "footer": null,
400
- "notes": [],
401
- "hash": "f0d7718fe0c7ec5a3f0bbab23e8a981cac112488",
402
- "gitTags": "",
403
- "committerDate": "2020-03-30 13:02:17 +0100",
404
- "isTagged": true,
405
- "tag": "@pie-lib/math-evaluator@0.6.9"
406
- },
407
- {
408
- "type": "fix",
409
- "scope": "math-evaluator",
410
- "subject": "support `x^(1/y) == sqrt(x,y)` PD-3",
411
- "merge": null,
412
- "header": "fix(math-evaluator): support `x^(1/y) == sqrt(x,y)` PD-3",
413
- "body": "* add a mathjs simplify rule to extend the default ruleset",
414
- "footer": null,
415
- "notes": [],
416
- "hash": "fa148ff4db1703f572beefa2d6c929fdc445261a",
417
- "gitTags": "",
418
- "committerDate": "2020-04-15 13:13:15 +0100",
419
- "isTagged": true,
420
- "tag": "@pie-lib/math-evaluator@0.6.21"
421
- },
422
- {
423
- "type": "feat",
424
- "scope": null,
425
- "subject": "major version bump",
426
- "merge": null,
427
- "header": "feat: major version bump",
428
- "body": null,
429
- "footer": "BREAKING CHANGE: The last release should have been breaking - this\nshould trigger a major bump now",
430
- "notes": [
431
- {
432
- "title": "BREAKING CHANGE",
433
- "text": "The last release should have been breaking - this\nshould trigger a major bump now"
434
- }
435
- ],
436
- "hash": "78da9d590c5fe67dab54f3b2668995762634ba79",
437
- "gitTags": " (develop)",
438
- "committerDate": "2020-04-27 12:30:42 +0100",
439
- "isTagged": true,
440
- "tag": "@pie-lib/math-evaluator@2.0.0"
441
- },
442
- {
443
- "type": "feat",
444
- "scope": null,
445
- "subject": "bump mathjs@^7.0.1",
446
- "merge": null,
447
- "header": "feat: bump mathjs@^7.0.1",
448
- "body": null,
449
- "footer": null,
450
- "notes": [],
451
- "hash": "865de4b8be0829cbbd083dfee9afeea0b1559eb2",
452
- "gitTags": " (develop)",
453
- "committerDate": "2020-06-05 12:56:06 +0100",
454
- "isTagged": true,
455
- "tag": "@pie-lib/math-evaluator@2.1.0"
456
- }
457
- ]
1
+ []
package/CHANGELOG.md CHANGED
@@ -3,7 +3,151 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
- ## [2.2.1-beta.0](https://github.com/pie-framework/pie-lib/compare/@pie-lib/math-evaluator@2.1.23...@pie-lib/math-evaluator@2.2.1-beta.0) (2025-07-20)
6
+ # [2.4.0](https://github.com/pie-framework/pie-lib/compare/@pie-lib/math-evaluator@2.1.23...@pie-lib/math-evaluator@2.4.0) (2025-07-31)
7
+
8
+ **Note:** Version bump only for package @pie-lib/math-evaluator
9
+
10
+
11
+
12
+
13
+
14
+ # [2.3.0](https://github.com/pie-framework/pie-lib/compare/@pie-lib/math-evaluator@2.1.23...@pie-lib/math-evaluator@2.3.0) (2025-07-31)
15
+
16
+ **Note:** Version bump only for package @pie-lib/math-evaluator
17
+
18
+
19
+
20
+
21
+
22
+ # [2.2.0-beta.8](https://github.com/pie-framework/pie-lib/compare/@pie-lib/math-evaluator@2.1.23...@pie-lib/math-evaluator@2.2.0-beta.8) (2025-07-25)
23
+
24
+ **Note:** Version bump only for package @pie-lib/math-evaluator
25
+
26
+
27
+
28
+
29
+
30
+ # [2.2.0-beta.7](https://github.com/pie-framework/pie-lib/compare/@pie-lib/math-evaluator@2.1.23...@pie-lib/math-evaluator@2.2.0-beta.7) (2025-07-25)
31
+
32
+ **Note:** Version bump only for package @pie-lib/math-evaluator
33
+
34
+
35
+
36
+
37
+
38
+ # [2.2.0-beta.7](https://github.com/pie-framework/pie-lib/compare/@pie-lib/math-evaluator@2.1.23...@pie-lib/math-evaluator@2.2.0-beta.7) (2025-07-25)
39
+
40
+ **Note:** Version bump only for package @pie-lib/math-evaluator
41
+
42
+
43
+
44
+
45
+
46
+ # [2.2.0-beta.6](https://github.com/pie-framework/pie-lib/compare/@pie-lib/math-evaluator@2.1.23...@pie-lib/math-evaluator@2.2.0-beta.6) (2025-07-25)
47
+
48
+ **Note:** Version bump only for package @pie-lib/math-evaluator
49
+
50
+
51
+
52
+
53
+
54
+ # [2.2.0-beta.6](https://github.com/pie-framework/pie-lib/compare/@pie-lib/math-evaluator@2.1.23...@pie-lib/math-evaluator@2.2.0-beta.6) (2025-07-25)
55
+
56
+ **Note:** Version bump only for package @pie-lib/math-evaluator
57
+
58
+
59
+
60
+
61
+
62
+ # [2.2.0-beta.5](https://github.com/pie-framework/pie-lib/compare/@pie-lib/math-evaluator@2.1.23...@pie-lib/math-evaluator@2.2.0-beta.5) (2025-07-25)
63
+
64
+ **Note:** Version bump only for package @pie-lib/math-evaluator
65
+
66
+
67
+
68
+
69
+
70
+ # [2.2.0-beta.5](https://github.com/pie-framework/pie-lib/compare/@pie-lib/math-evaluator@2.1.23...@pie-lib/math-evaluator@2.2.0-beta.5) (2025-07-25)
71
+
72
+ **Note:** Version bump only for package @pie-lib/math-evaluator
73
+
74
+
75
+
76
+
77
+
78
+ # [2.2.0-beta.4](https://github.com/pie-framework/pie-lib/compare/@pie-lib/math-evaluator@2.1.23...@pie-lib/math-evaluator@2.2.0-beta.4) (2025-07-25)
79
+
80
+ **Note:** Version bump only for package @pie-lib/math-evaluator
81
+
82
+
83
+
84
+
85
+
86
+ # [2.2.0-beta.3](https://github.com/pie-framework/pie-lib/compare/@pie-lib/math-evaluator@2.1.23...@pie-lib/math-evaluator@2.2.0-beta.3) (2025-07-25)
87
+
88
+ **Note:** Version bump only for package @pie-lib/math-evaluator
89
+
90
+
91
+
92
+
93
+
94
+ # [2.2.0-beta.4](https://github.com/pie-framework/pie-lib/compare/@pie-lib/math-evaluator@2.1.23...@pie-lib/math-evaluator@2.2.0-beta.4) (2025-07-23)
95
+
96
+ **Note:** Version bump only for package @pie-lib/math-evaluator
97
+
98
+
99
+
100
+
101
+
102
+ # [2.2.0-beta.3](https://github.com/pie-framework/pie-lib/compare/@pie-lib/math-evaluator@2.1.23...@pie-lib/math-evaluator@2.2.0-beta.3) (2025-07-23)
103
+
104
+ **Note:** Version bump only for package @pie-lib/math-evaluator
105
+
106
+
107
+
108
+
109
+
110
+ # [2.2.0-beta.3](https://github.com/pie-framework/pie-lib/compare/@pie-lib/math-evaluator@2.1.23...@pie-lib/math-evaluator@2.2.0-beta.3) (2025-07-20)
111
+
112
+ **Note:** Version bump only for package @pie-lib/math-evaluator
113
+
114
+
115
+
116
+
117
+
118
+ # [2.2.0-beta.2](https://github.com/pie-framework/pie-lib/compare/@pie-lib/math-evaluator@2.1.23...@pie-lib/math-evaluator@2.2.0-beta.2) (2025-07-20)
119
+
120
+ **Note:** Version bump only for package @pie-lib/math-evaluator
121
+
122
+
123
+
124
+
125
+
126
+ # [2.2.0-beta.1](https://github.com/pie-framework/pie-lib/compare/@pie-lib/math-evaluator@2.1.23...@pie-lib/math-evaluator@2.2.0-beta.1) (2025-07-20)
127
+
128
+ **Note:** Version bump only for package @pie-lib/math-evaluator
129
+
130
+
131
+
132
+
133
+
134
+ # [2.2.0-beta.2](https://github.com/pie-framework/pie-lib/compare/@pie-lib/math-evaluator@2.1.23...@pie-lib/math-evaluator@2.2.0-beta.2) (2025-07-20)
135
+
136
+ **Note:** Version bump only for package @pie-lib/math-evaluator
137
+
138
+
139
+
140
+
141
+
142
+ # [2.2.0-beta.1](https://github.com/pie-framework/pie-lib/compare/@pie-lib/math-evaluator@2.1.23...@pie-lib/math-evaluator@2.2.0-beta.1) (2025-07-20)
143
+
144
+ **Note:** Version bump only for package @pie-lib/math-evaluator
145
+
146
+
147
+
148
+
149
+
150
+ # [2.2.0-beta.1](https://github.com/pie-framework/pie-lib/compare/@pie-lib/math-evaluator@2.1.23...@pie-lib/math-evaluator@2.2.0-beta.1) (2025-07-20)
7
151
 
8
152
  **Note:** Version bump only for package @pie-lib/math-evaluator
9
153
 
package/lib/index.js ADDED
@@ -0,0 +1,189 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+
5
+ var _typeof = require("@babel/runtime/helpers/typeof");
6
+
7
+ Object.defineProperty(exports, "__esModule", {
8
+ value: true
9
+ });
10
+ exports.textToMathText = exports.latexToText = exports["default"] = exports.ave = void 0;
11
+
12
+ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
13
+
14
+ var mathjs = _interopRequireWildcard(require("mathjs"));
15
+
16
+ var _mathExpressions = _interopRequireDefault(require("@pie-framework/math-expressions"));
17
+
18
+ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
19
+
20
+ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
21
+
22
+ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
23
+
24
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { (0, _defineProperty2["default"])(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
25
+
26
+ var decimalCommaRegex = /,/g;
27
+ var decimalRegex = /\.|,/g;
28
+ var decimalWithThousandSeparatorNumberRegex = /^(?!0+\.00)(?=.{1,9}(\.|$))(?!0(?!\.))\d{1,3}(,\d{3})*(\.\d+)?$/;
29
+
30
+ var rationalizeAllPossibleSubNodes = function rationalizeAllPossibleSubNodes(expression) {
31
+ return rationalize(mathjs.parse(expression));
32
+ };
33
+
34
+ var rationalize = function rationalize(tree) {
35
+ var transformedTree = tree.transform(function (node) {
36
+ try {
37
+ var rationalizedNode = mathjs.rationalize(node);
38
+ return rationalizedNode;
39
+ } catch (_unused) {
40
+ return node;
41
+ }
42
+ });
43
+ return transformedTree;
44
+ };
45
+
46
+ function prepareExpression(string, isLatex) {
47
+ var returnValue = string ? string.trim() : '';
48
+ returnValue = returnValue.replace(decimalCommaRegex, '.');
49
+ returnValue = isLatex ? latexToText("".concat(returnValue)) : textToMathText("".concat(returnValue), {
50
+ unknownCommands: 'passthrough'
51
+ }).toString();
52
+ returnValue = returnValue.replace('=', '==');
53
+ return rationalizeAllPossibleSubNodes(returnValue);
54
+ }
55
+
56
+ var latexToAstOpts = {
57
+ missingFactor: function missingFactor(token, e) {
58
+ console.warn('missing factor for: ', token.token_type);
59
+
60
+ if (token.token_type === 'NUMBER') {
61
+ throw e;
62
+ }
63
+
64
+ return 0;
65
+ },
66
+ unknownCommandBehavior: 'passthrough'
67
+ };
68
+ var astToTextOpts = {
69
+ unicode_operators: {
70
+ ne: function ne(operands) {
71
+ return operands.join(' != ');
72
+ },
73
+ '%': function _(operands) {
74
+ return "percent(".concat(operands[0], ")");
75
+ }
76
+ }
77
+ };
78
+
79
+ var latexToText = function latexToText(latex) {
80
+ var extraOtps = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
81
+ var la = new _mathExpressions["default"].converters.latexToAstObj(_objectSpread(_objectSpread({}, latexToAstOpts), extraOtps));
82
+ var at = new _mathExpressions["default"].converters.astToTextObj(_objectSpread(_objectSpread({}, astToTextOpts), extraOtps));
83
+ var ast = la.convert(latex);
84
+ return at.convert(ast);
85
+ };
86
+
87
+ exports.latexToText = latexToText;
88
+
89
+ var textToMathText = function textToMathText(latex) {
90
+ var extraOtps = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
91
+ var la = new _mathExpressions["default"].converters.textToAstObj(_objectSpread(_objectSpread({}, latexToAstOpts), extraOtps));
92
+ var at = new _mathExpressions["default"].converters.astToTextObj(_objectSpread(_objectSpread({}, astToTextOpts), extraOtps));
93
+ var ast = la.convert(latex);
94
+ return at.convert(ast);
95
+ };
96
+
97
+ exports.textToMathText = textToMathText;
98
+
99
+ function shouldRationalizeEntireTree(tree) {
100
+ var shouldDoIt = true; // we need to iterate the entire tree to check for some conditions that might make rationalization impossible
101
+
102
+ try {
103
+ tree.traverse(function (node) {
104
+ // if we have a variable as an exponent for power operation, we should not rationalize
105
+ // try to see if there are power operations with variable exponents
106
+ if (node.type === 'OperatorNode' && node.fn === 'pow') {
107
+ var exponent = node.args[1]; // try to see if it can be compiled and evaluated - if it's a non-numerical value, it'll throw an error
108
+
109
+ exponent.compile().eval();
110
+ } // we cannot have variables for unresolved function calls either
111
+
112
+
113
+ if (node.type === 'FunctionNode') {
114
+ //try to see if the argument that the function is called with can be resolved as non-variable
115
+ var functionParameter = node.args[0]; // if it holds variables, this will throw an error
116
+
117
+ functionParameter.compile().eval();
118
+ }
119
+ });
120
+ mathjs.rationalize(tree);
121
+ } catch (_unused2) {
122
+ shouldDoIt = false;
123
+ }
124
+
125
+ return shouldDoIt;
126
+ }
127
+
128
+ function containsDecimal() {
129
+ var expression = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
130
+ return expression.match(decimalRegex);
131
+ }
132
+
133
+ var SIMPLIFY_RULES = [{
134
+ l: 'n1^(1/n2)',
135
+ r: 'nthRoot(n1, n2)'
136
+ }, {
137
+ l: 'sqrt(n1)',
138
+ r: 'nthRoot(n1, 2)'
139
+ }];
140
+
141
+ var simplify = function simplify(v) {
142
+ return mathjs.simplify(v, SIMPLIFY_RULES.concat(mathjs.simplify.rules));
143
+ }; //.concat(SIMPLIFY_RULES));
144
+
145
+
146
+ var areValuesEqual = function areValuesEqual(valueOne, valueTwo) {
147
+ var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
148
+ var allowDecimals = options.allowDecimals,
149
+ isLatex = options.isLatex,
150
+ inverse = options.inverse;
151
+ var valueOneToUse = valueOne;
152
+ var valueTwoToUse = valueTwo;
153
+
154
+ if (allowDecimals === false) {
155
+ if (containsDecimal(valueOne) || containsDecimal(valueTwo)) {
156
+ return false;
157
+ }
158
+ } else if (allowDecimals === true) {
159
+ if (containsDecimal(valueOne) && decimalWithThousandSeparatorNumberRegex.test(valueOne)) {
160
+ valueOneToUse = valueOne.replace(decimalCommaRegex, '');
161
+ }
162
+
163
+ if (containsDecimal(valueTwo) && decimalWithThousandSeparatorNumberRegex.test(valueTwo)) {
164
+ valueTwoToUse = valueTwo.replace(decimalCommaRegex, '');
165
+ }
166
+ }
167
+
168
+ var preparedValueOne = prepareExpression(valueOneToUse, isLatex, allowDecimals);
169
+ var preparedValueTwo = prepareExpression(valueTwoToUse, isLatex, allowDecimals);
170
+ var one = shouldRationalizeEntireTree(preparedValueOne) ? mathjs.rationalize(preparedValueOne) : preparedValueOne;
171
+ var two = shouldRationalizeEntireTree(preparedValueTwo) ? mathjs.rationalize(preparedValueTwo) : preparedValueTwo;
172
+ one = simplify(one);
173
+ two = simplify(two);
174
+ var equals = one.equals(two);
175
+ return inverse ? !equals : equals;
176
+ };
177
+
178
+ var ave = function ave(a, b) {
179
+ var am = mathjs.parse(a);
180
+ var bm = mathjs.parse(b);
181
+ var arm = simplify(am);
182
+ var brm = simplify(bm);
183
+ return arm.equals(brm);
184
+ };
185
+
186
+ exports.ave = ave;
187
+ var _default = areValuesEqual;
188
+ exports["default"] = _default;
189
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/index.js"],"names":["decimalCommaRegex","decimalRegex","decimalWithThousandSeparatorNumberRegex","rationalizeAllPossibleSubNodes","expression","rationalize","mathjs","parse","tree","transformedTree","transform","node","rationalizedNode","prepareExpression","string","isLatex","returnValue","trim","replace","latexToText","textToMathText","unknownCommands","toString","latexToAstOpts","missingFactor","token","e","console","warn","token_type","unknownCommandBehavior","astToTextOpts","unicode_operators","ne","operands","join","latex","extraOtps","la","me","converters","latexToAstObj","at","astToTextObj","ast","convert","textToAstObj","shouldRationalizeEntireTree","shouldDoIt","traverse","type","fn","exponent","args","compile","eval","functionParameter","containsDecimal","match","SIMPLIFY_RULES","l","r","simplify","v","concat","rules","areValuesEqual","valueOne","valueTwo","options","allowDecimals","inverse","valueOneToUse","valueTwoToUse","test","preparedValueOne","preparedValueTwo","one","two","equals","ave","a","b","am","bm","arm","brm"],"mappings":";;;;;;;;;;;;;AACA;;AACA;;;;;;;;;;AAEA,IAAMA,iBAAiB,GAAG,IAA1B;AACA,IAAMC,YAAY,GAAG,OAArB;AACA,IAAMC,uCAAuC,GAAG,iEAAhD;;AAEA,IAAMC,8BAA8B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BAAD,CAA3B,GAAgDtE,MAAM,CAACD,WAAP,CAAmBuE,gBAAnB,CAAhD,GAAuFA,gBAAjG;AAEAC,EAAAA,GAAG,GAAGf,QAAQ,CAACe,GAAD,CAAd;AACAC,EAAAA,GAAG,GAAGhB,QAAQ,CAACgB,GAAD,CAAd;AAEA,MAAMC,MAAM,GAAGF,GAAG,CAACE,MAAJ,CAAWD,GAAX,CAAf;AAEA,SAAOP,OAAO,GAAG,CAACQ,MAAJ,GAAaA,MAA3B;AACD,CAtCD;;AAwCO,IAAMC,GAAG,GAAG,SAANA,GAAM,CAACC,CAAD,EAAIC,CAAJ,EAAU;AAC3B,MAAMC,EAAE,GAAG7E,MAAM,CAACC,KAAP,CAAa0E,CAAb,CAAX;AACA,MAAMG,EAAE,GAAG9E,MAAM,CAACC,KAAP,CAAa2E,CAAb,CAAX;AAEA,MAAMG,GAAG,GAAGvB,QAAQ,CAACqB,EAAD,CAApB;AACA,MAAMG,GAAG,GAAGxB,QAAQ,CAACsB,EAAD,CAApB;AACA,SAAOC,GAAG,CAACN,MAAJ,CAAWO,GAAX,CAAP;AACD,CAPM;;;eASQpB,c","sourcesContent":["/* eslint-disable no-console */\nimport * as mathjs from 'mathjs';\nimport me from '@pie-framework/math-expressions';\n\nconst decimalCommaRegex = /,/g;\nconst decimalRegex = /\\.|,/g;\nconst decimalWithThousandSeparatorNumberRegex = /^(?!0+\\.00)(?=.{1,9}(\\.|$))(?!0(?!\\.))\\d{1,3}(,\\d{3})*(\\.\\d+)?$/;\n\nconst rationalizeAllPossibleSubNodes = (expression) => rationalize(mathjs.parse(expression));\nconst rationalize = (tree) => {\n const transformedTree = tree.transform((node) => {\n try {\n const rationalizedNode = mathjs.rationalize(node);\n return rationalizedNode;\n } catch {\n return node;\n }\n });\n return transformedTree;\n};\n\nfunction prepareExpression(string, isLatex) {\n let returnValue = string ? string.trim() : '';\n\n returnValue = returnValue.replace(decimalCommaRegex, '.');\n\n returnValue = isLatex\n ? latexToText(`${returnValue}`)\n : textToMathText(`${returnValue}`, { unknownCommands: 'passthrough' }).toString();\n\n returnValue = returnValue.replace('=', '==');\n return rationalizeAllPossibleSubNodes(returnValue);\n}\n\nconst latexToAstOpts = {\n missingFactor: (token, e) => {\n console.warn('missing factor for: ', token.token_type);\n if (token.token_type === 'NUMBER') {\n throw e;\n }\n return 0;\n },\n unknownCommandBehavior: 'passthrough',\n};\n\nconst astToTextOpts = {\n unicode_operators: {\n ne: function(operands) {\n return operands.join(' != ');\n },\n '%': function(operands) {\n return `percent(${operands[0]})`;\n },\n },\n};\n\nexport const latexToText = (latex, extraOtps = {}) => {\n const la = new me.converters.latexToAstObj({ ...latexToAstOpts, ...extraOtps });\n\n const at = new me.converters.astToTextObj({ ...astToTextOpts, ...extraOtps });\n\n const ast = la.convert(latex);\n\n return at.convert(ast);\n};\n\nexport const textToMathText = (latex, extraOtps = {}) => {\n const la = new me.converters.textToAstObj({ ...latexToAstOpts, ...extraOtps });\n\n const at = new me.converters.astToTextObj({ ...astToTextOpts, ...extraOtps });\n\n const ast = la.convert(latex);\n\n return at.convert(ast);\n};\n\nfunction shouldRationalizeEntireTree(tree) {\n let shouldDoIt = true;\n\n // we need to iterate the entire tree to check for some conditions that might make rationalization impossible\n try {\n tree.traverse((node) => {\n // if we have a variable as an exponent for power operation, we should not rationalize\n // try to see if there are power operations with variable exponents\n if (node.type === 'OperatorNode' && node.fn === 'pow') {\n const exponent = node.args[1];\n\n // try to see if it can be compiled and evaluated - if it's a non-numerical value, it'll throw an error\n exponent.compile().eval();\n }\n\n // we cannot have variables for unresolved function calls either\n if (node.type === 'FunctionNode') {\n //try to see if the argument that the function is called with can be resolved as non-variable\n const functionParameter = node.args[0];\n\n // if it holds variables, this will throw an error\n functionParameter.compile().eval();\n }\n });\n\n mathjs.rationalize(tree);\n } catch {\n shouldDoIt = false;\n }\n\n return shouldDoIt;\n}\n\nfunction containsDecimal(expression = '') {\n return expression.match(decimalRegex);\n}\nconst SIMPLIFY_RULES = [\n { l: 'n1^(1/n2)', r: 'nthRoot(n1, n2)' },\n { l: 'sqrt(n1)', r: 'nthRoot(n1, 2)' },\n];\n\nconst simplify = (v) => mathjs.simplify(v, SIMPLIFY_RULES.concat(mathjs.simplify.rules)); //.concat(SIMPLIFY_RULES));\n\nconst areValuesEqual = (valueOne, valueTwo, options = {}) => {\n const {\n // if explicitly set to false, having a decimal value in either side will result in a false equality\n // regardless of mathematical correctness\n allowDecimals,\n isLatex, // if the passed in values are latex, they need to be escaped\n inverse, // returns inverse for the comparison result\n } = options;\n\n let valueOneToUse = valueOne;\n let valueTwoToUse = valueTwo;\n\n if (allowDecimals === false) {\n if (containsDecimal(valueOne) || containsDecimal(valueTwo)) {\n return false;\n }\n } else if (allowDecimals === true) {\n if (containsDecimal(valueOne) && decimalWithThousandSeparatorNumberRegex.test(valueOne)) {\n valueOneToUse = valueOne.replace(decimalCommaRegex, '');\n }\n\n if (containsDecimal(valueTwo) && decimalWithThousandSeparatorNumberRegex.test(valueTwo)) {\n valueTwoToUse = valueTwo.replace(decimalCommaRegex, '');\n }\n }\n\n const preparedValueOne = prepareExpression(valueOneToUse, isLatex, allowDecimals);\n const preparedValueTwo = prepareExpression(valueTwoToUse, isLatex, allowDecimals);\n\n let one = shouldRationalizeEntireTree(preparedValueOne) ? mathjs.rationalize(preparedValueOne) : preparedValueOne;\n let two = shouldRationalizeEntireTree(preparedValueTwo) ? mathjs.rationalize(preparedValueTwo) : preparedValueTwo;\n\n one = simplify(one);\n two = simplify(two);\n\n const equals = one.equals(two);\n\n return inverse ? !equals : equals;\n};\n\nexport const ave = (a, b) => {\n const am = mathjs.parse(a);\n const bm = mathjs.parse(b);\n\n const arm = simplify(am);\n const brm = simplify(bm);\n return arm.equals(brm);\n};\n\nexport default areValuesEqual;\n"],"file":"index.js"}
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "publishConfig": {
4
4
  "access": "public"
5
5
  },
6
- "version": "2.2.1-beta.0",
6
+ "version": "2.4.0",
7
7
  "description": "Math evaluator tool for comparing expressions for equality",
8
8
  "keywords": [
9
9
  "math",
@@ -23,8 +23,8 @@
23
23
  "mathjs": "^7.0.1"
24
24
  },
25
25
  "devDependencies": {
26
- "@pie-lib/test-utils": "^0.3.1-beta.0"
26
+ "@pie-lib/test-utils": "beta"
27
27
  },
28
28
  "scripts": {},
29
- "gitHead": "e2aa3ddac60f49bcb8c2562370f496323642f453"
29
+ "gitHead": "ecb1ca31aa1c24d23af00d5ad04ce73ed8871057"
30
30
  }