JsonLang Extension for Logical Operations
npm install @jsonlang/logicIt is JsonLang Plugin/Extension for Logical operations.










``bash`
npm install @jsonlang/core @jsonlang/logic
` js
import { JsonLang } from '@jsonlang/core';
import { LogicRules } from '@jsonlang/logic';
const jsonLang = new JsonLang();
jsonLang.import(LogicRules);
`
* And or &&
* Input[]: Array
* Output: Boolean (true or false).
* Description: Do the Anding operation, if any value in Input[] has a value of (null, 0, false), it will return false, else it will return true.
* Or or ||
* Input[]: Array
* Output: Boolean (true or false).
* Description: Do the Oring operation, if all values in Input[] has a value of (null, 0, false), it will return false, else it will return true .Equal
* Equal or ==
* Input[]: Array
* Output: Boolean (true or false).
* Description: It takes an array of 2 inputs to compare if element one element two or not.
* NotEqual or =
* Input[]: Array
* Output: Boolean (true or false).
* Description: It takes an array of 2 inputs to compare if element one Not Equal to element two or not.
* Not or !
* Input[]: Array
* Output: Boolean (true or false).
* Description: It takes an array of 1 input inverts its value. If it true it will return false and vice versa.
* GreaterThan or >
* Input[]: Array
* Output: Boolean (true or false).
* Description: It takes an array of 2 inputs to compare if element one Greater Than element two or not.
* LessThan or <
* Input[]: Array
* Output: Boolean (true or false).
* Description: It takes an array of 2 inputs to compare if element one Less Than element two or not.
* GreaterThanOrEqual or >=
* Input[]: Array
* Output: Boolean (true or false).
* Description: It takes an array of 2 inputs to compare if element one Greater Than or Equal element two or not.
* LessThanOrEqual or <=
* Input[]: Array
* Output: Boolean (true or false).
* Description: It takes an array of 2 inputs to compare if element one Less Than or Equal element two or not.
* More...
`js
import { JsonLang } from '@jsonlang/core';
import { LogicRules } from '@jsonlang/logic';
const jsonLang = new JsonLang();
jsonLang.import(LogicRules);
jsonLang.execute( { "$R": "LessThan" , "$I": [10, 20] }, undefined, { sync: true } ); // true
// or for short
jsonLang.execute( { "$R": "<" , "$I": [10, 20] }, undefined, { sync: true } ); // true
// or use the async function
jsonLang.execute( { "$R": "<" , "$I": [10, 20] } )
.then(result => {
console.log(result); // true
});
`
This library uses Array.map and Array.reduce`, so it's not exactly Internet Explorer 8 friendly.
JsonLang/Logic is MIT licensed