Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@jovercao/expr-engine

Package Overview
Dependencies
Maintainers
1
Versions
13
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@jovercao/expr-engine

J3表达式引擎

  • 0.3.5
  • latest
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

表达式引擎

使用

import { create } from '@jovercao/expr-engine'

create().exec('$if($.test, "这个", "那个")', {
  /**
   * IF条件
   */
  test: true
})
// => '这个'

支持的内容

  • 变量/函数,必须以 $开头
  • 二运算符: ==, !=, ===, !==, <, <=, >, >=, <<,>>, >>>, +, -, *, /, %, **, |, ^, &
  • 一元运算符: -, +, !, ~
  • 逻辑运算符: &&, ||
  • 条件运算符: test ? consequent : alternate,亦可以使用 $if 函数替代

安全性

  • 环境隔离,表达式仅可访问 helpers 下的公共函数,即以$开头的成员
  • helpers函数,this 指向 helpers

扩展 helpers

new ExprEngin({
  helpers: {
    $hello(name: string) {
      return `hello ${name}`
    }
  }
})

FAQs

Package last updated on 11 Dec 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc