# xparse

> Flexible expression parser for computing user defined conditionals

Latest version **1.0.0** (published 2017-01-24) · Apache-2.0 license · 0 weekly downloads

## Install

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

## 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 | 2017-01-24 |
| First published | 2017-01-24 |
| Weekly downloads | 0 |
| License | Apache-2.0 |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Peter Lee |
| Maintainers | corenova |
| Keywords | parse, expression, operator, evaluate, validate, object |

## Links

- npm: https://www.npmjs.com/package/xparse
- Repository: https://github.com/corenova/xparse
- Issues: https://github.com/corenova/xparse/issues
- npm.io page: https://npm.io/package/xparse

## Dependencies (1)

- [comparse](https://npm.io/package/comparse.md) ^0.9.3

## Alternatives

- [babylon](https://npm.io/package/babylon.md) — 5.1M weekly downloads
- [csscolorparser](https://npm.io/package/csscolorparser.md) — 3.7M weekly downloads
- [expr-eval-fork](https://npm.io/package/expr-eval-fork.md) — 1.5M weekly downloads
- [@leeoniya/ufuzzy](https://npm.io/package/@leeoniya/ufuzzy.md) — 247.7K weekly downloads
- [xml-parser](https://npm.io/package/xml-parser.md) — 78.4K weekly downloads

## Recent versions

- 1.0.0 (latest) — 2017-01-24

## README

# xparse

Flexible expression parser for computing user defined conditionals

You can reference annotated source code
[here](./src/xparse.litcoffee).

## Usage

```bash
$ npm install xparse
```

```javascript
const xparse = require('xparse');

var expr = xparse("25 * 4");
expr() // returns 100
```

## Dynamic Variables

```javascript
var variables = {
  hello: 70
}
var resolver = (key) => variables[key]
var expr = xparse("hello < 25 * 4");
expr(resolver) // returns true (since 70 is less than 25 * 4)

variables.hello = 125
expr(resolver) // returns false (since 125 is not less than 25 * 4)
```

## Dynamic Functions

```javascript
var functions = {
  increment: (arg) => { arg + 1 }
  decrement: (arg) => { arg - 1 }
}
var resolver = (key, arg) => { functions[key](arg) }
var expr = xparse("increment(70) < 25 * 4");
expr(resolver) // returns true (since 71 is less than 25 * 4)

functions.increment = (arg) => { arg + 100 }
expr(resolver) // returns false (since 170 is not less than 25 * 4)
```

## License
  [Apache 2.0](LICENSE)

This software is brought to you by
[Corenova Technologies](http://www.corenova.com). We'd love to hear
your feedback.  Please feel free to reach me at <peter@corenova.com>
anytime with questions, suggestions, etc.

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