https://github.com/networkteam/eel
NPM package @networkteam/eel - Embedded expression language, a parser and compiler for a safe subset of JavaScript for dynamic evaluation in JavaScript.
https://github.com/networkteam/eel
Last synced: about 2 months ago
JSON representation
NPM package @networkteam/eel - Embedded expression language, a parser and compiler for a safe subset of JavaScript for dynamic evaluation in JavaScript.
- Host: GitHub
- URL: https://github.com/networkteam/eel
- Owner: networkteam
- License: mit
- Created: 2019-05-06T09:39:18.000Z (almost 7 years ago)
- Default Branch: master
- Last Pushed: 2024-06-20T14:48:02.000Z (almost 2 years ago)
- Last Synced: 2025-10-12T15:25:57.262Z (6 months ago)
- Language: JavaScript
- Size: 1.01 MB
- Stars: 1
- Watchers: 3
- Forks: 1
- Open Issues: 12
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# @networkteam/eel
**Embedded expression language, a parser and compiler for a safe subset of JavaScript for dynamic evaluation in JavaScript.**
## Features
* Safe evaluation of JS expressions:
* `!a || (b && c)`
* `number == 42`
* `foo.bar.baz`
* `foo["bar"].baz`
* `myFn(1, 2, 3)`
* `myObj.method(arg1).prop`
* Compiles expressions from strings to plain JS functions
* Safe to use with user generated expressions (e.g. as a filter language)
* Use in the browser or with Node.js
## Installation
yarn add @networkteam/eel
or
npm install --save @networkteam/eel
## Usage
```
import { compile } from '@networkteam/eel`
const expr = compile('myVar');
const result = expr({myVar: 'a', 'otherVar': b});
// result === 'a'
```
Ideally, the expression should be pre-compiled. The generated function
can be used with different context values to evaluate the result.
## Reference
**compile(expression)**
`expression`: string
Compiles the given expression and returns a function that receives
the current context for evaluation. The context must be an object that
contains all defined variables as properties.
## Licence
MIT