@dra2020/baseclient 1.0.142 → 1.0.143

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.
@@ -45,6 +45,7 @@ declare class Parser {
45
45
  initFromClauses(clauses: Clause[]): void;
46
46
  convertOpToText(): void;
47
47
  combineParenthetical(): void;
48
+ combineArithmetic(): void;
48
49
  combineUnary(): void;
49
50
  combineColon(): void;
50
51
  combineBinary(tt: TokType): void;
@@ -87,6 +87,26 @@ function tokIsUnary(tt: TokType): boolean
87
87
  case TokType.And: return false;
88
88
  case TokType.Or: return false;
89
89
  case TokType.Colon: return false;
90
+ case TokType.GreaterThan: return false;
91
+ case TokType.GreaterThanEqual: return false;
92
+ case TokType.Equal: return false;
93
+ case TokType.LessThan: return false;
94
+ case TokType.LessThanEqual: return false;
95
+ case TokType.NotEqual: return false;
96
+ }
97
+ }
98
+
99
+ function tokIsArithmetic(tt: TokType): boolean
100
+ {
101
+ switch (tt)
102
+ {
103
+ case TokType.Text: return false;
104
+ case TokType.OpenParen: return false;
105
+ case TokType.CloseParen: return false;
106
+ case TokType.Not: return false;
107
+ case TokType.And: return false;
108
+ case TokType.Or: return false;
109
+ case TokType.Colon: return false;
90
110
  // Nominally binary, but written as "prop: < 3" so appears as unary operator where test is comparative to prop value
91
111
  case TokType.GreaterThan: return true;
92
112
  case TokType.GreaterThanEqual: return true;
@@ -276,6 +296,8 @@ class Parser
276
296
  this.clauses = clauses;
277
297
  this.combineParenthetical();
278
298
  this.convertOpToText();
299
+ this.combineArithmetic();
300
+ this.convertOpToText();
279
301
  this.combineBinary(TokType.Colon);
280
302
  this.convertOpToText();
281
303
  this.combineUnary();
@@ -363,6 +385,23 @@ class Parser
363
385
  }
364
386
  }
365
387
 
388
+ combineArithmetic(): void
389
+ {
390
+ // go backwards to handle not not
391
+ for (let i: number = this.clauses.length-1; i >= 0; i--)
392
+ {
393
+ let c = this.clauses[i];
394
+ if (tokIsArithmetic(c.op.tt))
395
+ {
396
+ let argclause = (i < this.clauses.length-1) ? { op: c.op, operand1: this.clauses[i+1] } : undefined;
397
+ if (argclause)
398
+ this.clauses.splice(i, 2, argclause);
399
+ else
400
+ this.clauses.splice(i, 1);
401
+ }
402
+ }
403
+ }
404
+
366
405
  combineUnary(): void
367
406
  {
368
407
  // go backwards to handle not not
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dra2020/baseclient",
3
- "version": "1.0.142",
3
+ "version": "1.0.143",
4
4
  "description": "Utility functions for Javascript projects.",
5
5
  "main": "dist/baseclient.js",
6
6
  "types": "./dist/all/all.d.ts",