npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

mathex-parseval

v1.0.0

Published

A package that lets you tokenize, parse and evaluate math expressions

Readme

MathEx-ParsEval

Description

MathEx-ParsEval is an npm package designed to tokenize, parse, and evaluate mathematical expressions efficiently. It helps process complex expressions by generating token lists, Abstract Syntax Trees (ASTs), and evaluating results.

Features

  • Tokenizes a given mathematical expression.
  • Generates an Abstract Syntax Tree (AST).
  • Evaluates the result of the expression using the AST.
  • Supports variable assignment, allowing previously assigned variables to be used in later expressions.
  • Supported Operators: +, -, *, /, (, ), =, ,
  • Supported Mathematical Functions:
    • abs (absolute value), acos (cosine inverse), asin (sine inverse), atan (tangent inverse), ceil (ceiling function), cos (cosine), exp (exponential function), floor (floor), log (logarithm), ln (natural logarithm), random (pseudorandom number between 0 and 1), sin (sine), sqrt (square root), tan (tangent)
  • Supported Constants:
    • e (value: 2.718281828459045)
    • pi (value: 3.141592653589793)

Installation

To install MathEx-ParsEval, run the following command:

npm i mathex-parseval

Usage

Here are some examples of how to use MathEx-ParsEval:

import { Expression } from "mathex-parseval";

const expr1 = new Expression("x = sin(pi/2) * sqrt(25) - 23");
console.log("Expression : ", expr1.getExpression());
console.log("Tokens : ", expr1.getTokenList());
console.dir(expr1.getAST(), { depth: null });
console.log(expr1.getResult()); // -18

const expr2 = new Expression("abs(2-x*-10)");
console.log("Expression : ", expr2.getExpression());
console.log("Tokens : ", expr2.getTokenList());
console.dir(expr2.getAST(), { depth: null });
console.log(expr2.getResult()); // 178

Contributing

Contributions are welcome! Please fork this repository, create a branch, and submit a pull request.

License

This project is licensed under the ISC License - see the LICENSE file for details.


For more information or to report issues, visit the GitHub repository.