@danielsimonjr/mathts-expression 0.8.0 → 0.8.2

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.
Files changed (52) hide show
  1. package/README.md +42 -42
  2. package/dist/index.js +276 -347
  3. package/dist/node/AccessorNode.d.ts +121 -132
  4. package/dist/node/AccessorNode.d.ts.map +1 -1
  5. package/dist/node/ArrayNode.d.ts +25 -30
  6. package/dist/node/ArrayNode.d.ts.map +1 -1
  7. package/dist/node/AssignmentNode.d.ts +19 -32
  8. package/dist/node/AssignmentNode.d.ts.map +1 -1
  9. package/dist/node/BlockNode.d.ts +121 -126
  10. package/dist/node/BlockNode.d.ts.map +1 -1
  11. package/dist/node/ConditionalNode.d.ts +25 -30
  12. package/dist/node/ConditionalNode.d.ts.map +1 -1
  13. package/dist/node/ConstantNode.d.ts +93 -100
  14. package/dist/node/ConstantNode.d.ts.map +1 -1
  15. package/dist/node/FunctionAssignmentNode.d.ts +93 -98
  16. package/dist/node/FunctionAssignmentNode.d.ts.map +1 -1
  17. package/dist/node/FunctionNode.d.ts +32 -43
  18. package/dist/node/FunctionNode.d.ts.map +1 -1
  19. package/dist/node/IndexNode.d.ts +949 -72
  20. package/dist/node/IndexNode.d.ts.map +1 -1
  21. package/dist/node/Node.d.ts +43 -39
  22. package/dist/node/Node.d.ts.map +1 -1
  23. package/dist/node/ObjectNode.d.ts +947 -56
  24. package/dist/node/ObjectNode.d.ts.map +1 -1
  25. package/dist/node/OperatorNode.d.ts +955 -79
  26. package/dist/node/OperatorNode.d.ts.map +1 -1
  27. package/dist/node/ParenthesisNode.d.ts +881 -63
  28. package/dist/node/ParenthesisNode.d.ts.map +1 -1
  29. package/dist/node/RangeNode.d.ts +955 -71
  30. package/dist/node/RangeNode.d.ts.map +1 -1
  31. package/dist/node/RelationalNode.d.ts +947 -61
  32. package/dist/node/RelationalNode.d.ts.map +1 -1
  33. package/dist/node/SymbolNode.d.ts +942 -43
  34. package/dist/node/SymbolNode.d.ts.map +1 -1
  35. package/dist/node/utils/access.d.ts +8 -1
  36. package/dist/node/utils/access.d.ts.map +1 -1
  37. package/dist/node/utils/assign.d.ts +9 -1
  38. package/dist/node/utils/assign.d.ts.map +1 -1
  39. package/dist/node/utils/stringSubset.d.ts +8 -8
  40. package/dist/operators.d.ts +12 -15
  41. package/dist/operators.d.ts.map +1 -1
  42. package/dist/parse.d.ts +2 -0
  43. package/dist/parse.d.ts.map +1 -1
  44. package/dist/transform/utils/dimToZeroBase.d.ts +4 -0
  45. package/dist/transform/utils/dimToZeroBase.d.ts.map +1 -1
  46. package/dist/types.d.ts +8 -0
  47. package/dist/types.d.ts.map +1 -1
  48. package/dist/utils/is.d.ts +275 -3
  49. package/dist/utils/is.d.ts.map +1 -1
  50. package/dist/utils/latex.d.ts +12 -0
  51. package/dist/utils/latex.d.ts.map +1 -1
  52. package/package.json +59 -59
