# matheval

> Math expression evaluator

Latest version **1.0.0** (published 2013-05-01) · 0 weekly downloads

## Install

```sh
npm install matheval
pnpm add matheval
yarn add matheval
bun add matheval
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.0 |
| Published | 2013-05-01 |
| First published | 2012-10-31 |
| Weekly downloads | 0 |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Known vulnerabilities | 0 (+2 in 1 direct dependencies) |
| Install scripts | no |
| GitHub stars | 2 |
| Author | Shaun Guth |
| Maintainers | l8nite |

## Links

- npm: https://www.npmjs.com/package/matheval
- Repository: https://github.com/l8nite/matheval
- Homepage: http://github.com/l8nite/matheval
- npm.io page: https://npm.io/package/matheval

## Dependencies (1)

- [underscore](https://npm.io/package/underscore.md) ~1.4.2

## Recent versions

- 1.0.0 (latest) — 2013-05-01
- 0.0.2 — 2012-10-31
- 0.0.1 — 2012-10-31

## README

_matheval_ is a node.js library that evaluates simple math expressions.
Supports variables, parentheses, basic functions.

## Example

    var evaluate = require('matheval').evaluate;

    evaluate('x = 1', console.log); // prints 1
    evaluate('x + 1', console.log); // prints 2

## Installation

    $ npm install matheval

## Variables
You can override Variables.js to supply your own variables (for example, you can load them from a database or something)

    var evaluate = require('./matheval.js').evaluate;
    var Variables = require('./matheval.js').Variables;

    var v = new Variables();

    evaluate('x = 1', v, function(result) {
        console.log(result);
        evaluate('x + 1', v, console.log);
    });

## Notes

unary minus is higher precedence than exponentiation, so -1**-2 === (-1)**(-2), not -(1**(-2))

exponentiation is right-associative, so 3**3**3 is 3**27, not 9**3

## Testing

The tests rely on [mocha](http://visionmedia.github.com/mocha/) and [should](https://github.com/visionmedia/should.js/)

To run them:

    $ npm test

---
_Source: https://npm.io/package/matheval · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
