subscript 6.0.2 → 6.0.3
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 +16 -17
- package/package.json +13 -6
package/README.md
CHANGED
|
@@ -1,7 +1,4 @@
|
|
|
1
|
-
# <img alt="subscript" src="/subscript2.svg" height=
|
|
2
|
-
<a href="https://github.com/spectjs/subscript/actions/workflows/node.js.yml"><img src="https://github.com/spectjs/subscript/actions/workflows/node.js.yml/badge.svg"/></a>
|
|
3
|
-
<a href="http://npmjs.org/subscript"><img src="https://img.shields.io/npm/v/subscript?color=indianred"/></a>
|
|
4
|
-
<a href="http://microjs.com/#subscript"><img src="https://img.shields.io/badge/microjs-subscript-blue?color=darkslateblue"/></a>
|
|
1
|
+
# <img alt="subscript" src="/subscript2.svg" height=28/> <!--sub͘<em>script</em>--> <!--<sub>SUB͘<em>SCRIPT</em></sub>--> <a href="https://github.com/spectjs/subscript/actions/workflows/node.js.yml"><img src="https://github.com/spectjs/subscript/actions/workflows/node.js.yml/badge.svg"/></a> <a href="http://npmjs.org/subscript"><img src="https://img.shields.io/npm/v/subscript"/></a> <a href="http://microjs.com/#subscript"><img src="https://img.shields.io/badge/microjs-subscript-blue?color=darkslateblue"/></a>
|
|
5
2
|
|
|
6
3
|
_Subscript_ is micro-language with common syntax subset of C++, JS, Java, Python, Go, Rust etc.<br/>
|
|
7
4
|
|
|
@@ -37,13 +34,13 @@ _Subscript_ has [2kb](https://npmfs.com/package/subscript/6.0.0/subscript.min.js
|
|
|
37
34
|
Default operators are (same as JS precedence order):
|
|
38
35
|
|
|
39
36
|
* `( a, b, c )`
|
|
40
|
-
* `a
|
|
37
|
+
* `a.b`, `a[b]`, `a(b, c)`
|
|
41
38
|
* `a++`, `a--` unary postfix
|
|
42
39
|
* `!a`, `+a`, `-a`, `++a`, `--a` unary prefix
|
|
43
40
|
* `a * b`, `a / b`, `a % b`
|
|
44
41
|
* `a + b`, `a - b`
|
|
45
|
-
* `a << b`, `a
|
|
46
|
-
* `a < b`, `a <= b`, `a
|
|
42
|
+
* `a << b`, `a >> b`, `a >>> b`
|
|
43
|
+
* `a < b`, `a <= b`, `a > b`, `a >= b`
|
|
47
44
|
* `a == b`, `a != b`
|
|
48
45
|
* `a & b`
|
|
49
46
|
* `a ^ b`
|
|
@@ -58,7 +55,7 @@ Default literals:
|
|
|
58
55
|
|
|
59
56
|
Everything else can be extended via `parse.set(token, precedence, operator)` for unary or binary operators (detected by number of arguments in `operator`), or via `parse.set(token, parse, precedence)` for custom tokens.
|
|
60
57
|
|
|
61
|
-
```
|
|
58
|
+
```js
|
|
62
59
|
import script from 'subscript.js'
|
|
63
60
|
|
|
64
61
|
// add ~ unary operator with precedence 15
|
|
@@ -287,12 +284,13 @@ Subscript shows relatively good performance within other evaluators:
|
|
|
287
284
|
Parse 30k times:
|
|
288
285
|
|
|
289
286
|
```
|
|
290
|
-
subscript: ~170 ms
|
|
291
|
-
justin: ~183 ms
|
|
292
|
-
jsep: ~270 ms
|
|
287
|
+
subscript: ~170 ms 🥇
|
|
288
|
+
justin: ~183 ms 🥈
|
|
289
|
+
jsep: ~270 ms 🥉
|
|
293
290
|
mr-parser: ~420 ms
|
|
294
291
|
expr-eval: ~480 ms
|
|
295
292
|
math-parser: ~570 ms
|
|
293
|
+
math-expression-evaluator: ~900ms
|
|
296
294
|
jexl: ~1056 ms
|
|
297
295
|
mathjs: ~1200 ms
|
|
298
296
|
new Function: ~1154 ms
|
|
@@ -300,15 +298,16 @@ new Function: ~1154 ms
|
|
|
300
298
|
|
|
301
299
|
Eval 30k times:
|
|
302
300
|
```
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
301
|
+
new Function: ~7 ms 🥇
|
|
302
|
+
subscript: ~17 ms 🥈
|
|
303
|
+
justin: ~17 ms 🥈
|
|
304
|
+
jsep (expression-eval): ~30 ms 🥉
|
|
305
|
+
math-expression-evaluator: ~50ms
|
|
307
306
|
expr-eval: ~72 ms
|
|
308
|
-
math-parser: -
|
|
309
307
|
jexl: ~110 ms
|
|
310
308
|
mathjs: ~119 ms
|
|
311
|
-
|
|
309
|
+
mr-parser: -
|
|
310
|
+
math-parser: -
|
|
312
311
|
```
|
|
313
312
|
|
|
314
313
|
## Alternatives
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "subscript",
|
|
3
|
-
"version": "6.0.
|
|
4
|
-
"description": "
|
|
3
|
+
"version": "6.0.3",
|
|
4
|
+
"description": "Fast and tiny expression evaluator with common syntax microlanguage.",
|
|
5
5
|
"main": "subscript.js",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"files": [
|
|
@@ -31,11 +31,16 @@
|
|
|
31
31
|
"jexl",
|
|
32
32
|
"jsep",
|
|
33
33
|
"expression",
|
|
34
|
+
"evaluator",
|
|
35
|
+
"parser",
|
|
34
36
|
"evaluation",
|
|
35
37
|
"math",
|
|
36
38
|
"arithmetic",
|
|
37
|
-
"evaluator",
|
|
38
39
|
"justin",
|
|
40
|
+
"eval",
|
|
41
|
+
"math-eval",
|
|
42
|
+
"math-evaluator",
|
|
43
|
+
"calculation",
|
|
39
44
|
"jessie",
|
|
40
45
|
"jessica",
|
|
41
46
|
"eval",
|
|
@@ -43,11 +48,13 @@
|
|
|
43
48
|
"json",
|
|
44
49
|
"calculator",
|
|
45
50
|
"calc",
|
|
46
|
-
"lisp",
|
|
47
|
-
"frisk",
|
|
48
51
|
"math.js",
|
|
52
|
+
"mathjs",
|
|
49
53
|
"math-codegen",
|
|
50
|
-
"math-parser"
|
|
54
|
+
"math-parser",
|
|
55
|
+
"formula",
|
|
56
|
+
"operator",
|
|
57
|
+
"overload"
|
|
51
58
|
],
|
|
52
59
|
"author": "Dmitry Iv.",
|
|
53
60
|
"license": "ISC",
|