# pip-services3-expressions-nodex

> Tokenizers, parsers and expression calculators for Pip.Services in Node.js / ES2017

Latest version **1.0.4** (published 2023-04-03) · MIT license · 0 weekly downloads

## Install

```sh
npm install pip-services3-expressions-nodex
pnpm add pip-services3-expressions-nodex
yarn add pip-services3-expressions-nodex
bun add pip-services3-expressions-nodex
```

## Health

**Score 25/100 (F)** — status: abandoned.

Positive: has types; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.4 |
| Published | 2023-04-03 |
| First published | 2021-03-22 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Node | >=14.0.0 |
| Dependencies | 1 |
| Unpacked size | 832.2 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Conceptual Vision Consulting LLC |
| Maintainers | seroukhov, pipdeveloper |
| Keywords | pip.services, microservice, expressions |

## Links

- npm: https://www.npmjs.com/package/pip-services3-expressions-nodex
- Repository: https://github.com/pip-services3-nodex/pip-services3-expressions-nodex
- Homepage: https://github.com/pip-services3-nodex/pip-services3-expressions-nodex#readme
- Issues: https://github.com/pip-services3-nodex/pip-services3-expressions-nodex/issues
- npm.io page: https://npm.io/package/pip-services3-expressions-nodex

## Dependencies (1)

- [pip-services3-commons-nodex](https://npm.io/package/pip-services3-commons-nodex.md) ^1.0.4

## Recent versions

- 1.0.4 (latest) — 2023-04-03
- 1.0.3 — 2023-02-06
- 1.0.2 — 2021-03-22
- 1.0.1 — 2021-03-22
- 1.0.0 — 2021-03-22

## README

# <img src="https://uploads-ssl.webflow.com/5ea5d3315186cf5ec60c3ee4/5edf1c94ce4c859f2b188094_logo.svg" alt="Pip.Services Logo" width="200"> <br/> Tokenizers, parsers and expression calculators in Node.js / ES2017

This module is a part of the [Pip.Services](http://pip.services.org) polyglot microservices toolkit.
It provides syntax and lexical analyzers and expression calculator optimized for repeated calculations.

The module contains the following packages:
- **Calculator** - Expression calculator
- **CSV** - CSV tokenizer
- **IO** - input/output utility classes to support lexical analysis
- **Mustache** - Mustache templating engine
- **Tokenizers** - lexical analyzers to break incoming character streams into tokens
- **Variants** - dynamic objects that can hold any values and operators for them

<a name="links"></a> Quick links:

* [API Reference](https://pip-services3-nodex.github.io/pip-services3-expressions-nodex/globals.html)
* [Change Log](CHANGELOG.md)
* [Get Help](http://docs.pipservices.org/get_help/)
* [Contribute](http://docs.pipservices.org/contribute/)

## Use

Install the NPM package as
```bash
npm install pip-services3-expressions-nodex --save
```

The example below shows how to use expression calculator to dynamically
calculate user-defined expressions.

```typescript
import { IConfigurable } from 'pip-services3-commons-nodex';
import { ConfigParams } from 'pip-services3-commons-nodex';
import { IReferenceable } from 'pip-services3-commons-nodex';
import { IReferences } from 'pip-services3-commons-nodex';
import { Descriptor } from 'pip-services3-commons-nodex';
import { IOpenable } from 'pip-services3-commons-nodex';

...
let calculator = new ExpressionCalculator();

calculator.expression = "A + b / (3 - Max(-123, 1)*2)";

let vars = new VariableCollection();
vars.add(new Variable("A", new Variant(1)));
vars.add(new Variable("B", new Variant("3")));

let result = await calculator.evaluateWithVariables(vars);
console.log("The result of the expression is " + result.asString);
...
```

This is an example to process mustache templates.

```typescript
let mustache = new MustacheTemplate();
mustache.template = "Hello, {{{NAME}}}{{#ESCLAMATION}}!{{/ESCLAMATION}}{{#unless ESCLAMATION}}.{{/unless}}";
let result = mustache.evaluateWithVariables({ NAME: 'Mike', ESCLAMATION: true });
console.log("The result of template evaluation is '" + result + "'");
```

## Develop

For development you shall install the following prerequisites:
* Node.js 8+
* Visual Studio Code or another IDE of your choice
* Docker
* Typescript

Install dependencies:
```bash
npm install
```

Compile the code:
```bash
tsc
```

Run automated tests:
```bash
npm test
```

Generate API documentation:
```bash
./docgen.ps1
```

Before committing changes run dockerized build and test as:
```bash
./build.ps1
./test.ps1
./clear.ps1
```

## Contacts

The module is created and maintained by **Sergey Seroukhov**.

---
_Source: https://npm.io/package/pip-services3-expressions-nodex · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
