{"id":21179033,"url":"https://github.com/spaceavocado/illogical","last_synced_at":"2026-03-04T21:02:05.599Z","repository":{"id":47115593,"uuid":"443232449","full_name":"spaceavocado/illogical","owner":"spaceavocado","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.","archived":false,"fork":false,"pushed_at":"2025-02-24T05:39:17.000Z","size":1663,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-08-21T16:02:17.910Z","etag":null,"topics":["expression","logical"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/spaceavocado.png","metadata":{"files":{"readme":"readme.md","changelog":"changelog.md","contributing":"contributing.md","funding":null,"license":"license.txt","code_of_conduct":"code_of_conduct.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-12-31T02:23:47.000Z","updated_at":"2025-02-24T05:39:20.000Z","dependencies_parsed_at":"2024-11-20T17:33:35.392Z","dependency_job_id":"73a0b79f-ccf3-414a-85c2-9e02cfff3f97","html_url":"https://github.com/spaceavocado/illogical","commit_stats":null,"previous_names":[],"tags_count":25,"template":false,"template_full_name":null,"purl":"pkg:github/spaceavocado/illogical","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/spaceavocado%2Fillogical","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/spaceavocado%2Fillogical/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/spaceavocado%2Fillogical/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/spaceavocado%2Fillogical/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/spaceavocado","download_url":"https://codeload.github.com/spaceavocado/illogical/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/spaceavocado%2Fillogical/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":30092867,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-04T20:42:30.420Z","status":"ssl_error","status_checked_at":"2026-03-04T20:42:30.057Z","response_time":59,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["expression","logical"],"created_at":"2024-11-20T17:28:02.917Z","updated_at":"2026-03-04T21:02:05.581Z","avatar_url":"https://github.com/spaceavocado.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# illogical\n\nA 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.\n\n\u003e Revision: Aug 20, 2024.\n\nOther implementations:\n- [GO](https://github.com/spaceavocado/goillogical)\n- [Python](https://github.com/spaceavocado/pyillogical)\n- [C#](https://github.com/spaceavocado/cillogical)\n- [Java](https://github.com/spaceavocado/jillogical)\n- [Odin](https://github.com/spaceavocado/oillogical)\n\n## About\n\nThis project has been developed to provide a shared conditional logic between front-end and back-end code, stored in JSON or in any other data serialization format.\n\n\u003e Code documentation could be found here: https://spaceavocado.github.io/illogical/index.html.\n\n\u003e The library is being build as **CommonJS** module and **ESM**.\n\n## Installation via NPM or Yarn\n\n```sh\nnpm install -D @spaceavocado/illogical\n```\n\n```sh\nyarn add @spaceavocado/illogical -D\n```\n\n**Table of Content**\n\n---\n\n- [illogical](#illogical)\n  - [About](#about)\n  - [Installation via NPM or Yarn](#installation-via-npm-or-yarn)\n  - [Basic Usage](#basic-usage)\n    - [Evaluate](#evaluate)\n    - [Statement](#statement)\n    - [Parse](#parse)\n      - [Evaluate Function](#evaluate-function)\n    - [Simplify](#simplify)\n  - [Working with Expressions](#working-with-expressions)\n    - [Evaluation Data Context](#evaluation-data-context)\n      - [Accessing Array Element:](#accessing-array-element)\n      - [Accessing Array Element via Reference:](#accessing-array-element-via-reference)\n      - [Nested Referencing](#nested-referencing)\n      - [Composite Reference Key](#composite-reference-key)\n      - [Data Type Casting](#data-type-casting)\n    - [Operand Types](#operand-types)\n      - [Value](#value)\n      - [Reference](#reference)\n      - [Collection](#collection)\n    - [Comparison Expressions](#comparison-expressions)\n      - [Equal](#equal)\n      - [Not Equal](#not-equal)\n      - [Greater Than](#greater-than)\n      - [Greater Than or Equal](#greater-than-or-equal)\n      - [Less Than](#less-than)\n      - [Less Than or Equal](#less-than-or-equal)\n      - [In](#in)\n      - [Not In](#not-in)\n      - [Prefix](#prefix)\n      - [Suffix](#suffix)\n      - [Overlap](#overlap)\n      - [Undefined](#undefined)\n      - [Present](#present)\n    - [Logical Expressions](#logical-expressions)\n      - [And](#and)\n      - [Or](#or)\n      - [Nor](#nor)\n      - [Xor](#xor)\n      - [Not](#not)\n  - [Engine Options](#engine-options)\n    - [Parser Options](#parser-options)\n      - [Reference Predicate](#reference-predicate)\n      - [Reference Transform](#reference-transform)\n      - [Operator Mapping](#operator-mapping)\n  - [Contributing](#contributing)\n  - [License](#license)\n\n---\n\n## Basic Usage\n\n```ts\n// Import the illogical engine\nimport illogical from '@spaceavocado/illogical'\n\n// Create a new instance of the engine\nconst i = illogical()\n\n// Evaluate the raw expression\nconst result = i.evaluate(['==', 5, 5])\n```\n\n\u003e For advanced usage, please [Engine Options](#engine-options).\n\n### Evaluate\n\nEvaluate comparison or logical expression:\n\n`i.evaluate(`[Comparison Expression](#comparison-expressions) or [Logical Expression](#logical-expressions), [Evaluation Data Context](#evaluation-data-context)`)` =\u003e `boolean`\n\n\u003e Data context is optional.\n\n**Example**\n\n```ts\n// Comparison expression\ni.evaluate(['==', 5, 5])\ni.evaluate(['==', 'circle', 'circle'])\ni.evaluate(['==', true, true])\ni.evaluate(['==', '$name', 'peter'], { name: 'peter' })\ni.evaluate(['UNDEFINED', '$RefA'], {})\n\n// Logical expression\ni.evaluate(['AND', ['==', 5, 5], ['==', 10, 10]])\ni.evaluate(['AND', ['==', 'circle', 'circle'], ['==', 10, 10]])\ni.evaluate(['OR', ['==', '$name', 'peter'], ['==', 5, 10]], { name: 'peter' })\n```\n\n### Statement\n\nGet expression string representation:\n\n`i.statement(`[Comparison Expression](#comparison-expressions) or [Logical Expression](#logical-expressions)`)` =\u003e `string`\n\n**Example**\n\n```ts\n/* Comparison expression */\n\ni.statement(['==', 5, 5]) // (5 == 5)\ni.statement(['==', 'circle', 'circle']) // (\"circle\" == \"circle\")\ni.statement(['==', true, true]) // (true == true)\ni.statement(['==', '$name', 'peter'], { name: 'peter' }) // ({name} == \"peter\")\ni.statement(['UNDEFINED', '$RefA']) // ({RefA} is UNDEFINED)\n\n/* Logical expression */\n\ni.statement(['AND', ['==', 5, 5], ['==', 10, 10]]) // ((5 == 5) AND (10 == 10))\ni.statement(['AND', ['==', 'circle', 'circle'], ['==', 10, 10]]) // ((\"circle\" == \"circle\") AND (10 == 10))\ni.statement(['OR', ['==', '$name', 'peter'], ['==', 5, 10]], { name: 'peter' }) // (({name} == \"peter\") OR (5 == 10))\n```\n\n### Parse\n\nParse the expression into a evaluable object, i.e. it returns the parsed self-evaluable condition expression.\n\n`i.parse(`[Comparison Expression](#comparison-expressions) or [Logical Expression](#logical-expressions)`)` =\u003e `evaluable`\n\n#### Evaluate Function\n\n- `evaluable.evaluate(context)` please see [Evaluation Data Context](#evaluation-data-context).\n- `evaluable.toString()` please see [Statement](#statement).\n\n**Example**\n\n```ts\nlet evaluable = i.parse(['==', '$name', 'peter'])\n\nevaluable.evaluate({ name: 'peter' }) // true\nevaluable.toString() // ({name} == \"peter\")\n```\n\n### Simplify\n\nSimplifies an expression with a given context. This is useful when you already have some of\nthe properties of context and wants to try to evaluate the expression.\n\n**Example**\n\n```ts\ni.simplify(['AND', ['==', '$a', 10], ['==', '$b', 20]], { a: 10 }) // ['==', '$b', 20]\ni.simplify(['AND', ['==', '$a', 10], ['==', '$b', 20]], { a: 20 }) // false\n```\n\nValues not found in the context will cause the parent operand not to be evaluated and returned\nas part of the simplified expression.\n\nIn some situations we might want to evaluate the expression even if referred value is not\npresent. You can provide a list of keys that will be strictly evaluated even if they are not\npresent in the context.\n\n**Example**\n\n```ts\ni.simplify(\n  ['AND', ['==', '$a', 10], ['==', '$b', 20]],\n  { a: 10 },\n  ['b'] // '$b' will be evaluated to undefined.\n) // false\n```\n\nAlternatively we might want to do the opposite and strictly evaluate the expression for all referred\nvalues not present in the context except for a specified list of optional keys.\n\n**Example**\n\n```ts\ni.simplify(\n  ['OR', ['==', '$a', 10], ['==', '$b', 20], ['==', '$c', 20]],\n  { c: 10 },\n  undefined,\n  ['b'] // except for '$b' everything not in context will be evaluated to undefined.\n) // ['==', '$b', 20]\n```\n\n## Working with Expressions\n\n### Evaluation Data Context\n\nThe evaluation data context is used to provide the expression with variable references, i.e. this allows for the dynamic expressions. The data context is object with properties used as the references keys, and its values as reference values.\n\n\u003e Valid reference values: object, string, number, boolean, string[], number[].\n\nTo reference the nested reference, please use \".\" delimiter, e.g.:\n`$address.city`\n\n#### Accessing Array Element:\n\n`$options[1]`\n\n#### Accessing Array Element via Reference:\n\n`$options[{index}]`\n\n- The **index** reference is resolved within the data context as an array index.\n\n#### Nested Referencing\n\n`$address.{segment}`\n\n- The **segment** reference is resolved within the data context as a property key.\n\n#### Composite Reference Key\n\n`$shape{shapeType}`\n\n- The **shapeType** reference is resolved within the data context, and inserted into the outer reference key.\n- E.g. **shapeType** is resolved as \"**B**\" and would compose the **$shapeB** outer reference.\n- This resolution could be n-nested.\n\n#### Data Type Casting\n\n`$payment.amount.(Type)`\n\nCast the given data context into the desired data type before being used as an operand in the evaluation.\n\n\u003e Note: If the conversion is invalid, then a warning message is being logged.\n\nSupported data type conversions:\n\n- .(String): cast a given reference to String.\n- .(Number): cast a given reference to Number.\n- .(Integer): cast a given reference to whole number.\n- .(Float): cast a given reference to floating point number.\n- .(Boolean): cast a given reference to boolean value.\n\n**Example**\n\n```ts\n// Data context\nconst ctx = {\n  name: 'peter',\n  country: 'canada',\n  age: 21,\n  options: [1, 2, 3],\n  address: {\n    city: 'Toronto',\n    country: 'Canada',\n  },\n  index: 2,\n  segment: 'city',\n  shapeA: 'box',\n  shapeB: 'circle',\n  shapeType: 'B',\n}\n\n// Evaluate an expression in the given data context\ni.evaluate(['\u003e', '$age', 20], ctx) // true\n\n// Evaluate an expression in the given data context\ni.evaluate(['==', '$address.city', 'Toronto'], ctx) // true\n\n// Accessing Array Element\ni.evaluate(['==', '$options[1]', 2], ctx) // true\n\n// Accessing Array Element via Reference\ni.evaluate(['==', '$options[{index}]', 3], ctx) // true\n\n// Nested Referencing\ni.evaluate(['==', '$address.{segment}', 'Toronto'], ctx) // true\n\n// Composite Reference Key\ni.evaluate(['==', '$shape{shapeType}', 'circle'], ctx) // true\n\n// Data Type Casting\ni.evaluate(['==', '$age.(String)', '21'], ctx) // true\n```\n\n### Operand Types\n\nThe [Comparison Expression](#comparison-expression) expect operands to be one of the below:\n\n#### Value\n\nSimple value types: string, number, boolean.\n\n**Example**\n\n```ts\n;['==', 5, 5][('==', 'circle', 'circle')][('==', true, true)]\n```\n\n#### Reference\n\nThe reference operand value is resolved from the [Evaluation Data Context](#evaluation-data-context), where the the operands name is used as key in the context.\n\nThe reference operand must be prefixed with `$` symbol, e.g.: `$name`. This might be customized via [Reference Predicate Parser Option](#reference-predicate).\n\n**Example**\n\n| Expression                    | Data Context      |\n| ----------------------------- | ----------------- |\n| `['==', '$age', 21]`          | `{age: 21}`       |\n| `['==', 'circle', '$shape'] ` | `{age: 'circle'}` |\n| `['==', '$visible', true]`    | `{visible: true}` |\n\n#### Collection\n\nThe operand could be an array mixed from [Value](#value) and [Reference](#reference).\n\n**Example**\n\n| Expression                               | Data Context                        |\n| ---------------------------------------- | ----------------------------------- |\n| `['IN', [1, 2], 1]`                      | `{}`                                |\n| `['IN', 'circle', ['$shapeA', $shapeB] ` | `{shapeA: 'circle', shapeB: 'box'}` |\n| `['IN', [$number, 5], 5]`                | `{number: 3}`                       |\n\n### Comparison Expressions\n\n#### Equal\n\nExpression format: `[\"==\", `[Left Operand](#operand-types), [Right Operand](#operand-types)`]`.\n\n\u003e Valid operand types: string, number, boolean.\n\n```json\n[\"==\", 5, 5]\n```\n\n```ts\ni.evaluate(['==', 5, 5]) // true\n```\n\n#### Not Equal\n\nExpression format: `[\"!=\", `[Left Operand](#operand-types), [Right Operand](#operand-types)`]`.\n\n\u003e Valid operand types: string, number, boolean.\n\n```json\n[\"!=\", \"circle\", \"square\"]\n```\n\n```ts\ni.evaluate(['!=', 'circle', 'square']) // true\n```\n\n#### Greater Than\n\nExpression format: `[\"\u003e\", `[Left Operand](#operand-types), [Right Operand](#operand-types)`]`.\n\n\u003e Valid operand types: number.\n\n```json\n[\"\u003e\", 10, 5]\n```\n\n```ts\ni.evaluate(['\u003e', 10, 5]) // true\n```\n\n#### Greater Than or Equal\n\nExpression format: `[\"\u003e=\", `[Left Operand](#operand-types), [Right Operand](#operand-types)`]`.\n\n\u003e Valid operand types: number.\n\n```json\n[\"\u003e=\", 5, 5]\n```\n\n```ts\ni.evaluate(['\u003e=', 5, 5]) // true\n```\n\n#### Less Than\n\nExpression format: `[\"\u003c\", `[Left Operand](#operand-types), [Right Operand](#operand-types)`]`.\n\n\u003e Valid operand types: number.\n\n```json\n[\"\u003c\", 5, 10]\n```\n\n```ts\ni.evaluate(['\u003c', 5, 10]) // true\n```\n\n#### Less Than or Equal\n\nExpression format: `[\"\u003c=\", `[Left Operand](#operand-types), [Right Operand](#operand-types)`]`.\n\n\u003e Valid operand types: number.\n\n```json\n[\"\u003c=\", 5, 5]\n```\n\n```ts\ni.evaluate(['\u003c=', 5, 5]) // true\n```\n\n#### In\n\nExpression format: `[\"IN\", `[Left Operand](#operand-types), [Right Operand](#operand-types)`]`.\n\n\u003e Valid operand types: number and number[] or string and string[].\n\n```json\n[\"IN\", 5, [1,2,3,4,5]]\n[\"IN\", [\"circle\", \"square\", \"triangle\"], \"square\"]\n```\n\n```ts\ni.evaluate(['IN', 5, [1, 2, 3, 4, 5]]) // true\ni.evaluate(['IN', ['circle', 'square', 'triangle'], 'square']) // true\n```\n\n#### Not In\n\nExpression format: `[\"NOT IN\", `[Left Operand](#operand-types), [Right Operand](#operand-types)`]`.\n\n\u003e Valid operand types: number and number[] or string and string[].\n\n```json\n[\"IN\", 10, [1,2,3,4,5]]\n[\"IN\", [\"circle\", \"square\", \"triangle\"], \"oval\"]\n```\n\n```ts\ni.evaluate(['NOT IN', 10, [1, 2, 3, 4, 5]]) // true\ni.evaluate(['NOT IN', ['circle', 'square', 'triangle'], 'oval']) // true\n```\n\n#### Prefix\n\nExpression format: `[\"PREFIX\", `[Left Operand](#operand-types), [Right Operand](#operand-types)`]`.\n\n\u003e Valid operand types: string.\n\n- Left operand is the PREFIX term.\n- Right operand is the tested word.\n\n```json\n[\"PREFIX\", \"hemi\", \"hemisphere\"]\n```\n\n```ts\ni.evaluate(['PREFIX', 'hemi', 'hemisphere']) // true\ni.evaluate(['PREFIX', 'hemi', 'sphere']) // false\n```\n\n#### Suffix\n\nExpression format: `[\"SUFFIX\", `[Left Operand](#operand-types), [Right Operand](#operand-types)`]`.\n\n\u003e Valid operand types: string.\n\n- Left operand is the tested word.\n- Right operand is the SUFFIX term.\n\n```json\n[\"SUFFIX\", \"establishment\", \"ment\"]\n```\n\n```ts\ni.evaluate(['SUFFIX', 'establishment', 'ment']) // true\ni.evaluate(['SUFFIX', 'establish', 'ment']) // false\n```\n\n#### Overlap\n\nExpression format: `[\"OVERLAP\", `[Left Operand](#operand-types), [Right Operand](#operand-types)`]`.\n\n\u003e Valid operand types number[] or string[].\n\n```json\n[\"OVERLAP\", [1, 2], [1, 2, 3, 4, 5]]\n[\"OVERLAP\", [\"circle\", \"square\", \"triangle\"], [\"square\"]]\n```\n\n```ts\ni.evaluate(['OVERLAP', [1, 2, 6], [1, 2, 3, 4, 5]]) // true\ni.evaluate(['OVERLAP', ['circle', 'square', 'triangle'], ['square', 'oval']]) // true\n```\n\n#### Undefined\n\nExpression format: `[\"UNDEFINED\", `[Reference Operand](#reference)`]`.\n\n```json\n[\"UNDEFINED\", \"$RefA\"]\n```\n\n```ts\ni.evaluate(['UNDEFINED', 'RefA'], {}) // true\ni.evaluate(['UNDEFINED', 'RefA'], { RefA: undefined }) // true\ni.evaluate(['UNDEFINED', 'RefA'], { RefA: 10 }) // false\n```\n\n#### Present\n\nEvaluates as FALSE when the operand is UNDEFINED or NULL.\n\nExpression format: `[\"PRESENT\", `[Reference Operand](#reference)`]`.\n\n```json\n[\"PRESENT\", \"$RefA\"]\n```\n\n```ts\ni.evaluate(['PRESENT', 'RefA'], {}) // false\ni.evaluate(['PRESENT', 'RefA'], { RefA: undefined }) // false\ni.evaluate(['PRESENT', 'RefA'], { RefA: null }) // false\ni.evaluate(['PRESENT', 'RefA'], { RefA: 10 }) // true\ni.evaluate(['PRESENT', 'RefA'], { RefA: false }) // true\ni.evaluate(['PRESENT', 'RefA'], { RefA: 0 }) // true\n```\n\n### Logical Expressions\n\n#### And\n\nThe logical AND operator (\u0026\u0026) returns the boolean value TRUE if both operands are TRUE and returns FALSE otherwise.\n\nExpression format: `[\"AND\", Left Operand 1, Right Operand 2, ... , Right Operand N]`.\n\n\u003e Valid operand types: [Comparison Expression](#comparison-expressions) or [Nested Logical Expression](#logical-expressions).\n\n```json\n[\"AND\", [\"==\", 5, 5], [\"==\", 10, 10]]\n```\n\n```ts\ni.evaluate(['AND', ['==', 5, 5], ['==', 10, 10]]) // true\n```\n\n#### Or\n\nThe logical OR operator (||) returns the boolean value TRUE if either or both operands is TRUE and returns FALSE otherwise.\n\nExpression format: `[\"OR\", Left Operand 1, Right Operand 2, ... , Right Operand N]`.\n\n\u003e Valid operand types: [Comparison Expression](#comparison-expressions) or [Nested Logical Expression](#logical-expressions).\n\n```json\n[\"OR\", [\"==\", 5, 5], [\"==\", 10, 5]]\n```\n\n```ts\ni.evaluate(['OR', ['==', 5, 5], ['==', 10, 5]]) // true\n```\n\n#### Nor\n\nThe logical NOR operator returns the boolean value TRUE if both operands are FALSE and returns FALSE otherwise.\n\nExpression format: `[\"NOR\", Left Operand 1, Right Operand 2, ... , Right Operand N]`\n\n\u003e Valid operand types: [Comparison Expression](#comparison-expressions) or [Nested Logical Expression](#logical-expressions).\n\n```json\n[\"NOR\", [\"==\", 5, 1], [\"==\", 10, 5]]\n```\n\n```ts\ni.evaluate(['NOR', ['==', 5, 1], ['==', 10, 5]]) // true\n```\n\n#### Xor\n\nThe logical NOR operator returns the boolean value TRUE if both operands are FALSE and returns FALSE otherwise.\n\nExpression format: `[\"XOR\", Left Operand 1, Right Operand 2, ... , Right Operand N]`\n\n\u003e Valid operand types: [Comparison Expression](#comparison-expressions) or [Nested Logical Expression](#logical-expressions).\n\n```json\n[\"XOR\", [\"==\", 5, 5], [\"==\", 10, 5]]\n```\n\n```ts\ni.evaluate(['XOR', ['==', 5, 5], ['==', 10, 5]]) // true\n```\n\n```json\n[\"XOR\", [\"==\", 5, 5], [\"==\", 10, 10]]\n```\n\n```ts\ni.evaluate(['XOR', ['==', 5, 5], ['==', 10, 10]]) // false\n```\n\n#### Not\n\nThe logical NOT operator returns the boolean value TRUE if the operand is FALSE, TRUE otherwise.\n\nExpression format: `[\"NOT\", Operand]`\n\n\u003e Valid operand types: [Comparison Expression](#comparison-expressions) or [Nested Logical Expression](#logical-expressions).\n\n```json\n[\"NOT\", [\"==\", 5, 5]]\n```\n\n```ts\ni.evaluate(['NOT', ['==', 5, 5]]) // true\n```\n\n## Engine Options\n\n### Parser Options\n\nBelow described, are individual options object properties which could be used individually. Any missing options will be substituted with the default options.\n\n**Usage**\n\n```ts\n// Import the illogical engine\nimport Engine from '@spaceavocado/illogical'\n\n// Create a new instance of the engine\nconst opts = {\n  referencePredicate: (operand) =\u003e operand.startsWith('$'),\n}\nconst engine = new Engine(opts)\n```\n\n#### Reference Predicate\n\nA function used to determine if the operand is a reference type, otherwise evaluated as a static value.\n\n```ts\nreferencePredicate: (operand: string) =\u003e boolean\n```\n\n**Return value:**\n\n- `true` = reference type\n- `false` = value type\n\n**Default reference predicate:**\n\n\u003e The `$` symbol at the begging of the operand is used to predicate the reference type., E.g. `$State`, `$Country`.\n\n#### Reference Transform\n\nA function used to transform the operand into the reference annotation stripped form. I.e. remove any annotation used to detect the reference type. E.g. \"$Reference\" =\u003e \"Reference\".\n\n```ts\nreferenceTransform: (operand: string) =\u003e string\n```\n\n\u003e **Default reference transform:**\n\u003e It removes the `$` symbol at the begging of the operand name.\n\n#### Operator Mapping\n\nMapping of the operators. The key is unique operator key, and the value is the key used to represent the given operator in the raw expression.\n\n```ts\noperatorMapping: Map\u003csymbol, string\u003e\n```\n\n**Default operator mapping:**\n\n```ts\n// Comparison\n;[Operator.EQ, '==']\n;[Operator.NE, '!=']\n;[(Operator.GT, '\u003e')]\n;[(Operator.GE, '\u003e=')]\n;[(Operator.LT, '\u003c')]\n;[(Operator.LE, '\u003c=')]\n;[(Operator.IN, 'IN')]\n;[(Operator.NOT_IN, 'NOT IN')]\n;[(Operator.PREFIX, 'PREFIX')]\n;[(Operator.SUFFIX, 'SUFFIX')]\n;[(Operator.OVERLAP, 'OVERLAP')]\n;[(Operator.UNDEFINED, 'UNDEFINED')]\n;[(Operator.PRESENT, 'PRESENT')]\n// Logical\n;[(Operator.AND, 'AND')]\n;[(Operator.OR, 'OR')]\n;[(Operator.NOR, 'NOR')]\n;[(Operator.XOR, 'XOR')]\n;[(Operator.NOT, 'NOT')]\n```\n\n\u003e The operator keys are unique symbols which could be imported from the engine package:\n\n```ts\nimport type { Operator } from '@spaceavocado/illogical'\n```\n\n---\n\n## Contributing\n\nSee [contributing.md](contributing.md).\n\n## License\n\nIllogical is released under the MIT license. See [license.txt](license.txt).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fspaceavocado%2Fillogical","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fspaceavocado%2Fillogical","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fspaceavocado%2Fillogical/lists"}