package/README.md CHANGED
@@ -1,42 +1,42 @@
1
- # @danielsimonjr/mathts-expression
2
-
3
- Expression parser & evaluator for [MathTS](https://github.com/danielsimonjr/mathts).
4
-
5
- The expression engine for MathTS: a parser (string → AST), an AST node set, a compiler, and an evaluator. Includes a sandbox (`getSafeProperty` / `getSafeMethod`) for safe property access.
6
-
7
- ## Install
8
-
9
- ```sh
10
- npm install @danielsimonjr/mathts-expression
11
- ```
12
-
13
- ## What it provides
14
-
15
- - `createParse` / `createParserClass` / `createParser` — parse to an AST.
16
- - 16 AST node constructors (`createConstantNode`, `createOperatorNode`, …).
17
- - `compile` / `createEvaluate` / `compileExpression` — evaluate expressions.
18
- - AST serializers on every node: `toString()`, `toTex()` (LaTeX), `toHTML()`, and `toMathML()` (MathML).
19
- - Focused re-exports are also published: `@danielsimonjr/mathts-{parser,ast,evaluator}`.
20
-
21
- ## Serializing an AST
22
-
23
- Every node serializes to several formats. `toMathML()` returns a MathML
24
- **fragment** (like `toTex()` returns a LaTeX fragment, without delimiters);
25
- wrap it in a `<math>` element with `mathMLDocument(node)` to render. MathML is
26
- typeset natively by modern browsers — no external dependencies.
27
-
28
- ```ts
29
- import { mathMLDocument, mathMLError } from '@danielsimonjr/mathts-expression';
30
-
31
- const node = parse('c = 1 / sqrt(eps0 * mu0)'); // parse from the functions package
32
- node.toString(); // 'c = 1 / sqrt(eps0 * mu0)'
33
- node.toTex(); // 'c=\\frac{1}{\\sqrt{ eps0\\cdot mu0}}'
34
- node.toMathML(); // '<mrow><mi>c</mi><mo>=</mo><mfrac>…</mfrac></mrow>'
35
- mathMLDocument(node); // '<math xmlns="…" display="block">…</math>' (renderable)
36
- ```
37
-
38
- `mathMLError(src)` produces a `<math><merror>` element for a parse failure.
39
-
40
- ## License
41
-
42
- MIT (c) Daniel Simon Jr.
1
+ # @danielsimonjr/mathts-expression
2
+
3
+ Expression parser & evaluator for [MathTS](https://github.com/danielsimonjr/mathts).
4
+
5
+ The expression engine for MathTS: a parser (string → AST), an AST node set, a compiler, and an evaluator. Includes a sandbox (`getSafeProperty` / `getSafeMethod`) for safe property access.
6
+
7
+ ## Install
8
+
9
+ ```sh
10
+ npm install @danielsimonjr/mathts-expression
11
+ ```
12
+
13
+ ## What it provides
14
+
15
+ - `createParse` / `createParserClass` / `createParser` — parse to an AST.
16
+ - 16 AST node constructors (`createConstantNode`, `createOperatorNode`, …).
17
+ - `compile` / `createEvaluate` / `compileExpression` — evaluate expressions.
18
+ - AST serializers on every node: `toString()`, `toTex()` (LaTeX), `toHTML()`, and `toMathML()` (MathML).
19
+ - Focused re-exports are also published: `@danielsimonjr/mathts-{parser,ast,evaluator}`.
20
+
21
+ ## Serializing an AST
22
+
23
+ Every node serializes to several formats. `toMathML()` returns a MathML
24
+ **fragment** (like `toTex()` returns a LaTeX fragment, without delimiters);
25
+ wrap it in a `<math>` element with `mathMLDocument(node)` to render. MathML is
26
+ typeset natively by modern browsers — no external dependencies.
27
+
28
+ ```ts
29
+ import { mathMLDocument, mathMLError } from '@danielsimonjr/mathts-expression';
30
+
31
+ const node = parse('c = 1 / sqrt(eps0 * mu0)'); // parse from the functions package
32
+ node.toString(); // 'c = 1 / sqrt(eps0 * mu0)'
33
+ node.toTex(); // 'c=\\frac{1}{\\sqrt{ eps0\\cdot mu0}}'
34
+ node.toMathML(); // '<mrow><mi>c</mi><mo>=</mo><mfrac>…</mfrac></mrow>'
35
+ mathMLDocument(node); // '<math xmlns="…" display="block">…</math>' (renderable)
36
+ ```
37
+
38
+ `mathMLError(src)` produces a `<math><merror>` element for a parse failure.
39
+
40
+ ## License
41
+
42
+ MIT (c) Daniel Simon Jr.