@marianmeres/condition-parser 1.5.0 → 1.6.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.
Files changed (2) hide show
  1. package/dist/parser.js +15 -0
  2. package/package.json +2 -2
package/dist/parser.js CHANGED
@@ -158,13 +158,28 @@ export class ConditionParser {
158
158
  this.#consumeWhitespace();
159
159
  const remaining = this.#input.slice(this.#pos);
160
160
  let result = null;
161
+ const _isNotAhead = (s) => /\s*not\s+/i.exec(s);
161
162
  if (/^and /i.test(remaining)) {
162
163
  this.#pos += 4;
163
164
  result = "and";
165
+ // maybe followed by "not"?
166
+ const notIsAheadMatch = _isNotAhead(remaining);
167
+ if (notIsAheadMatch) {
168
+ // minus 1, because the initial test includes single trailing whitespace
169
+ this.#pos += notIsAheadMatch[0].length - 1;
170
+ result = "andNot";
171
+ }
164
172
  }
165
173
  else if (/^or /i.test(remaining)) {
166
174
  this.#pos += 3;
167
175
  result = "or";
176
+ // maybe followed by "not"?
177
+ const notIsAheadMatch = _isNotAhead(remaining);
178
+ if (notIsAheadMatch) {
179
+ // minus 1, because the initial test includes single trailing whitespace
180
+ this.#pos += notIsAheadMatch[0].length - 1;
181
+ result = "orNot";
182
+ }
168
183
  }
169
184
  else if (openingParenthesesLevel !== undefined) {
170
185
  const preLevel = openingParenthesesLevel;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@marianmeres/condition-parser",
3
- "version": "1.5.0",
3
+ "version": "1.6.0",
4
4
  "type": "module",
5
5
  "main": "dist/mod.js",
6
6
  "types": "dist/mod.d.ts",
@@ -14,6 +14,6 @@
14
14
  "url": "https://github.com/marianmeres/condition-parser/issues"
15
15
  },
16
16
  "dependencies": {
17
- "@marianmeres/condition-builder": "^1.8.0"
17
+ "@marianmeres/condition-builder": "^1.9.0"
18
18
  }
19
19
  }