@briza/illogical 1.6.1 → 1.7.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.
- package/changelog.md +10 -4
- package/lib/illogical.esm.js +542 -6
- package/lib/illogical.js +542 -6
- package/package.json +3 -3
- package/readme.md +21 -7
- package/types/common/type-check.d.ts +2 -0
- package/types/index.d.ts +1 -0
- package/types/operand/collection.d.ts +5 -0
- package/types/parser/index.d.ts +1 -1
- package/types/unsafe/and.d.ts +3 -0
- package/types/unsafe/arithmetic.d.ts +6 -0
- package/types/unsafe/comparison.d.ts +7 -0
- package/types/unsafe/equality.d.ts +5 -0
- package/types/unsafe/in.d.ts +3 -0
- package/types/unsafe/nor.d.ts +4 -0
- package/types/unsafe/not-in.d.ts +3 -0
- package/types/unsafe/not.d.ts +3 -0
- package/types/unsafe/or.d.ts +3 -0
- package/types/unsafe/overlap.d.ts +3 -0
- package/types/unsafe/prefix.d.ts +5 -0
- package/types/unsafe/present.d.ts +4 -0
- package/types/unsafe/simplify.d.ts +4 -0
- package/types/unsafe/type-check.d.ts +12 -0
- package/types/unsafe/xor.d.ts +4 -0
|
@@ -43,3 +43,5 @@ export declare function areAllResults(values: (Result | Evaluable)[]): values is
|
|
|
43
43
|
* @returns {boolean} type guard
|
|
44
44
|
*/
|
|
45
45
|
export declare function areAllNumbers(results: Result[]): results is number[];
|
|
46
|
+
export declare function isUndefined(value: unknown): value is undefined;
|
|
47
|
+
export declare function isNull(value: unknown): value is null;
|
package/types/index.d.ts
CHANGED
|
@@ -75,5 +75,6 @@ declare class Engine {
|
|
|
75
75
|
* @returns {Inpunt | boolean}
|
|
76
76
|
*/
|
|
77
77
|
simplify(exp: ExpressionInput, context: Context, strictKeys?: string[], optionalKeys?: string[]): Input | boolean;
|
|
78
|
+
unsafeSimplify(exp: ExpressionInput, context: Context, strictKeys?: string[], optionalKeys?: string[]): Input | boolean;
|
|
78
79
|
}
|
|
79
80
|
export default Engine;
|
|
@@ -9,6 +9,11 @@ import { Value } from './value';
|
|
|
9
9
|
*/
|
|
10
10
|
export declare class Collection extends Operand {
|
|
11
11
|
private readonly items;
|
|
12
|
+
/**
|
|
13
|
+
* Get the items in the collection.
|
|
14
|
+
* @returns {Array<Value | Reference>}
|
|
15
|
+
*/
|
|
16
|
+
getItems(): Array<Value | Reference>;
|
|
12
17
|
/**
|
|
13
18
|
* @constructor
|
|
14
19
|
* @param {Operand[]} items Collection of operands.
|
package/types/parser/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Evaluable } from '../common/evaluable';
|
|
2
2
|
import { Options } from './options';
|
|
3
|
-
export type Input = string | number | boolean | null | Input[] | [string, ...Input[]]
|
|
3
|
+
export type Input = string | number | boolean | null | Input[] | [string, ...Input[]] | Record<string, unknown>;
|
|
4
4
|
export type ArrayInput = Input[];
|
|
5
5
|
export type ExpressionInput = [string, ...Input[]];
|
|
6
6
|
/**
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { Evaluable } from '../common/evaluable';
|
|
2
|
+
import { Input } from '../parser';
|
|
3
|
+
export declare const simplifySum: (simplifyInput: (input: Input) => Input | Evaluable) => (input: Input[] | [string, ...Input[]]) => Input | Evaluable;
|
|
4
|
+
export declare const simplifySubtract: (simplifyInput: (input: Input) => Input | Evaluable) => (input: Input[] | [string, ...Input[]]) => Input | Evaluable;
|
|
5
|
+
export declare const simplifyMultiply: (simplifyInput: (input: Input) => Input | Evaluable) => (input: Input[] | [string, ...Input[]]) => Input | Evaluable;
|
|
6
|
+
export declare const simplifyDivide: (simplifyInput: (input: Input) => Input | Evaluable) => (input: Input[] | [string, ...Input[]]) => Input | Evaluable;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { Evaluable } from '../common/evaluable';
|
|
2
|
+
import { Input } from '../parser';
|
|
3
|
+
import { Options } from '../parser/options';
|
|
4
|
+
export declare const simplifyGt: (opts: Options, simplifyInput: (input: Input) => Input | Evaluable) => (input: Input[] | [string, ...Input[]]) => Input | Evaluable;
|
|
5
|
+
export declare const simplifyGe: (opts: Options, simplifyInput: (input: Input) => Input | Evaluable) => (input: Input[] | [string, ...Input[]]) => Input | Evaluable;
|
|
6
|
+
export declare const simplifyLt: (opts: Options, simplifyInput: (input: Input) => Input | Evaluable) => (input: Input[] | [string, ...Input[]]) => Input | Evaluable;
|
|
7
|
+
export declare const simplifyLe: (opts: Options, simplifyInput: (input: Input) => Input | Evaluable) => (input: Input[] | [string, ...Input[]]) => Input | Evaluable;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { Evaluable } from '../common/evaluable';
|
|
2
|
+
import { Input } from '../parser';
|
|
3
|
+
import { Options } from '../parser/options';
|
|
4
|
+
export declare const simplifyEq: (opts: Options, simplifyInput: (input: Input) => Input | Evaluable) => (input: Input[] | [string, ...Input[]]) => Input | Evaluable;
|
|
5
|
+
export declare const simplifyNe: (opts: Options, simplifyInput: (input: Input) => Input | Evaluable) => (input: Input[] | [string, ...Input[]]) => Input | Evaluable;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { Evaluable } from '../common/evaluable';
|
|
2
|
+
import { Input } from '../parser';
|
|
3
|
+
import { Options } from '../parser/options';
|
|
4
|
+
export declare const simplifyNor: (opts: Options, simplifyInput: (input: Input) => Input | Evaluable) => (input: Input[] | [string, ...Input[]]) => Input | Evaluable;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { Evaluable } from '../common/evaluable';
|
|
2
|
+
import { Input } from '../parser';
|
|
3
|
+
import { Options } from '../parser/options';
|
|
4
|
+
export declare const simplifyPrefix: (opts: Options, simplifyInput: (input: Input) => Input | Evaluable) => (input: Input[] | [string, ...Input[]]) => Input | Evaluable;
|
|
5
|
+
export declare const simplifySuffix: (opts: Options, simplifyInput: (input: Input) => Input | Evaluable) => (input: Input[] | [string, ...Input[]]) => Input | Evaluable;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { Evaluable } from '../common/evaluable';
|
|
2
|
+
import { Input } from '../parser';
|
|
3
|
+
export declare const simplifyPresent: (simplifyInput: (input: Input) => Input | Evaluable) => (input: Input[] | [string, ...Input[]]) => Input | Evaluable;
|
|
4
|
+
export declare const simplifyUndefined: (simplifyInput: (input: Input) => Input | Evaluable) => (input: Input[] | [string, ...Input[]]) => Input | Evaluable;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { Context, Evaluable } from '../common/evaluable';
|
|
2
|
+
import { Input } from '../parser';
|
|
3
|
+
import { Options } from '../parser/options';
|
|
4
|
+
export declare const unsafeSimplify: (context: Context, opts: Options, strictKeys?: string[], optionalKeys?: string[]) => (input: Input) => Input | Evaluable;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { Evaluable, Result } from '../common/evaluable';
|
|
2
|
+
import { Input } from '../parser';
|
|
3
|
+
export declare const isTrueResult: (value: Input) => value is true;
|
|
4
|
+
export declare const isFalseResult: (value: Input) => value is false;
|
|
5
|
+
export declare const isNonFalseResult: (operand: Input | Evaluable) => operand is Input;
|
|
6
|
+
export declare const isNonTrueResult: (operand: Input | Evaluable) => operand is Input;
|
|
7
|
+
export declare const resultToInputInternal: (value: Result) => Input | undefined;
|
|
8
|
+
export declare const resultToInput: (value: Result) => Input | undefined;
|
|
9
|
+
export declare const areAllNumbers: (results: Input[]) => results is number[];
|
|
10
|
+
export declare const areAllInputs: (values: (Input | Evaluable)[]) => values is Input[];
|
|
11
|
+
export declare const getInputValues: (results: Input[]) => number[] | false;
|
|
12
|
+
export declare const extractValues: (input: Input | Evaluable) => Result[];
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { Evaluable } from '../common/evaluable';
|
|
2
|
+
import { Input } from '../parser';
|
|
3
|
+
import { Options } from '../parser/options';
|
|
4
|
+
export declare const simplifyXor: (opts: Options, simplifyInput: (input: Input) => Input | Evaluable) => (input: Input[] | [string, ...Input[]]) => Input | Evaluable;
|