@briza/illogical 1.4.3 → 1.5.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.
- package/changelog.md +13 -0
- package/lib/illogical.esm.js +82 -176
- package/lib/illogical.js +82 -175
- package/package.json +23 -23
- package/readme.md +21 -7
- package/types/common/evaluable.d.ts +57 -57
- package/types/common/type-check.d.ts +28 -32
- package/types/common/util.d.ts +11 -11
- package/types/expression/comparison/eq.d.ts +18 -22
- package/types/expression/comparison/ge.d.ts +18 -22
- package/types/expression/comparison/gt.d.ts +18 -22
- package/types/expression/comparison/in.d.ts +23 -27
- package/types/expression/comparison/index.d.ts +45 -49
- package/types/expression/comparison/le.d.ts +18 -22
- package/types/expression/comparison/lt.d.ts +18 -22
- package/types/expression/comparison/ne.d.ts +18 -22
- package/types/expression/comparison/not-in.d.ts +23 -27
- package/types/expression/comparison/overlap.d.ts +23 -27
- package/types/expression/comparison/prefix.d.ts +23 -27
- package/types/expression/comparison/present.d.ts +25 -29
- package/types/expression/comparison/suffix.d.ts +23 -27
- package/types/expression/comparison/undefined.d.ts +28 -32
- package/types/expression/logical/and.d.ts +23 -27
- package/types/expression/logical/index.d.ts +32 -36
- package/types/expression/logical/nor.d.ts +23 -27
- package/types/expression/logical/not.d.ts +23 -27
- package/types/expression/logical/or.d.ts +23 -27
- package/types/expression/logical/xor.d.ts +23 -27
- package/types/index.d.ts +73 -71
- package/types/operand/collection.d.ts +36 -40
- package/types/operand/index.d.ts +25 -29
- package/types/operand/reference.d.ts +44 -48
- package/types/operand/value.d.ts +31 -35
- package/types/parser/index.d.ts +39 -43
- package/types/parser/options.d.ts +61 -65
|
@@ -1,27 +1,23 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
export declare
|
|
8
|
-
/**
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
*
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
* @
|
|
21
|
-
*/
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
* {@link Evaluable.simplify}
|
|
25
|
-
*/
|
|
26
|
-
simplify(...args: [Context, string[]]): boolean | Evaluable;
|
|
27
|
-
}
|
|
1
|
+
import { Context, Evaluable, Result, SimplifyArgs } from '../../common/evaluable';
|
|
2
|
+
import { Logical } from '../logical';
|
|
3
|
+
export declare const OPERATOR: unique symbol;
|
|
4
|
+
/**
|
|
5
|
+
* Xor logical expression
|
|
6
|
+
*/
|
|
7
|
+
export declare class Xor extends Logical {
|
|
8
|
+
/**
|
|
9
|
+
* @constructor
|
|
10
|
+
* @param {Evaluable[]} operands Collection of operands.
|
|
11
|
+
*/
|
|
12
|
+
constructor(operands: Evaluable[]);
|
|
13
|
+
/**
|
|
14
|
+
* Evaluate in the given context.
|
|
15
|
+
* @param {Context} ctx
|
|
16
|
+
* @return {Result}
|
|
17
|
+
*/
|
|
18
|
+
evaluate(ctx: Context): Result;
|
|
19
|
+
/**
|
|
20
|
+
* {@link Evaluable.simplify}
|
|
21
|
+
*/
|
|
22
|
+
simplify(...args: SimplifyArgs): boolean | Evaluable;
|
|
23
|
+
}
|
package/types/index.d.ts
CHANGED
|
@@ -1,71 +1,73 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Main module.
|
|
3
|
-
* @module illogical
|
|
4
|
-
*/
|
|
5
|
-
import { Context, Evaluable } from './common/evaluable';
|
|
6
|
-
import { OPERATOR as OPERATOR_EQ } from './expression/comparison/eq';
|
|
7
|
-
import { OPERATOR as OPERATOR_GE } from './expression/comparison/ge';
|
|
8
|
-
import { OPERATOR as OPERATOR_GT } from './expression/comparison/gt';
|
|
9
|
-
import { OPERATOR as OPERATOR_IN } from './expression/comparison/in';
|
|
10
|
-
import { OPERATOR as OPERATOR_LE } from './expression/comparison/le';
|
|
11
|
-
import { OPERATOR as OPERATOR_LT } from './expression/comparison/lt';
|
|
12
|
-
import { OPERATOR as OPERATOR_NE } from './expression/comparison/ne';
|
|
13
|
-
import { OPERATOR as OPERATOR_NOT_IN } from './expression/comparison/not-in';
|
|
14
|
-
import { OPERATOR as OPERATOR_OVERLAP } from './expression/comparison/overlap';
|
|
15
|
-
import { OPERATOR as OPERATOR_PREFIX } from './expression/comparison/prefix';
|
|
16
|
-
import { OPERATOR as OPERATOR_PRESENT } from './expression/comparison/present';
|
|
17
|
-
import { OPERATOR as OPERATOR_SUFFIX } from './expression/comparison/suffix';
|
|
18
|
-
import { OPERATOR as OPERATOR_UNDEFINED } from './expression/comparison/undefined';
|
|
19
|
-
import { OPERATOR as OPERATOR_AND } from './expression/logical/and';
|
|
20
|
-
import { OPERATOR as OPERATOR_NOR } from './expression/logical/nor';
|
|
21
|
-
import { OPERATOR as OPERATOR_NOT } from './expression/logical/not';
|
|
22
|
-
import { OPERATOR as OPERATOR_OR } from './expression/logical/or';
|
|
23
|
-
import { OPERATOR as OPERATOR_XOR } from './expression/logical/xor';
|
|
24
|
-
import { ExpressionInput, Input } from './parser';
|
|
25
|
-
import { Options } from './parser/options';
|
|
26
|
-
export { OPERATOR_EQ, OPERATOR_NE, OPERATOR_GT, OPERATOR_GE, OPERATOR_LT, OPERATOR_LE, OPERATOR_IN, OPERATOR_NOT_IN, OPERATOR_PREFIX, OPERATOR_SUFFIX, OPERATOR_OVERLAP, OPERATOR_UNDEFINED, OPERATOR_PRESENT, OPERATOR_AND, OPERATOR_OR, OPERATOR_NOR, OPERATOR_XOR, OPERATOR_NOT, };
|
|
27
|
-
/**
|
|
28
|
-
* Condition engine
|
|
29
|
-
*/
|
|
30
|
-
declare class Engine {
|
|
31
|
-
private readonly parser;
|
|
32
|
-
/**
|
|
33
|
-
* @constructor
|
|
34
|
-
* @param {Options?} options Parser options.
|
|
35
|
-
*/
|
|
36
|
-
constructor(options?: Partial<Options>);
|
|
37
|
-
/**
|
|
38
|
-
* Evaluate the expression.
|
|
39
|
-
* @param {ExpressionInput} exp Raw expression.
|
|
40
|
-
* @param {Context} ctx Evaluation data context.
|
|
41
|
-
* @return {boolean}
|
|
42
|
-
*/
|
|
43
|
-
evaluate(exp: ExpressionInput, ctx: Context): boolean;
|
|
44
|
-
/**
|
|
45
|
-
* Get expression statement
|
|
46
|
-
* @param {ExpressionInput} exp Raw expression.
|
|
47
|
-
* @return {string}
|
|
48
|
-
*/
|
|
49
|
-
statement(exp: ExpressionInput): string;
|
|
50
|
-
/**
|
|
51
|
-
* Parse expression.
|
|
52
|
-
* @param {ExpressionInput} exp Raw expression.
|
|
53
|
-
* @return {Evaluable}
|
|
54
|
-
*/
|
|
55
|
-
parse(exp: ExpressionInput): Evaluable;
|
|
56
|
-
/**
|
|
57
|
-
* Simplifies an expression with values in context.
|
|
58
|
-
*
|
|
59
|
-
* This method tries to evaluate all the expressions and reduce them to its corresponding boolean value.
|
|
60
|
-
* If a value required for the expression is not present in the context, the minimal corresponding expression
|
|
61
|
-
* will be returned.
|
|
62
|
-
*
|
|
63
|
-
* @param {ExpressionInput} exp Raw expression.
|
|
64
|
-
* @param {Context} context Evaluation data context.
|
|
65
|
-
* @param {string[]}
|
|
66
|
-
*
|
|
67
|
-
*
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
1
|
+
/**
|
|
2
|
+
* Main module.
|
|
3
|
+
* @module illogical
|
|
4
|
+
*/
|
|
5
|
+
import { Context, Evaluable } from './common/evaluable';
|
|
6
|
+
import { OPERATOR as OPERATOR_EQ } from './expression/comparison/eq';
|
|
7
|
+
import { OPERATOR as OPERATOR_GE } from './expression/comparison/ge';
|
|
8
|
+
import { OPERATOR as OPERATOR_GT } from './expression/comparison/gt';
|
|
9
|
+
import { OPERATOR as OPERATOR_IN } from './expression/comparison/in';
|
|
10
|
+
import { OPERATOR as OPERATOR_LE } from './expression/comparison/le';
|
|
11
|
+
import { OPERATOR as OPERATOR_LT } from './expression/comparison/lt';
|
|
12
|
+
import { OPERATOR as OPERATOR_NE } from './expression/comparison/ne';
|
|
13
|
+
import { OPERATOR as OPERATOR_NOT_IN } from './expression/comparison/not-in';
|
|
14
|
+
import { OPERATOR as OPERATOR_OVERLAP } from './expression/comparison/overlap';
|
|
15
|
+
import { OPERATOR as OPERATOR_PREFIX } from './expression/comparison/prefix';
|
|
16
|
+
import { OPERATOR as OPERATOR_PRESENT } from './expression/comparison/present';
|
|
17
|
+
import { OPERATOR as OPERATOR_SUFFIX } from './expression/comparison/suffix';
|
|
18
|
+
import { OPERATOR as OPERATOR_UNDEFINED } from './expression/comparison/undefined';
|
|
19
|
+
import { OPERATOR as OPERATOR_AND } from './expression/logical/and';
|
|
20
|
+
import { OPERATOR as OPERATOR_NOR } from './expression/logical/nor';
|
|
21
|
+
import { OPERATOR as OPERATOR_NOT } from './expression/logical/not';
|
|
22
|
+
import { OPERATOR as OPERATOR_OR } from './expression/logical/or';
|
|
23
|
+
import { OPERATOR as OPERATOR_XOR } from './expression/logical/xor';
|
|
24
|
+
import { ExpressionInput, Input } from './parser';
|
|
25
|
+
import { Options } from './parser/options';
|
|
26
|
+
export { OPERATOR_EQ, OPERATOR_NE, OPERATOR_GT, OPERATOR_GE, OPERATOR_LT, OPERATOR_LE, OPERATOR_IN, OPERATOR_NOT_IN, OPERATOR_PREFIX, OPERATOR_SUFFIX, OPERATOR_OVERLAP, OPERATOR_UNDEFINED, OPERATOR_PRESENT, OPERATOR_AND, OPERATOR_OR, OPERATOR_NOR, OPERATOR_XOR, OPERATOR_NOT, };
|
|
27
|
+
/**
|
|
28
|
+
* Condition engine
|
|
29
|
+
*/
|
|
30
|
+
declare class Engine {
|
|
31
|
+
private readonly parser;
|
|
32
|
+
/**
|
|
33
|
+
* @constructor
|
|
34
|
+
* @param {Options?} options Parser options.
|
|
35
|
+
*/
|
|
36
|
+
constructor(options?: Partial<Options>);
|
|
37
|
+
/**
|
|
38
|
+
* Evaluate the expression.
|
|
39
|
+
* @param {ExpressionInput} exp Raw expression.
|
|
40
|
+
* @param {Context} ctx Evaluation data context.
|
|
41
|
+
* @return {boolean}
|
|
42
|
+
*/
|
|
43
|
+
evaluate(exp: ExpressionInput, ctx: Context): boolean;
|
|
44
|
+
/**
|
|
45
|
+
* Get expression statement
|
|
46
|
+
* @param {ExpressionInput} exp Raw expression.
|
|
47
|
+
* @return {string}
|
|
48
|
+
*/
|
|
49
|
+
statement(exp: ExpressionInput): string;
|
|
50
|
+
/**
|
|
51
|
+
* Parse expression.
|
|
52
|
+
* @param {ExpressionInput} exp Raw expression.
|
|
53
|
+
* @return {Evaluable}
|
|
54
|
+
*/
|
|
55
|
+
parse(exp: ExpressionInput): Evaluable;
|
|
56
|
+
/**
|
|
57
|
+
* Simplifies an expression with values in context.
|
|
58
|
+
*
|
|
59
|
+
* This method tries to evaluate all the expressions and reduce them to its corresponding boolean value.
|
|
60
|
+
* If a value required for the expression is not present in the context, the minimal corresponding expression
|
|
61
|
+
* will be returned.
|
|
62
|
+
*
|
|
63
|
+
* @param {ExpressionInput} exp Raw expression.
|
|
64
|
+
* @param {Context} context Evaluation data context.
|
|
65
|
+
* @param {string[]} strictKeys keys to be considered present even if they are not present in the context
|
|
66
|
+
* @param {string[]} optionalKeys keys to be considered not present unless they are in the context or in
|
|
67
|
+
* `strictKeys`; when `strictKeys` is `undefined` and `optionalKeys` is an array, every key that is not in
|
|
68
|
+
* `optionalKeys` is considered to be present and thus will be evaluated
|
|
69
|
+
* @returns {Inpunt | boolean}
|
|
70
|
+
*/
|
|
71
|
+
simplify(exp: ExpressionInput, context: Context, strictKeys?: string[], optionalKeys?: string[]): Input | boolean;
|
|
72
|
+
}
|
|
73
|
+
export default Engine;
|
|
@@ -1,40 +1,36 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
*
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
* @
|
|
25
|
-
*/
|
|
26
|
-
|
|
27
|
-
/**
|
|
28
|
-
* {@link Evaluable.
|
|
29
|
-
*/
|
|
30
|
-
|
|
31
|
-
/**
|
|
32
|
-
*
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
* @return {string}
|
|
38
|
-
*/
|
|
39
|
-
toString(): string;
|
|
40
|
-
}
|
|
1
|
+
import { Context, Evaluable, Result, SimplifyArgs } from '../common/evaluable';
|
|
2
|
+
import { Input } from '../parser';
|
|
3
|
+
import { Options } from '../parser/options';
|
|
4
|
+
import { Operand } from '.';
|
|
5
|
+
import { Reference } from './reference';
|
|
6
|
+
import { Value } from './value';
|
|
7
|
+
/**
|
|
8
|
+
* Collection operand resolved containing mixture of value and references.
|
|
9
|
+
*/
|
|
10
|
+
export declare class Collection extends Operand {
|
|
11
|
+
private readonly items;
|
|
12
|
+
/**
|
|
13
|
+
* @constructor
|
|
14
|
+
* @param {Operand[]} items Collection of operands.
|
|
15
|
+
*/
|
|
16
|
+
constructor(items: Array<Value | Reference>);
|
|
17
|
+
/**
|
|
18
|
+
* Evaluate in the given context.
|
|
19
|
+
* @param {Context} ctx
|
|
20
|
+
* @return {boolean}
|
|
21
|
+
*/
|
|
22
|
+
evaluate(ctx: Context): Result;
|
|
23
|
+
/**
|
|
24
|
+
* {@link Evaluable.simplify}
|
|
25
|
+
*/
|
|
26
|
+
simplify(...args: SimplifyArgs): Result | Evaluable;
|
|
27
|
+
/**
|
|
28
|
+
* {@link Evaluable.serialize}
|
|
29
|
+
*/
|
|
30
|
+
serialize(options: Options): Input;
|
|
31
|
+
/**
|
|
32
|
+
* Get the strict representation of the operand.
|
|
33
|
+
* @return {string}
|
|
34
|
+
*/
|
|
35
|
+
toString(): string;
|
|
36
|
+
}
|
package/types/operand/index.d.ts
CHANGED
|
@@ -1,29 +1,25 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
/**
|
|
14
|
-
* {@link Evaluable.
|
|
15
|
-
*/
|
|
16
|
-
abstract
|
|
17
|
-
/**
|
|
18
|
-
* {@link Evaluable.
|
|
19
|
-
*/
|
|
20
|
-
abstract
|
|
21
|
-
/**
|
|
22
|
-
*
|
|
23
|
-
*/
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
* Get the strict representation.
|
|
27
|
-
*/
|
|
28
|
-
toString(): string;
|
|
29
|
-
}
|
|
1
|
+
import { Context, Evaluable, EvaluableType, Result } from '../common/evaluable';
|
|
2
|
+
import { Input } from '../parser';
|
|
3
|
+
import { Options } from '../parser/options';
|
|
4
|
+
/**
|
|
5
|
+
* Abstract operand
|
|
6
|
+
*/
|
|
7
|
+
export declare abstract class Operand implements Evaluable {
|
|
8
|
+
type: EvaluableType;
|
|
9
|
+
/**
|
|
10
|
+
* {@link Evaluable.evaluate}
|
|
11
|
+
*/
|
|
12
|
+
abstract evaluate(ctx: Context): Result;
|
|
13
|
+
/**
|
|
14
|
+
* {@link Evaluable.simplify}
|
|
15
|
+
*/
|
|
16
|
+
abstract simplify(ctx: Context, strictKeys?: string[], optionalKeys?: string[]): Result | Evaluable;
|
|
17
|
+
/**
|
|
18
|
+
* {@link Evaluable.serialize}
|
|
19
|
+
*/
|
|
20
|
+
abstract serialize(options: Options): Input;
|
|
21
|
+
/**
|
|
22
|
+
* Get the strict representation.
|
|
23
|
+
*/
|
|
24
|
+
toString(): string;
|
|
25
|
+
}
|
|
@@ -1,48 +1,44 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
*
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
* @
|
|
27
|
-
*/
|
|
28
|
-
|
|
29
|
-
/**
|
|
30
|
-
* {@link Evaluable.
|
|
31
|
-
*/
|
|
32
|
-
|
|
33
|
-
/**
|
|
34
|
-
*
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
*
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
* @param value value to cast as data type
|
|
46
|
-
*/
|
|
47
|
-
private toDataType;
|
|
48
|
-
}
|
|
1
|
+
import { Context, Evaluable, Result } from '../common/evaluable';
|
|
2
|
+
import { Options } from '../parser/options';
|
|
3
|
+
import { Operand } from '.';
|
|
4
|
+
export declare enum DataType {
|
|
5
|
+
Number = "Number",
|
|
6
|
+
String = "String"
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* Reference operand resolved within the context
|
|
10
|
+
*/
|
|
11
|
+
export declare class Reference extends Operand {
|
|
12
|
+
private readonly key;
|
|
13
|
+
private readonly dataType;
|
|
14
|
+
/**
|
|
15
|
+
* @constructor
|
|
16
|
+
* @param {string} key Context key.
|
|
17
|
+
*/
|
|
18
|
+
constructor(key: string);
|
|
19
|
+
/**
|
|
20
|
+
* Evaluate in the given context.
|
|
21
|
+
* @param {Context} ctx
|
|
22
|
+
* @return {boolean}
|
|
23
|
+
*/
|
|
24
|
+
evaluate(ctx: Context): Result;
|
|
25
|
+
/**
|
|
26
|
+
* {@link Evaluable.simplify}
|
|
27
|
+
*/
|
|
28
|
+
simplify(ctx: Context, strictKeys?: string[], optionalKeys?: string[]): Result | Evaluable;
|
|
29
|
+
/**
|
|
30
|
+
* {@link Evaluable.serialize}
|
|
31
|
+
*/
|
|
32
|
+
serialize({ referenceSerialization }: Options): string;
|
|
33
|
+
/**
|
|
34
|
+
* Get the strict representation of the operand.
|
|
35
|
+
* @return {string}
|
|
36
|
+
*/
|
|
37
|
+
toString(): string;
|
|
38
|
+
/**
|
|
39
|
+
* Converts a value to a specified data type
|
|
40
|
+
* Silently returns original value if data type conversion has not been implemented.
|
|
41
|
+
* @param value value to cast as data type
|
|
42
|
+
*/
|
|
43
|
+
private toDataType;
|
|
44
|
+
}
|
package/types/operand/value.d.ts
CHANGED
|
@@ -1,35 +1,31 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
* @
|
|
16
|
-
*/
|
|
17
|
-
|
|
18
|
-
/**
|
|
19
|
-
* {@link Evaluable.
|
|
20
|
-
*/
|
|
21
|
-
|
|
22
|
-
/**
|
|
23
|
-
* {@link Evaluable.
|
|
24
|
-
*/
|
|
25
|
-
|
|
26
|
-
/**
|
|
27
|
-
*
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
* @return {string}
|
|
33
|
-
*/
|
|
34
|
-
toString(): string;
|
|
35
|
-
}
|
|
1
|
+
import { Result } from '../common/evaluable';
|
|
2
|
+
import { Input } from '../parser';
|
|
3
|
+
import { Operand } from '.';
|
|
4
|
+
/**
|
|
5
|
+
* Static value operand
|
|
6
|
+
*/
|
|
7
|
+
export declare class Value extends Operand {
|
|
8
|
+
private readonly value;
|
|
9
|
+
/**
|
|
10
|
+
* @constructor
|
|
11
|
+
* @param {Result} value Constant value.
|
|
12
|
+
*/
|
|
13
|
+
constructor(value: Result);
|
|
14
|
+
/**
|
|
15
|
+
* {@link Evaluable.evaluate}
|
|
16
|
+
*/
|
|
17
|
+
evaluate(): Result;
|
|
18
|
+
/**
|
|
19
|
+
* {@link Evaluable.simplify}
|
|
20
|
+
*/
|
|
21
|
+
simplify(): Result;
|
|
22
|
+
/**
|
|
23
|
+
* {@link Evaluable.serialize}
|
|
24
|
+
*/
|
|
25
|
+
serialize(): Input;
|
|
26
|
+
/**
|
|
27
|
+
* Get the strict representation of the operand.
|
|
28
|
+
* @return {string}
|
|
29
|
+
*/
|
|
30
|
+
toString(): string;
|
|
31
|
+
}
|
package/types/parser/index.d.ts
CHANGED
|
@@ -1,43 +1,39 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
export declare
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
*
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
*
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
*
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
*
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
* @param raw Raw data
|
|
41
|
-
*/
|
|
42
|
-
private getOperand;
|
|
43
|
-
}
|
|
1
|
+
import { Evaluable } from '../common/evaluable';
|
|
2
|
+
import { Options } from './options';
|
|
3
|
+
export declare type Input = string | number | boolean | null | Input[] | [string, ...Input[]];
|
|
4
|
+
export declare type ArrayInput = Input[];
|
|
5
|
+
export declare type ExpressionInput = [string, ...Input[]];
|
|
6
|
+
/**
|
|
7
|
+
* Parser of raw expressions into Evaluable expression
|
|
8
|
+
*/
|
|
9
|
+
export declare class Parser {
|
|
10
|
+
private readonly opts;
|
|
11
|
+
private readonly expectedOperators;
|
|
12
|
+
/**
|
|
13
|
+
* @constructor
|
|
14
|
+
* @param {Options?} options Parser options.
|
|
15
|
+
*/
|
|
16
|
+
constructor(options?: Partial<Options>);
|
|
17
|
+
/**
|
|
18
|
+
* Parser options
|
|
19
|
+
* @type {Options}
|
|
20
|
+
*/
|
|
21
|
+
get options(): Options;
|
|
22
|
+
/**
|
|
23
|
+
* Parse raw expression into evaluable expression.
|
|
24
|
+
* @param {ExpressionInput} raw Raw expression.
|
|
25
|
+
* @return {Evaluable}
|
|
26
|
+
*/
|
|
27
|
+
parse(raw: ExpressionInput): Evaluable;
|
|
28
|
+
/**
|
|
29
|
+
* Parse raw expression based on the expression type.
|
|
30
|
+
* @param {Input} raw Raw expression.
|
|
31
|
+
* @return {Evaluable}
|
|
32
|
+
*/
|
|
33
|
+
private parseRawExp;
|
|
34
|
+
/**
|
|
35
|
+
* Get resolved operand
|
|
36
|
+
* @param raw Raw data
|
|
37
|
+
*/
|
|
38
|
+
private getOperand;
|
|
39
|
+
}
|