# tallycat-parser

> This the parser for [Tallycat](https://apps.josh.earth/tallycat/). It uses a parser grammar using [OhmJS](https://ohmlang.github.io)

Latest version **0.0.3** (published 2020-12-13) · ISC license · 0 weekly downloads

## Install

```sh
npm install tallycat-parser
pnpm add tallycat-parser
yarn add tallycat-parser
bun add tallycat-parser
```

## Health

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

Positive: esm support; no vulnerabilities.

Warnings: low downloads; no types; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.3 |
| Published | 2020-12-13 |
| First published | 2020-12-13 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | ESM + CommonJS |
| Dependencies | 1 |
| Unpacked size | 73.2 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Maintainers | joshmarinacci |

## Links

- npm: https://www.npmjs.com/package/tallycat-parser
- npm.io page: https://npm.io/package/tallycat-parser

## Dependencies (1)

- [ohm-js](https://npm.io/package/ohm-js.md) ^15.3.0

## Recent versions

- 0.0.3 (latest) — 2020-12-13
- 0.0.2 — 2020-12-13
- 0.0.1 — 2020-12-13

## README

This the parser for [Tallycat](https://apps.josh.earth/tallycat/). 
It uses a parser grammar using [OhmJS](https://ohmlang.github.io)

The parser can do arithmetic (+ - / *) on numbers with units. For example the string `2ft * 3` will return
`6 feet` as an object. It understand common imperial and metric units for length, weight, time, area,
volume, and more.

Here's a few more simple examples.


```
2ft * 2ft * 2ft as gal => 59.8442 gallons
2 TB as GB => 2000 gigabytes
2 TiB as GiB => 2048 gibibytes
5 years as seconds => 157680000 seconds
```


Use the library from node like this:

```javascript

import {Parser} from "tallycat-parser";

let result = Parser.parseString('4ft * 6');
console.log(result.toString())
// prints Literal 24 1*foot^1 / 
```

`Parser.parseString` returns a `LiteralNumber` object. To get the numeric value call `getValue()`. To print the rest of the structure call:

```javascript
console.log(result.getValue())
result._numers.forEach(n => {
    console.log(n.getName(),n.getDimension(),n.getFactor())
})
result._denoms.forEach(n => {
    console.log(n.getName(),n.getDimension(),n.getFactor())
})

```

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