open-index/open-npm huggingface dataset:
npm package: @liquidform/formula-lang
Description: LiquidForm's expressions are a subset of JavaScript expression syntax.
Latest version: 0.0.9

# An expression parser and executor for LiquidForm's formula language

LiquidForm's expressions are a subset of JavaScript expression syntax. 

They're used for field validation, computed fields and text templates.


## Literals
- numbers: `2`, `-3.6`
- strings: `'single quoted'`, `"double quoted"`
- booleans: `true`, `false`

## Identifiers
The lang supports identifiers and property chains. Bracket notation is also supported.

Identifiers are resolved from the `context.properties` object passed to the `evaluateExpression(expression:String, context:Context):any` method.


Examples
```js
person.addresses[0].street

listOfOptions[selectedOptionId].label
```

## Functions
Functions can be called to compute values. They must be present in the `context.functions` object passed to the `evaluateExpression(expression:String, context:Context):any` method.

Examples

```js
evaluateExpression(
    'Math.max(valueA, valueB)', 
    {
        functions : {Math},
        properties : {
            valueA : 12,
            valueB : 13
        }
    });
```

## Arithmetics
- `*` multiplication: `2 * 3 * 22`
- `/` division: `81 / 9`
- `+` addition: `2 + 2`
- `-` subtraction `7 -2`
- `%` modulus `5 % 2`

## Comparison
- `==` <u>strict</u> equality
- `!=` <u>strict</u> inequality
- `>` greater than
- `<` less than
- `>=` equal or greater than
- `<=` equal or less than

## Logical
- `&&` logical and 
- `||` logical or 

## Ternary operator
```js
//syntax
condition ? trueResult : falseResult

//example
carMakeField == 'Tesla' ? 'electric' : 'petrol'
```

## Unary operator
```js
 !false //== true 
```

## The `undefined` value
The syntax tries to steer away from `undefined` and throws a `ParseError` when it encounters one.