From ffde6fe4ff2f0c3bbc09903099cd96d67c9faebf Mon Sep 17 00:00:00 2001 From: hustcc Date: Fri, 28 Mar 2025 09:52:48 +0800 Subject: [PATCH 1/2] docs: update readme desc --- .github/workflows/{ci.yml => build.yml} | 2 +- README.md | 31 ++++++++++++++++++++++--- 2 files changed, 29 insertions(+), 4 deletions(-) rename .github/workflows/{ci.yml => build.yml} (98%) 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..a99069e 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,24 @@ -# @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 +{ + fill: "{ d.value > 100 ? 'red' : 'green' }", // Equivalent to function: `d => 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 +41,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 From 04d46c26b5fd49b7897fd5c48995e9b61cdfc028 Mon Sep 17 00:00:00 2001 From: hustcc Date: Fri, 28 Mar 2025 09:54:46 +0800 Subject: [PATCH 2/2] docs: update --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index a99069e..591e7a3 100644 --- a/README.md +++ b/README.md @@ -15,7 +15,8 @@ Used to parse a _mathematical expressions_ to _JavaScript function_ safely. For ```ts { - fill: "{ d.value > 100 ? 'red' : 'green' }", // Equivalent to function: `d => d.value > 100 ? 'red' : 'green'` + // Equivalent to function: `d => d.value > 100 ? 'red' : 'green'` + fill: "{ d.value > 100 ? 'red' : 'green' }", } ```