diff --git a/.github/workflows/ci.yml b/.github/workflows/build.yml similarity index 98% rename from .github/workflows/ci.yml rename to .github/workflows/build.yml index 2257962..8eb295e 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/build.yml @@ -1,4 +1,4 @@ -name: CI +name: build on: push: diff --git a/README.md b/README.md index 46f9054..591e7a3 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,25 @@ -# @antv/expr ![gzip size](https://img.badgesize.io/https://unpkg.com/@antv/expr/dist/index.esm.js?compression=gzip) +
-Have you ever wanted to make your SSR charts more dynamic but worried about security risks? +

@antv/expr: Mathematical Expression Parser

+ +Lightweight JavaScript expression parser and evaluator, safety and high-performance. 🚀 + +![gzip size](https://img.badgesize.io/https://unpkg.com/@antv/expr/dist/index.esm.js?compression=gzip) +[![Build Status](https://github.com/antvis/expr/actions/workflows/build.yml/badge.svg)](https://github.com/antvis/expr/actions/workflows/build.yml) +[![npm Version](https://img.shields.io/npm/v/@antv/expr.svg)](https://www.npmjs.com/package/@antv/expr) +[![npm Download](https://img.shields.io/npm/dm/@antv/expr.svg)](https://www.npmjs.com/package/@antv/expr) + +
+ +Used to parse a _mathematical expressions_ to _JavaScript function_ safely. For example, in [@antv/g2](https://github.com/antvis/expr), we can set the style with an expressions. + +```ts +{ + // Equivalent to function: `d => d.value > 100 ? 'red' : 'green'` + fill: "{ d.value > 100 ? 'red' : 'green' }", +} +``` -We've got you covered! Our solution introduces an easy-to-use template syntax that safely serializes functions, allowing you to dynamically render charts without compromising security. 🚀 ## ✨ Features @@ -25,6 +42,15 @@ pnpm add @antv/expr ## 🔨 Usage +- [Synchronous Expression Evaluation](#synchronous-expression-evaluation) +- [Pre-compiling Expressions](#pre-compiling-expressions) +- [Registering and Calling Functions](#registering-and-calling-functions) +- [Variable References](#variable-references) +- [Arithmetic Operations](#arithmetic-operations) +- [Comparison and Logical Operations](#comparison-and-logical-operations) +- [Conditional (Ternary) Expressions](#conditional-ternary-expressions) +- [Timeout Handling](#timeout-handling) + ### Synchronous Expression Evaluation ```typescript