@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.
@@ -35,13 +35,15 @@ export interface Evaluable {
35
35
  * Simplifies this Evaluable when possible.
36
36
  *
37
37
  * @param {Context} ctx context for the evaluation
38
- * @param {string[]} strictKeys keys to be considered present even if they are not present in the context
39
- * @param {string[]} optionalKeys keys to be considered not present unless they are in the context or in
38
+ * @param {string[] | Set<string>} strictKeys keys to be considered present even if they are not present in the
39
+ * context. Passing as a Set is recommended for performance reasons.
40
+ * @param {string[] | Set<string>} optionalKeys keys to be considered not present unless they are in the context or in
40
41
  * `strictKeys`; when `strictKeys` is `undefined` and `optionalKeys` is an array, every key that is not in
41
- * `optionalKeys` is considered to be present and thus will be evaluated
42
+ * `optionalKeys` is considered to be present and thus will be evaluated. Passing as a Set is recommended for
43
+ * performance reasons.
42
44
  * @returns {Result | Evaluable} simplified value or itself
43
45
  */
44
- simplify(ctx: Context, strictKeys?: string[], optionalKeys?: string[]): Result | Evaluable;
46
+ simplify(ctx: Context, strictKeys?: string[] | Set<string>, optionalKeys?: string[] | Set<string>): Result | Evaluable;
45
47
  /**
46
48
  * Serializes the Evaluable to its input format.
47
49
  *
@@ -22,7 +22,7 @@ export declare abstract class Logical implements Evaluable {
22
22
  /**
23
23
  * {@link Evaluable.simplify}
24
24
  */
25
- abstract simplify(ctx: Context, strictKeys?: string[], optionalKeys?: string[]): Result | Evaluable;
25
+ abstract simplify(ctx: Context, strictKeys?: string[] | Set<string>, optionalKeys?: string[] | Set<string>): Result | Evaluable;
26
26
  /**
27
27
  * Get the strict representation of the expression.
28
28
  * @return {string}
package/types/index.d.ts CHANGED
@@ -68,13 +68,14 @@ declare class Engine {
68
68
  *
69
69
  * @param {ExpressionInput} exp Raw expression.
70
70
  * @param {Context} context Evaluation data context.
71
- * @param {string[]} strictKeys keys to be considered present even if they are not present in the context
72
- * @param {string[]} optionalKeys keys to be considered not present unless they are in the context or in
71
+ * @param {string[] | Set<string>} strictKeys keys to be considered present even if they are not present in the
72
+ * context. Passing as a Set is recommended for performance reasons.
73
+ * @param {string[] | Set<string>} optionalKeys keys to be considered not present unless they are in the context or in
73
74
  * `strictKeys`; when `strictKeys` is `undefined` and `optionalKeys` is an array, every key that is not in
74
- * `optionalKeys` is considered to be present and thus will be evaluated
75
+ * `optionalKeys` is considered to be present and thus will be evaluated. Passing as a Set is recommended for
76
+ * performance reasons.
75
77
  * @returns {Inpunt | boolean}
76
78
  */
77
- simplify(exp: ExpressionInput, context: Context, strictKeys?: string[], optionalKeys?: string[]): Input | boolean;
78
- unsafeSimplify(exp: ExpressionInput, context: Context, strictKeys?: string[], optionalKeys?: string[]): Input | boolean;
79
+ simplify(exp: ExpressionInput, context: Context, strictKeys?: string[] | Set<string>, optionalKeys?: string[] | Set<string>): Input | boolean;
79
80
  }
80
81
  export default Engine;
@@ -13,7 +13,7 @@ export declare abstract class Operand implements Evaluable {
13
13
  /**
14
14
  * {@link Evaluable.simplify}
15
15
  */
16
- abstract simplify(ctx: Context, strictKeys?: string[], optionalKeys?: string[]): Result | Evaluable;
16
+ abstract simplify(ctx: Context, strictKeys?: string[] | Set<string>, optionalKeys?: string[] | Set<string>): Result | Evaluable;
17
17
  /**
18
18
  * {@link Evaluable.serialize}
19
19
  */
@@ -24,10 +24,11 @@ export declare class Reference extends Operand {
24
24
  * @return {boolean}
25
25
  */
26
26
  evaluate(ctx: Context): Result;
27
+ private checkStrictAndOptional;
27
28
  /**
28
29
  * {@link Evaluable.simplify}
29
30
  */
30
- simplify(ctx: Context, strictKeys?: string[], optionalKeys?: string[]): Result | Evaluable;
31
+ simplify(ctx: Context, strictKeys?: string[] | Set<string>, optionalKeys?: string[] | Set<string>): Result | Evaluable;
31
32
  /**
32
33
  * {@link Evaluable.serialize}
33
34
  */
@@ -1,4 +1,4 @@
1
1
  import { Context, Evaluable } from '../common/evaluable';
2
2
  import { Input } from '../parser';
3
3
  import { Options } from '../parser/options';
4
- export declare const unsafeSimplify: (context: Context, opts: Options, strictKeys?: string[], optionalKeys?: string[]) => (input: Input) => Input | Evaluable;
4
+ export declare const unsafeSimplify: (context: Context, opts: Options, strictKeys?: Set<string>, optionalKeys?: Set<string>) => (input: Input) => Input | Evaluable;