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

math-expression-parse

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

math-expression-parse

a simple parser for javascript math expression

  • 1.0.2
  • unpublished
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
0
Maintainers
1
Weekly downloads
 
Created
Source

math-expression-parse(数学表达式解析)

安装

npm i math-expression-parse

使用

import {parse} from "math-expression-parse"

let data = {
    "字段1":"100",
    "字段2":"200"
}
let expression = "sum({字段1},{字段2})"

console.log(parse(data,expression)) //打印:300

公式介绍:

基本:

  • 简单使用:{字段1}
  • 拼接字段:{字段1}{字段2}

条件:

  • 条件语句:condition(条件,条件为真返回值,条件为假返回值)

数学:

  • 求和:sum({字段1},{字段2})
  • 取最大:max({字段1},{字段2})
  • 取平均数:average({字段1},{字段2})
  • 向下保留精度:floor({字段1},int 精度)
  • 两数相除:divide({字段1},{字段2})
  • 向上保留精度:ceil({字段1},int 精度)
  • 两数相减:sub({字段1},{字段2})
  • 四舍五入:round({字段1},int 精度)

Keywords

FAQs

Package last updated on 24 Feb 2022

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