@briza/illogical 1.5.5 → 1.5.6

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@briza/illogical",
3
- "version": "1.5.5",
3
+ "version": "1.5.6",
4
4
  "description": "A micro conditional javascript engine used to parse the raw logical and comparison expressions, evaluate the expression in the given data context, and provide access to a text form of the given expressions.",
5
5
  "main": "lib/illogical.js",
6
6
  "module": "lib/illogical.esm.js",
@@ -42,31 +42,31 @@
42
42
  "rules"
43
43
  ],
44
44
  "devDependencies": {
45
- "@babel/core": "^7.17.9",
46
- "@babel/plugin-proposal-class-properties": "^7.16.7",
47
- "@babel/preset-env": "^7.16.11",
48
- "@babel/preset-typescript": "^7.16.7",
49
- "@rollup/plugin-babel": "^5.3.1",
50
- "@rollup/plugin-commonjs": "^21.0.3",
51
- "@rollup/plugin-node-resolve": "^13.2.0",
52
- "@types/jest": "^27.4.1",
53
- "@typescript-eslint/eslint-plugin": "^5.19.0",
54
- "@typescript-eslint/parser": "^5.19.0",
55
- "eslint": "^8.13.0",
56
- "eslint-config-prettier": "^8.5.0",
57
- "eslint-import-resolver-typescript": "^2.7.1",
58
- "eslint-plugin-import": "^2.26.0",
45
+ "@babel/core": "^7.23.6",
46
+ "@babel/plugin-proposal-class-properties": "^7.18.6",
47
+ "@babel/preset-env": "^7.23.6",
48
+ "@babel/preset-typescript": "^7.23.3",
49
+ "@rollup/plugin-babel": "^6.0.4",
50
+ "@rollup/plugin-commonjs": "^25.0.7",
51
+ "@rollup/plugin-eslint": "^9.0.5",
52
+ "@rollup/plugin-node-resolve": "^15.2.3",
53
+ "@types/jest": "^28.1.8",
54
+ "@typescript-eslint/eslint-plugin": "^6.14.0",
55
+ "@typescript-eslint/parser": "^6.14.0",
56
+ "eslint": "^8.55.0",
57
+ "eslint-config-prettier": "^9.1.0",
58
+ "eslint-import-resolver-typescript": "^3.6.1",
59
+ "eslint-plugin-import": "^2.29.0",
59
60
  "eslint-plugin-node": "^11.1.0",
60
- "eslint-plugin-prettier": "^3.4.1",
61
- "eslint-plugin-promise": "^6.0.0",
62
- "eslint-plugin-simple-import-sort": "^7.0.0",
63
- "jest": "^27.5.1",
61
+ "eslint-plugin-prettier": "^5.0.1",
62
+ "eslint-plugin-promise": "^6.1.1",
63
+ "eslint-plugin-simple-import-sort": "^10.0.0",
64
+ "jest": "^29.7.0",
64
65
  "license-checker": "^25.0.1",
65
- "prettier": "^2.6.2",
66
- "rollup": "^2.70.1",
67
- "rollup-plugin-eslint": "^7.0.0",
68
- "ts-jest": "^27.1.4",
69
- "typedoc": "^0.22.15",
70
- "typescript": "4.6.3"
66
+ "prettier": "^3.1.1",
67
+ "rollup": "^4.8.0",
68
+ "ts-jest": "^29.1.1",
69
+ "typedoc": "^0.25.4",
70
+ "typescript": "^5.3.3"
71
71
  }
72
72
  }
package/readme.md CHANGED
@@ -383,56 +383,72 @@ engine.evaluate(['!=', 'circle', 'square']) // true
383
383
 
