1.0.7 • Published 2 years ago

@astii/expression-sandbox v1.0.7

Weekly downloads
-
License
ISC
Repository
github
Last release
2 years ago

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

  1. {expression}
  2. {expression}-{expression}
1.0.7

2 years ago

1.0.6

2 years ago

1.0.5

2 years ago

1.0.4

2 years ago

1.0.3

2 years ago

1.0.2

2 years ago

1.0.1

2 years ago

1.0.0

2 years ago