@briza/illogical 1.7.1 → 1.7.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/changelog.md CHANGED
@@ -1,5 +1,13 @@
1
1
  # illogical changelog
2
2
 
3
+ ## 1.7.3
4
+
5
+ - Updating tsconfig and other dependencies.
6
+
7
+ ## 1.7.2
8
+
9
+ - Resolving performance issues on simplify and removing unnecessary unsafeSimplify.
10
+
3
11
  ## 1.7.1
4
12
 
5
13
  - Adding Reference cache and other performance improvements to condition parsing.
@@ -90,15 +90,9 @@ function areAllResults(values) {
90
90
  * @param {Result[]} results results or evaluables
91
91
  * @returns {boolean} type guard
92
92
  */
93
- function areAllNumbers$1(results) {
93
+ function areAllNumbers(results) {
94
94
  return results.every(isNumber);
95
95
  }
96
- function isUndefined(value) {
97
- return value === undefined;
98
- }
99
- function isNull(value) {
100
- return value === null;
101
- }
102
96
 
103
97
  /**
104
98
  * Valid types for context members
@@ -156,7 +150,7 @@ class Arithmetic {
156
150
  if (presentValues.length !== results.length) {
157
151
  return false;
158
152
  }
159
- if (!areAllNumbers$1(presentValues)) {
153
+ if (!areAllNumbers(presentValues)) {
160
154
  throw new Error(`operands must be numbers for ${this.constructor.name}`);
161
155
  }
162
156
  return presentValues;
@@ -598,6 +592,9 @@ class Reference extends Operand {
598
592
  evaluate(ctx) {
599
593
  return this.toDataType(this.valueLookup(ctx));
600
594
  }
595
+ checkStrictAndOptional(key, strictKeys, optionalKeys) {
596
+ return strictKeys !== undefined && (Array.isArray(strictKeys) ? strictKeys.includes(key) : strictKeys.has(key)) || optionalKeys !== undefined && (Array.isArray(optionalKeys) ? !optionalKeys.includes(key) : !optionalKeys.has(key)) ? undefined : this;
597
+ }
601
598
 
602
599
  /**
603
600
  * {@link Evaluable.simplify}
@@ -611,7 +608,7 @@ class Reference extends Operand {
611
608
  if (!key || typeof key === 'number') {
612
609
  return this;
613
610
  }
614
- return strictKeys && strictKeys.includes(key) || optionalKeys && !optionalKeys.includes(key) ? undefined : this;
611
+ return this.checkStrictAndOptional(key, strictKeys, optionalKeys);
615
612
  }
616
613
 
617
614
  /**
@@ -1954,516 +1951,6 @@ class Parser {
1954
1951
  }
1955
1952
  }
1956
1953
 
1957
- const isTrueResult = value => value === true;
1958
- const isFalseResult = value => value === false;
1959
- const isNonFalseResult = operand => operand !== false && !isEvaluable(operand);
1960
- const isNonTrueResult = operand => operand !== true && !isEvaluable(operand);
1961
- const resultToInputInternal = value => {
1962
- if (isUndefined(value)) {
1963
- return undefined;
1964
- }
1965
- if (Array.isArray(value)) {
1966
- return undefined;
1967
- }
1968
- return value;
1969
- };
1970
- const resultToInput = value => {
1971
- if (isUndefined(value)) {
1972
- return undefined;
1973
- }
1974
- if (Array.isArray(value)) {
1975
- const definedValues = value.map(resultToInputInternal).filter(val => !isUndefined(val));
1976
- if (definedValues.length === 0) {
1977
- return undefined;
1978
- }
1979
- return definedValues;
1980
- }
1981
- return value;
1982
- };
1983
- const areAllNumbers = results => {
1984
- return results.every(isNumber);
1985
- };
1986
- const areAllInputs = values => values.every(value => !isEvaluable(value));
1987
- const getInputValues = results => {
1988
- const presentValues = results.filter(result => !isNull(result) && !isUndefined(result));
1989
- // If we have missing context values the result or we still have refences
1990
- // simplify to false.
1991
- if (presentValues.length !== results.length || !areAllNumbers(presentValues)) {
1992
- return false;
1993
- }
1994
- return presentValues;
1995
- };
1996
- const extractValues = input => {
1997
- const evaluable = isEvaluable(input);
1998
- if (!evaluable) {
1999
- return Array.isArray(input) ? input : [input];
2000
- }
2001
- if (input instanceof Collection) {
2002
- const results = input.getItems();
2003
- const values = results.map(item => item instanceof Value ? item.evaluate() : null).filter(value => !isNull(value));
2004
- return values;
2005
- }
2006
- return [];
2007
- };
2008
-
2009
- const simplifyAnd = simplifyInput => input => {
2010
- const [operator, ...operands] = input;
2011
- const simplifiedOperands = [];
2012
- for (const operand of operands) {
2013
- const simplification = simplifyInput(operand);
2014
- if (isUndefined(simplification) || isBoolean(simplification) && !isTrueResult(simplification)) {
2015
- // Short-circuit for AND
2016
- return false;
2017
- }
2018
- simplifiedOperands.push(simplification);
2019
- }
2020
-
2021
- // Remove false operands leaving only the Inputs
2022
- const simplified = simplifiedOperands.filter(isNonTrueResult);
2023
- if (simplified.length === 0) {
2024
- return true;
2025
- }
2026
- if (simplified.length === 1) {
2027
- return simplified[0];
2028
- }
2029
- return [operator, ...simplified];
2030
- };
2031
-
2032
- const simplify$3 = (simplifyInput, predicate) => input => {
2033
- const [, ...operands] = input;
2034
- const results = operands.map(simplifyInput);
2035
- if (areAllInputs(results)) {
2036
- const presentValues = getInputValues(results);
2037
- if (isFalseResult(presentValues)) {
2038
- return false;
2039
- }
2040
- return presentValues.reduce(predicate);
2041
- }
2042
- return input;
2043
- };
2044
- const simplifySum = simplifyInput => input => simplify$3(simplifyInput, operateWithExpectedDecimals('sum'))(input);
2045
- const simplifySubtract = simplifyInput => input => simplify$3(simplifyInput, operateWithExpectedDecimals('subtract'))(input);
2046
- const simplifyMultiply = simplifyInput => input => simplify$3(simplifyInput, operateWithExpectedDecimals('multiply'))(input);
2047
- const simplifyDivide = simplifyInput => input => simplify$3(simplifyInput, (acc, result) => acc / result)(input);
2048
-
2049
- const simplifyComparison = predicate => (opts, simplifyInput) => input => {
2050
- const [operator, ...operands] = input;
2051
- const [left, right] = operands;
2052
- const leftSimplified = simplifyInput(left);
2053
- const rightSimplified = simplifyInput(right);
2054
- const isLeftEvaluable = isEvaluable(leftSimplified);
2055
- const isRightEvaluable = isEvaluable(rightSimplified);
2056
- if (isLeftEvaluable || isRightEvaluable) {
2057
- // If either left or right is an array, we cannot simplify further
2058
- return [operator, isLeftEvaluable ? leftSimplified.serialize(opts) : left, isRightEvaluable ? rightSimplified.serialize(opts) : right];
2059
- }
2060
- if (isNumber(leftSimplified) && isNumber(rightSimplified)) {
2061
- return predicate(leftSimplified, rightSimplified);
2062
- }
2063
- const leftDate = toDateNumber(leftSimplified);
2064
- const rightDate = toDateNumber(rightSimplified);
2065
- if (leftDate && rightDate) {
2066
- return predicate(leftDate, rightDate);
2067
- }
2068
- if (Array.isArray(leftSimplified) || Array.isArray(rightSimplified)) {
2069
- return [operator, leftSimplified, rightSimplified];
2070
- }
2071
- return false;
2072
- };
2073
- const simplifyGt = (opts, simplifyInput) => input => simplifyComparison((left, right) => left > right)(opts, simplifyInput)(input);
2074
- const simplifyGe = (opts, simplifyInput) => input => simplifyComparison((left, right) => left >= right)(opts, simplifyInput)(input);
2075
- const simplifyLt = (opts, simplifyInput) => input => simplifyComparison((left, right) => left < right)(opts, simplifyInput)(input);
2076
- const simplifyLe = (opts, simplifyInput) => input => simplifyComparison((left, right) => left <= right)(opts, simplifyInput)(input);
2077
-
2078
- const simplifyEquality = predicate => (opts, simplifyInput) => input => {
2079
- const [operator, ...operands] = input;
2080
- const [left, right] = operands;
2081
- const leftSimplified = simplifyInput(left);
2082
- const rightSimplified = simplifyInput(right);
2083
- const isLeftEvaluable = isEvaluable(leftSimplified);
2084
- const isRightEvaluable = isEvaluable(rightSimplified);
2085
- if (isLeftEvaluable || isRightEvaluable) {
2086
- // If either left or right is an array, we cannot simplify further
2087
- return [operator, isLeftEvaluable ? leftSimplified.serialize(opts) : left, isRightEvaluable ? rightSimplified.serialize(opts) : right];
2088
- }
2089
-
2090
- // See Equal.comparison
2091
- return predicate(leftSimplified, rightSimplified);
2092
- };
2093
- const simplifyEq = (opts, simplifyInput) => input => simplifyEquality((left, right) => left === right)(opts, simplifyInput)(input);
2094
- const simplifyNe = (opts, simplifyInput) => input => simplifyEquality((left, right) => left !== right)(opts, simplifyInput)(input);
2095
-
2096
- const simplify$2 = (originalInput, nonArrayInput, arrayInput) => {
2097
- // If we don't have the non-array operand, there is nothing to do.
2098
- if (isEvaluable(nonArrayInput)) {
2099
- return originalInput;
2100
- }
2101
-
2102
- // If we don't have all the values, try with what we have for the
2103
- // positive case, but otherwise return the original input.
2104
- if (isEvaluable(arrayInput)) {
2105
- const leftValues = extractValues(arrayInput);
2106
- const isFound = leftValues.indexOf(nonArrayInput) > -1;
2107
- return isFound ? true : originalInput;
2108
- }
2109
-
2110
- // If we have all the values, we can check if the non-array operand is
2111
- // included in the array operand.
2112
- return arrayInput.indexOf(nonArrayInput) > -1;
2113
- };
2114
- const simplifyIn = simplifyInput => input => {
2115
- const [, ...operands] = input;
2116
- const [left, right] = operands;
2117
- if (isNull(left) || isUndefined(left) || isNull(right) || isUndefined(right)) {
2118
- return false;
2119
- }
2120
- const leftSimplified = simplifyInput(left);
2121
- const rightSimplified = simplifyInput(right);
2122
- const isLeftArray = Array.isArray(leftSimplified) || isEvaluable(leftSimplified);
2123
- const isRightArray = Array.isArray(rightSimplified) || isEvaluable(rightSimplified);
2124
- if (isLeftArray) {
2125
- return simplify$2(input, rightSimplified, leftSimplified);
2126
- }
2127
- if (isRightArray) {
2128
- return simplify$2(input, leftSimplified, rightSimplified);
2129
- }
2130
- return false;
2131
- };
2132
-
2133
- const simplifyNor = (opts, simplifyInput) => input => {
2134
- const [operator, ...operands] = input;
2135
- const simplifiedOperands = [];
2136
- for (const operand of operands) {
2137
- const simplification = simplifyInput(operand);
2138
- if (isUndefined(simplification) || isBoolean(simplification) && isTrueResult(simplification)) {
2139
- // Short-circuit for AND
2140
- return false;
2141
- }
2142
- simplifiedOperands.push(simplification);
2143
- }
2144
-
2145
- // Remove true operands leaving only the Inputs
2146
- const simplified = simplifiedOperands.filter(isNonFalseResult);
2147
- if (simplified.length === 0) {
2148
- return true;
2149
- }
2150
- if (simplified.length === 1) {
2151
- var _opts$operatorMapping;
2152
- return [(_opts$operatorMapping = opts.operatorMapping.get(OPERATOR$3)) !== null && _opts$operatorMapping !== void 0 ? _opts$operatorMapping : 'NOT', simplified[0]];
2153
- }
2154
- return [operator, ...simplified];
2155
- };
2156
-
2157
- const simplifyNot = simplifyInput => input => {
2158
- const [, ...operands] = input;
2159
- const simplification = simplifyInput(operands[0]);
2160
- if (isBoolean(simplification)) {
2161
- return !simplification;
2162
- }
2163
- return input;
2164
- };
2165
-
2166
- const simplifyNotIn = simplifyInput => input => {
2167
- const [, ...operands] = input;
2168
- const [left, right] = operands;
2169
- const leftArray = Array.isArray(left);
2170
- const rightArray = Array.isArray(right);
2171
- if (isNull(left) || isUndefined(left) || isNull(right) || isUndefined(right) || leftArray && rightArray || !leftArray && !rightArray) {
2172
- return true;
2173
- }
2174
- if (leftArray) {
2175
- // If any operand is still an Evaluable, we cannot simplify further
2176
- const rightSimplified = simplifyInput(right);
2177
- if (isEvaluable(rightSimplified)) {
2178
- return input;
2179
- }
2180
- const leftSimplified = left.map(simplifyInput);
2181
- if (leftSimplified.some(isEvaluable)) {
2182
- return input;
2183
- }
2184
- return leftSimplified.indexOf(rightSimplified) === -1;
2185
- }
2186
- if (rightArray) {
2187
- const leftSimplified = simplifyInput(left);
2188
- if (isEvaluable(leftSimplified)) {
2189
- return input;
2190
- }
2191
- const rightSimplified = right.map(simplifyInput);
2192
- if (rightSimplified.some(isEvaluable)) {
2193
- return input;
2194
- }
2195
- return rightSimplified.indexOf(leftSimplified) === -1;
2196
- }
2197
- return input;
2198
- };
2199
-
2200
- const simplifyOr = simplifyInput => input => {
2201
- const [operator, ...operands] = input;
2202
- const simplifiedOperands = [];
2203
- for (const operand of operands) {
2204
- const simplification = simplifyInput(operand);
2205
- if (isBoolean(simplification) && isTrueResult(simplification)) {
2206
- // Short-circuit for OR
2207
- return true;
2208
- } else if (simplification) {
2209
- simplifiedOperands.push(simplification);
2210
- }
2211
- }
2212
- const simplified = simplifiedOperands.filter(isNonFalseResult);
2213
- if (simplified.length === 0) {
2214
- return false;
2215
- }
2216
- if (simplified.length === 1) {
2217
- return simplified[0];
2218
- }
2219
- return [operator, ...simplified];
2220
- };
2221
-
2222
- const simplifyOverlap = simplifyInput => input => {
2223
- const [, ...operands] = input;
2224
- const [left, right] = operands;
2225
- const leftSimplified = simplifyInput(left);
2226
- const rightSimplified = simplifyInput(right);
2227
- const isLeftEvaluable = isEvaluable(leftSimplified);
2228
- const isRightEvaluable = isEvaluable(rightSimplified);
2229
-
2230
- // If we don't have all operands simplified, we can try the positive case
2231
- // of the values we have satisfying the OVERLAP. But if not, we need to
2232
- // return the original input.
2233
- if (isLeftEvaluable || isRightEvaluable) {
2234
- const leftValues = extractValues(leftSimplified);
2235
- const rightValues = extractValues(rightSimplified);
2236
- const rightSet = new Set(rightValues);
2237
- const res = leftValues.some(element => rightSet.has(element));
2238
- if (res) {
2239
- return true;
2240
- }
2241
- return input;
2242
- }
2243
-
2244
- // If simplified results are not arrays, it means we had a strictKey
2245
- // without values provided. Simplify to false.
2246
- if (!Array.isArray(leftSimplified) || !Array.isArray(rightSimplified)) {
2247
- return false;
2248
- }
2249
- const rightSet = new Set(rightSimplified);
2250
- const res = leftSimplified.some(element => rightSet.has(element));
2251
- if (res) {
2252
- return true;
2253
- }
2254
- return false;
2255
- };
2256
-
2257
- const simplify$1 = (opts, simplifyInput, startsWith = true) => input => {
2258
- const [operator, ...operands] = input;
2259
- const [left, right] = operands;
2260
- const leftSimplified = simplifyInput(left);
2261
- const rightSimplified = simplifyInput(right);
2262
- const isLeftEvaluable = isEvaluable(leftSimplified);
2263
- const isRightEvaluable = isEvaluable(rightSimplified);
2264
- if (isLeftEvaluable || isRightEvaluable) {
2265
- // If either left or right is an array, we cannot simplify further
2266
- return [operator, isLeftEvaluable ? leftSimplified.serialize(opts) : left, isRightEvaluable ? rightSimplified.serialize(opts) : right];
2267
- }
2268
- if (isString(leftSimplified) && isString(rightSimplified)) {
2269
- return startsWith ? rightSimplified.startsWith(leftSimplified) : leftSimplified.endsWith(rightSimplified);
2270
- }
2271
- return false;
2272
- };
2273
- const simplifyPrefix = (opts, simplifyInput) => input => simplify$1(opts, simplifyInput)(input);
2274
- const simplifySuffix = (opts, simplifyInput) => input => simplify$1(opts, simplifyInput, false)(input);
2275
-
2276
- const simplify = (simplifyInput, predicate, present = true) => input => {
2277
- const [, ...operands] = input;
2278
- const [operand] = operands;
2279
- const simplified = simplifyInput(operand);
2280
- const isOperandEvaluable = isEvaluable(simplified);
2281
- if (isOperandEvaluable) {
2282
- return input;
2283
- }
2284
-
2285
- // Operand simplifies to itself when it is included in strictKeys or
2286
- // optionalKeys, thus it was undefined.
2287
- if (operand === simplified) {
2288
- return !present;
2289
- }
2290
- return predicate(simplified);
2291
- };
2292
- const simplifyPresent = simplifyInput => input => simplify(simplifyInput, input => !isUndefined(input) && !isNull(input))(input);
2293
- const simplifyUndefined = simplifyInput => input => simplify(simplifyInput, isUndefined, false)(input);
2294
-
2295
- const simplifyXor = (opts, simplifyInput) => input => {
2296
- const [operator, ...operands] = input;
2297
- let trueCount = 0;
2298
- const simplifiedOperands = [];
2299
- for (const operand of operands) {
2300
- const simplification = simplifyInput(operand);
2301
- if (isBoolean(simplification) && isTrueResult(simplification)) {
2302
- trueCount++;
2303
- continue;
2304
- }
2305
- if (isBoolean(simplification) && isFalseResult(simplification)) {
2306
- continue;
2307
- }
2308
- if (!isEvaluable(simplification)) {
2309
- simplifiedOperands.push(simplification);
2310
- }
2311
- }
2312
- if (trueCount > 1) {
2313
- return false;
2314
- }
2315
- if (simplifiedOperands.length === 0) {
2316
- return trueCount === 1;
2317
- }
2318
- if (simplifiedOperands.length === 1) {
2319
- if (trueCount === 1) {
2320
- var _opts$operatorMapping;
2321
- return [(_opts$operatorMapping = opts.operatorMapping.get(OPERATOR$3)) !== null && _opts$operatorMapping !== void 0 ? _opts$operatorMapping : 'NOT', simplifiedOperands[0]];
2322
- }
2323
- return simplifiedOperands[0];
2324
- }
2325
- if (trueCount === 1) {
2326
- var _opts$operatorMapping2;
2327
- return [(_opts$operatorMapping2 = opts.operatorMapping.get(OPERATOR$2)) !== null && _opts$operatorMapping2 !== void 0 ? _opts$operatorMapping2 : 'NOR', ...simplifiedOperands];
2328
- }
2329
- return [operator, ...simplifiedOperands];
2330
- };
2331
-
2332
- const unsafeSimplify = (context, opts, strictKeys, optionalKeys) => {
2333
- const simplifyInput = input => {
2334
- // Value or Reference
2335
- if (!Array.isArray(input)) {
2336
- // Reference
2337
- if (isString(input) && opts.referencePredicate(input)) {
2338
- const result = new Reference(opts.referenceTransform(input)).simplify(context, strictKeys, optionalKeys);
2339
- if (isEvaluable(result)) {
2340
- return result;
2341
- }
2342
- const inputResult = resultToInput(result);
2343
- if (!isUndefined(inputResult)) {
2344
- return inputResult;
2345
- }
2346
- // It should have been a boolean or an Evaluable, but just in case
2347
- // fallback to returning the input.
2348
- }
2349
- // Value
2350
- return input;
2351
- }
2352
- const [operator] = input;
2353
- switch (operator) {
2354
- // Logical operators
2355
- case opts.operatorMapping.get(OPERATOR$4):
2356
- {
2357
- return simplifyAnd(simplifyInput)(input);
2358
- }
2359
- case opts.operatorMapping.get(OPERATOR$1):
2360
- {
2361
- return simplifyOr(simplifyInput)(input);
2362
- }
2363
- case opts.operatorMapping.get(OPERATOR$2):
2364
- {
2365
- return simplifyNor(opts, simplifyInput)(input);
2366
- }
2367
- case opts.operatorMapping.get(OPERATOR):
2368
- {
2369
- return simplifyXor(opts, simplifyInput)(input);
2370
- }
2371
- case opts.operatorMapping.get(OPERATOR$3):
2372
- {
2373
- return simplifyNot(simplifyInput)(input);
2374
- }
2375
- // Comparison operators
2376
- case opts.operatorMapping.get(OPERATOR$h):
2377
- {
2378
- return simplifyEq(opts, simplifyInput)(input);
2379
- }
2380
- case opts.operatorMapping.get(OPERATOR$b):
2381
- {
2382
- return simplifyNe(opts, simplifyInput)(input);
2383
- }
2384
- case opts.operatorMapping.get(OPERATOR$f):
2385
- {
2386
- return simplifyGt(opts, simplifyInput)(input);
2387
- }
2388
- case opts.operatorMapping.get(OPERATOR$g):
2389
- {
2390
- return simplifyGe(opts, simplifyInput)(input);
2391
- }
2392
- case opts.operatorMapping.get(OPERATOR$c):
2393
- {
2394
- return simplifyLt(opts, simplifyInput)(input);
2395
- }
2396
- case opts.operatorMapping.get(OPERATOR$d):
2397
- {
2398
- return simplifyLe(opts, simplifyInput)(input);
2399
- }
2400
- case opts.operatorMapping.get(OPERATOR$e):
2401
- {
2402
- return simplifyIn(simplifyInput)(input);
2403
- }
2404
- case opts.operatorMapping.get(OPERATOR$a):
2405
- {
2406
- return simplifyNotIn(simplifyInput)(input);
2407
- }
2408
- case opts.operatorMapping.get(OPERATOR$8):
2409
- {
2410
- return simplifyPrefix(opts, simplifyInput)(input);
2411
- }
2412
- case opts.operatorMapping.get(OPERATOR$6):
2413
- {
2414
- return simplifySuffix(opts, simplifyInput)(input);
2415
- }
2416
- case opts.operatorMapping.get(OPERATOR$9):
2417
- {
2418
- return simplifyOverlap(simplifyInput)(input);
2419
- }
2420
- case opts.operatorMapping.get(OPERATOR$5):
2421
- {
2422
- return simplifyUndefined(simplifyInput)(input);
2423
- }
2424
- case opts.operatorMapping.get(OPERATOR$7):
2425
- {
2426
- return simplifyPresent(simplifyInput)(input);
2427
- }
2428
- // Arithmetic operators
2429
- case opts.operatorMapping.get(OPERATOR$i):
2430
- {
2431
- return simplifySum(simplifyInput)(input);
2432
- }
2433
- case opts.operatorMapping.get(OPERATOR$j):
2434
- {
2435
- return simplifySubtract(simplifyInput)(input);
2436
- }
2437
- case opts.operatorMapping.get(OPERATOR$k):
2438
- {
2439
- return simplifyMultiply(simplifyInput)(input);
2440
- }
2441
- case opts.operatorMapping.get(OPERATOR$l):
2442
- {
2443
- return simplifyDivide(simplifyInput)(input);
2444
- }
2445
- default:
2446
- {
2447
- // Handle as an array of References / Values if no operator matches
2448
- const result = input.map(simplifyInput);
2449
- if (!areAllInputs(result)) {
2450
- return new Collection(result.map(item => {
2451
- if (item instanceof Reference) {
2452
- return item;
2453
- }
2454
- if (!isEvaluable(item)) {
2455
- return new Value(item);
2456
- }
2457
- throw new Error('Unexpected expression found within a collection of values/references');
2458
- }));
2459
- }
2460
- return result;
2461
- }
2462
- }
2463
- };
2464
- return simplifyInput;
2465
- };
2466
-
2467
1954
  const unexpectedResultError = 'non expression or boolean result should be returned';
2468
1955
 
2469
1956
  /**
@@ -2520,10 +2007,12 @@ class Engine {
2520
2007
  *
2521
2008
  * @param {ExpressionInput} exp Raw expression.
2522
2009
  * @param {Context} context Evaluation data context.
2523
- * @param {string[]} strictKeys keys to be considered present even if they are not present in the context
2524
- * @param {string[]} optionalKeys keys to be considered not present unless they are in the context or in
2010
+ * @param {string[] | Set<string>} strictKeys keys to be considered present even if they are not present in the
2011
+ * context. Passing as a Set is recommended for performance reasons.
2012
+ * @param {string[] | Set<string>} optionalKeys keys to be considered not present unless they are in the context or in
2525
2013
  * `strictKeys`; when `strictKeys` is `undefined` and `optionalKeys` is an array, every key that is not in
2526
- * `optionalKeys` is considered to be present and thus will be evaluated
2014
+ * `optionalKeys` is considered to be present and thus will be evaluated. Passing as a Set is recommended for
2015
+ * performance reasons.
2527
2016
  * @returns {Inpunt | boolean}
2528
2017
  */
2529
2018
  simplify(exp, context, strictKeys, optionalKeys) {
@@ -2536,18 +2025,6 @@ class Engine {
2536
2025
  }
2537
2026
  throw new Error(unexpectedResultError);
2538
2027
  }
2539
- unsafeSimplify(exp, context, strictKeys, optionalKeys) {
2540
- const result = unsafeSimplify(context, this.parser.options, strictKeys, optionalKeys)(exp);
2541
- if (isBoolean(result)) {
2542
- return result;
2543
- }
2544
-
2545
- // The unsafe implementation should not expose the Evaluable interface
2546
- if (isEvaluable(result)) {
2547
- throw new Error('Unexpected Evaluable not serialized result');
2548
- }
2549
- return result;
2550
- }
2551
2028
  }
2552
2029
 
2553
2030
  export { OPERATOR$4 as OPERATOR_AND, OPERATOR$l as OPERATOR_DIVIDE, OPERATOR$h as OPERATOR_EQ, OPERATOR$g as OPERATOR_GE, OPERATOR$f as OPERATOR_GT, OPERATOR$e as OPERATOR_IN, OPERATOR$d as OPERATOR_LE, OPERATOR$c as OPERATOR_LT, OPERATOR$k as OPERATOR_MULTIPLY, OPERATOR$b as OPERATOR_NE, OPERATOR$2 as OPERATOR_NOR, OPERATOR$3 as OPERATOR_NOT, OPERATOR$a as OPERATOR_NOT_IN, OPERATOR$1 as OPERATOR_OR, OPERATOR$9 as OPERATOR_OVERLAP, OPERATOR$8 as OPERATOR_PREFIX, OPERATOR$7 as OPERATOR_PRESENT, OPERATOR$j as OPERATOR_SUBTRACT, OPERATOR$6 as OPERATOR_SUFFIX, OPERATOR$i as OPERATOR_SUM, OPERATOR$5 as OPERATOR_UNDEFINED, OPERATOR as OPERATOR_XOR, Engine as default, defaultOptions, isEvaluable };