subscript 9.0.0 → 9.0.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 +18 -22
- package/package.json +2 -1
- package/subscript.d.ts +6 -0
package/README.md
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
# sub<em>script</em> <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="https://bundlejs.com/?q=subscript"><img alt="npm bundle size" src="https://img.shields.io/bundlejs/size/subscript"/></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>
|
|
2
2
|
|
|
3
|
-
> _Subscript_ is fast, tiny & extensible
|
|
3
|
+
> _Subscript_ is fast, tiny & extensible parser / evaluator / microlanguage with standard syntax.
|
|
4
4
|
|
|
5
5
|
#### Used for:
|
|
6
6
|
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
* sandboxes, playgrounds, safe eval
|
|
7
|
+
* expressions evaluators, calculators
|
|
8
|
+
* subsets of languages (eg. [jasm](https://github.com/dy/jasm), [justin](#justin))
|
|
9
|
+
* sandboxes, playgrounds, safe eval (eg. [glsl-transpiler](https://github.com/stackgl/glsl-transpiler))
|
|
11
10
|
* custom DSL (eg. [piezo](https://github.com/dy/piezo)) <!-- uneural -->
|
|
12
11
|
* preprocessors (eg. [prepr](https://github.com/dy/prepr))
|
|
12
|
+
* templates (eg. [sprae](https://github.com/dy/sprae))
|
|
13
13
|
|
|
14
14
|
_Subscript_ has [3.5kb](https://npmfs.com/package/subscript/7.4.3/subscript.min.js) footprint (compare to [11.4kb](https://npmfs.com/package/jsep/1.2.0/dist/jsep.min.js) _jsep_ + [4.5kb](https://npmfs.com/package/expression-eval/5.0.0/dist/expression-eval.module.js) _expression-eval_), best [performance](#performance) and extensive test coverage.
|
|
15
15
|
|
|
@@ -104,26 +104,22 @@ const fn = compile(['+', ['*', 'min', [,60]], [,'sec']])
|
|
|
104
104
|
fn({min: 5}) // min*60 + "sec" == "300sec"
|
|
105
105
|
|
|
106
106
|
// node kinds
|
|
107
|
-
['+', a];
|
|
108
|
-
['+', a, b];
|
|
109
|
-
['+', a, b, c];
|
|
110
|
-
['()', a];
|
|
111
|
-
['()', a, b];
|
|
112
|
-
[, a]; // literal value `'a'`
|
|
113
|
-
a;
|
|
114
|
-
null;
|
|
107
|
+
['+', a]; // unary operator `+a`
|
|
108
|
+
['+', a, b]; // binary operator `a + b`
|
|
109
|
+
['+', a, b, c]; // n-ary operator `a + b + c`
|
|
110
|
+
['()', a]; // group operator `(a)`
|
|
111
|
+
['()', a, b]; // access operator `a(b)`
|
|
112
|
+
[, 'a']; // literal value `'a'`
|
|
113
|
+
a; // variable (from scope)
|
|
114
|
+
null|empty; // placeholder
|
|
115
115
|
|
|
116
116
|
// eg.
|
|
117
|
-
['()', 'a']
|
|
118
|
-
['()', 'a'
|
|
117
|
+
['()', 'a'] // (a)
|
|
118
|
+
['()', 'a',,] // a()
|
|
119
|
+
['()', 'a', 'b'] // a(b)
|
|
120
|
+
['+', 'a'] // +a
|
|
121
|
+
['+','a',,] // a+
|
|
119
122
|
```
|
|
120
|
-
<!--
|
|
121
|
-
['()'] // ()
|
|
122
|
-
['()', 'a'] // (a)
|
|
123
|
-
['()', 'a', 'b'] // a(b)
|
|
124
|
-
['+',1] // +1
|
|
125
|
-
['+',1,,] // 1+
|
|
126
|
-
-->
|
|
127
123
|
|
|
128
124
|
### Stringify
|
|
129
125
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "subscript",
|
|
3
|
-
"version": "9.0.
|
|
3
|
+
"version": "9.0.1",
|
|
4
4
|
"description": "Fast and tiny expression evaluator with minimal syntax.",
|
|
5
5
|
"main": "subscript.js",
|
|
6
6
|
"module": "subscript.js",
|
|
@@ -21,6 +21,7 @@
|
|
|
21
21
|
"feature",
|
|
22
22
|
"subscript.js",
|
|
23
23
|
"subscript.min.js",
|
|
24
|
+
"subscript.d.ts",
|
|
24
25
|
"justin.js",
|
|
25
26
|
"justin.min.js"
|
|
26
27
|
],
|