@surface/expression
TypeScript icon, indicating that this package has built-in type declarations

1.0.0-dev.202208221519 • Public • Published

@surface/expression are a javascript subset that allows you to parse and evaluate the generated AST.

Supported Expressions:

  • ArrayExpression
  • ArrowFunctionExpression
  • AssignmentExpression
  • BinaryExpression
  • CallExpression
  • ChainExpression
  • ConditionalExpression
  • Identifier
  • Literal
  • LogicalExpression
  • MemberExpression
  • NewExpression
  • ObjectExpression
  • ParenthesizedExpression
  • RegExpLiteral
  • SequenceExpression
  • TaggedTemplateExpression
  • TemplateLiteral
  • ThisExpression
  • UnaryExpression
  • UpdateExpression

Notes that ArrowFunctionExpression does not supports Block Body.

Basic usage

import Expression from "@surface/expression";

const expression = Expression.parse("x + y");

const value = expression.evaluate({ x: 1, y: 2 });

console.log(value); // 3

Package Sidebar

Install

npm i @surface/expression

Weekly Downloads

2

Version

1.0.0-dev.202208221519

License

MIT

Unpacked Size

197 kB

Total Files

91

Last publish

Collaborators

  • hitalloexiled