Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/dqbd/ts-math-evaluate
Type-level math expression evaluator for TypeScript.
https://github.com/dqbd/ts-math-evaluate
math parser type-level-programming typescript
Last synced: 27 days ago
JSON representation
Type-level math expression evaluator for TypeScript.
- Host: GitHub
- URL: https://github.com/dqbd/ts-math-evaluate
- Owner: dqbd
- Created: 2022-11-23T15:32:56.000Z (about 2 years ago)
- Default Branch: main
- Last Pushed: 2023-06-05T15:05:27.000Z (over 1 year ago)
- Last Synced: 2024-12-29T03:12:18.599Z (about 1 month ago)
- Topics: math, parser, type-level-programming, typescript
- Language: TeX
- Homepage: https://ts-math-evaluate.vercel.app/
- Size: 13.3 MB
- Stars: 12
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
Awesome Lists containing this project
README
![TS-Math-Evaluate](https://raw.githubusercontent.com/dqbd/ts-math-evaluate/main/assets/cover.svg)
# TS-Math-Evaluate
`ts-math-evaluate` is a type-level library for evaluating mathematical expressions in TypeScript, developed as a master thesis, implementing core mathematical operations and the accompanying evaluator, demonstrating the power of the TypeScript type system and the ability to perform complex meta-programming within the type system itself.
Alongside the evaluator, the expression parser and the accompanying parser generator can accept any LL(1) grammar and can be used to parse more complex formats, such as JSON. Finally, a benchmarking tool is provided, which can be used to benchmark any type-level code in isolation, keeping all the test cases in a single file.
A comprehensive guide to the TypeScript syntax and type-level programming techniques is provided to broaden the understanding of the capabilities of this language, seen [here (ctufit-thesis.pdf)](https://github.com/dqbd/ts-math-evaluate/blob/c7e71ed156ba0349e658ae805684cf46ecdc744d/thesis/ctufit-thesis.pdf).
## Installation
```bash
npm install ts-math-evaluate
```## Usage
```typescript
import type { Evaluate } from "ts-math-evaluate"type Basic = Evaluate<
"3.1 + 2.5 * (1 - 5.6) / 4.2"
>type Advanced = Evaluate<
"truncate(root(4, 2))! * -floor(1.5) + abs(-1) + ceil(root(4, 2))"
>
```For full documentation, please visit [https://ts-math-evaluate.vercel.app/](https://ts-math-evaluate.vercel.app/).