@astii/expression-sandbox
v1.0.7
Published
<div align="center"> <img src="https://www.cryptocoinzone.com/wp-content/uploads/2021/11/Sandbox-SAND-logo.png" height="200"/> </div>
Downloads
26
Readme
expression-sandbox
a simple sandbox for execute JS expression, support as follows:
- custom prefix;
- template expression;
Install
npm install @astii/expression-sandbox --save
or
yarn add @astii/expression-sandbox
Usage
import { ExpressionSandbox } from '@astii/expression-sandbox'
const context = { a: 1 };
const expression = '{a}';
const sandbox = new ExpressionSandbox({context});
const ret = sandbox.executeWithTemplate(expression); //execute expression with template, ret: 1
or
const expression = 'a'
const ret = sandbox.execute(expression); //execute expression without template, ret: 1
Template
- {expression}
- {expression}-{expression}