Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml → .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: CI
name: build

on:
push:
Expand Down
32 changes: 29 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,25 @@
# @antv/expr ![gzip size](https://img.badgesize.io/https://unpkg.com/@antv/expr/dist/index.esm.js?compression=gzip)
<div align="center">

Have you ever wanted to make your SSR charts more dynamic but worried about security risks?
<h1>@antv/expr: Mathematical Expression Parser</h1>

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)

</div>

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

Expand All @@ -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
Expand Down
Loading