# @ohmyverse/expression-manager

Latest version **0.0.2** (published 2022-11-30) · AGPL-3.0 license · 0 weekly downloads

## Install

```sh
npm install @ohmyverse/expression-manager
pnpm add @ohmyverse/expression-manager
yarn add @ohmyverse/expression-manager
bun add @ohmyverse/expression-manager
```

## Health

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

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

Warnings: low downloads; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.2 |
| Published | 2022-11-30 |
| First published | 2022-11-30 |
| Weekly downloads | 0 |
| License | AGPL-3.0 |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 5 |
| Unpacked size | 210.6 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 2 |
| Author | OhMyVerse SL - OhMyVerse.io |
| Maintainers | eibriel, pabloestornut |

## Links

- npm: https://www.npmjs.com/package/@ohmyverse/expression-manager
- Repository: https://github.com/Golfcraft/expression-manager
- Homepage: https://github.com/Golfcraft/expression-manager#readme
- Issues: https://github.com/Golfcraft/expression-manager/issues
- npm.io page: https://npm.io/package/@ohmyverse/expression-manager

## Dependencies (5)

- [jsep](https://npm.io/package/jsep.md) ^1.3.7
- [rollup-plugin-terser](https://npm.io/package/rollup-plugin-terser.md) ^7.0.2
- [rollup-plugin-commonjs](https://npm.io/package/rollup-plugin-commonjs.md) ^10.1.0
- [rollup-plugin-typescript2](https://npm.io/package/rollup-plugin-typescript2.md) ^0.34.1
- [rollup-plugin-node-resolve](https://npm.io/package/rollup-plugin-node-resolve.md) ^5.2.0

## Recent versions

- 0.0.2 (latest) — 2022-11-30
- 0.0.1 — 2022-11-30

## README

# @ohmyverse/expression-manager
## A library to manage and react to javascript expression evaluations


```js
import { createExpressionManager, EVENT } from '@ohmyverse/expression-manager'

const em = createExpressionManager({ a: 1, b: 2 }, { context: { giveMeFive: () => 5 } })
const control1 = em.addControl({ id: 1, runtime: { storage: 'a' } })
const control2 = em.addControl({ id: 2, runtime: { anyExpressionToRead: 'a + c || a && b' } })
em.addRuntimeAssignment({
    storage: 'c',
    expression: 'a + b + giveMeFive()'
})
em.onEvent(({ data, type }: any) => {
    if (type === EVENT.EVENT_VARIABLE_CHANGE) {
        const { targetControlIds, newValues, oldValues } = data
        //changed variables from {"a":1}  to  {"c":10,"a":3}  affects the controls : [2, 1]
        log('changed variables from', JSON.stringify(oldValues), ' to ', JSON.stringify(newValues), ' affects the controls :', targetControlIds)
    }
})
log('state before interacting with control1', em.getState()) //returns {a: 1, b: 2}
control1.setValue(3)
log('state after interacting with control1', em.getState()) //returns {a: 3, b: 2, c: 10}
```
####  (For more examples look src/index.test.ts)
Note that there is still missing options to document, we will be adding more documentation for runtime assignments like `timeout`, `condition`, `listen`, which are not explained in the example or tests for now, we need to eat and this doesn't give us food, but we will be improving docs over time.

## License

AGPL-3.0

If you need a different license for your company contact ohmyverse.io

---
_Source: https://npm.io/package/@ohmyverse/expression-manager · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