384
384
  Expression format: `[">", `[Left Operand](#operand-types), [Right Operand](#operand-types)`]`.
385
385
 
386
- > Valid operand types: number.
386
+ > Valid operand types: number, string.
387
+
388
+ - String comparison only supports ISO-8601 formatted dates.
387
389
 
388
390
  ```json
389
391
  [">", 10, 5]
392
+ [">", "2023-01-01", "2022-12-31"]
390
393
  ```
391
394
 
392
395
  ```js
393
396
  engine.evaluate(['>', 10, 5]) // true
397
+ engine.evaluate(['>', '2023-01-01', '2022-12-31']) // true
394
398
  ```
395
399
 
396
400
  #### Greater Than or Equal
397
401
 
398
402
  Expression format: `[">=", `[Left Operand](#operand-types), [Right Operand](#operand-types)`]`.
399
403
 
400
- > Valid operand types: number.
404
+ > Valid operand types: number, string.
405
+
406
+ - String comparison only supports ISO-8601 formatted dates.
401
407
 
402
408
  ```json
403
409
  [">=", 5, 5]
410
+ [">=", "2023-01-01", "2023-01-01"]
404
411
  ```
405
412
 
406
413
  ```js
407
414
  engine.evaluate(['>=', 5, 5]) // true
415
+ engine.evaluate(['>=', '2023-01-01', '2023-01-01']) // true
408
416
  ```
409
417
 
410
418
  #### Less Than
411
419
 
412
420
  Expression format: `["<", `[Left Operand](#operand-types), [Right Operand](#operand-types)`]`.
413
421
 
414
- > Valid operand types: number.
422
+ > Valid operand types: number, string.
423
+
424
+ - String comparison only supports ISO-8601 formatted dates.
415
425
 
416
426
  ```json
417
427
  ["<", 5, 10]
428
+ ["<", "2022-12-31", "2023-01-01"]
418
429
  ```
419
430
 
420
431
  ```js
421
432
  engine.evaluate(['<', 5, 10]) // true
433
+ engine.evaluate(['<', '2022-12-31', '2023-01-01']) // true
422
434
  ```
423
435
 
424
436
  #### Less Than or Equal
425
437
 
426
438
  Expression format: `["<=", `[Left Operand](#operand-types), [Right Operand](#operand-types)`]`.
427
439
 
428
- > Valid operand types: number.
440
+ > Valid operand types: number, string.
441
+
442
+ - String comparison only supports ISO-8601 formatted dates.
429
443
 
430
444
  ```json
431
445
  ["<=", 5, 5]
446
+ ["<=", "2023-01-01", "2023-01-01"]
432
447
  ```
433
448
 
434
449
  ```js
435
450
  engine.evaluate(['<=', 5, 5]) // true
451
+ engine.evaluate(['<=', '2023-01-01', '2023-01-01']) // true
436
452
  ```
437
453
 
438
454
  #### In
@@ -3,7 +3,7 @@ import { Options } from '../parser/options';
3
3
  /**
4
4
  * Valid types for context members
5
5
  */
6
- declare type ContextValue = Record<string, unknown> | string | number | boolean | null | undefined | ContextValue[];
6
+ type ContextValue = Record<string, unknown> | string | number | boolean | null | undefined | ContextValue[];
7
7
  /**
8
8
  * Evaluation Context
9
9
  * Holds references used during the evaluation process.
@@ -15,7 +15,7 @@ export interface Context {
15
15
  /**
16
16
  * Evaluation result
17
17
  */
18
- export declare type Result = undefined | null | string | number | boolean | Array<Result> | Record<string, unknown>;
18
+ export type Result = undefined | null | string | number | boolean | Array<Result> | Record<string, unknown>;
19
19
  export declare enum EvaluableType {
20
20
  Operand = "Operand",
21
21
  Expression = "Expression"
@@ -53,5 +53,5 @@ export interface Evaluable {
53
53
  */
54
54
  toString(): string;
55
55
  }
56
- export declare type SimplifyArgs = Parameters<Evaluable['simplify']>;
56
+ export type SimplifyArgs = Parameters<Evaluable['simplify']>;
57
57
  export {};
@@ -9,3 +9,8 @@ export declare const toNumber: (value: Result) => number | undefined;
9
9
  * @param value value to be converted to string
10
10
  */
11
11
  export declare const toString: (value: Result) => string | undefined;
12
+ /**
13
+ * Convert a value to number if it's type is string, otherwise return NaN
14
+ * @param value value to be converted to number
15
+ */
16
+ export declare const toDateNumber: (value: Result) => number;
@@ -1,8 +1,8 @@
1
1
  import { Evaluable } from '../common/evaluable';
2
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[]];
3
+ export type Input = string | number | boolean | null | Input[] | [string, ...Input[]];
4
+ export type ArrayInput = Input[];
5
+ export type ExpressionInput = [string, ...Input[]];
6
6
  /**
7
7
  * Parser of raw expressions into Evaluable expression
8
8
  */
@@ -1,4 +1,4 @@
1
- export declare type optionValue = ((operand: string) => string | boolean) | Map<symbol, string>;
1
+ export type optionValue = ((operand: string) => string | boolean) | Map<symbol, string>;
2
2
  export interface Options {
3
3
  /**
4
4
  * A function used to determine if the operand is a reference type,