# typescript-parser-combinator

> A simple parser combinator in TypeScript.

Latest version **0.5.4** (published 2020-04-25) · ISC license · 0 weekly downloads

## Install

```sh
npm install typescript-parser-combinator
pnpm add typescript-parser-combinator
yarn add typescript-parser-combinator
bun add typescript-parser-combinator
```

## Health

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

Positive: has types; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.5.4 |
| Published | 2020-04-25 |
| First published | 2019-04-21 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 14.6 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | mal30 |
| Maintainers | mal30 |

## Links

- npm: https://www.npmjs.com/package/typescript-parser-combinator
- Repository: https://github.com/ljorring/typescript-parser-combinator
- Homepage: https://github.com/ljorring/typescript-parser-combinator#readme
- Issues: https://github.com/ljorring/typescript-parser-combinator/issues
- npm.io page: https://npm.io/package/typescript-parser-combinator

## Dependencies (1)

- [@types/rewire](https://npm.io/package/@types/rewire.md) ^2.5.28

## Recent versions

- 0.5.4 (latest) — 2020-04-25
- 0.5.3 — 2020-04-25
- 0.5.2 — 2019-05-14
- 0.5.1 — 2019-05-02
- 0.5.0 — 2019-05-02
- 0.3.8 — 2019-04-27
- 0.3.7 — 2019-04-27
- 0.3.6 — 2019-04-26
- 0.3.5 — 2019-04-26
- 0.3.4 — 2019-04-25
- 0.3.3 — 2019-04-25
- 0.3.2 — 2019-04-22
- 0.3.0 — 2019-04-22
- 0.2.2 — 2019-04-21
- 0.2.1 — 2019-04-21
- … 4 more at https://npm.io/package/typescript-parser-combinator/versions

## README

# TypeScript Parser Combinator

A simple parser combinator in TypeScript.

It has been built with the sole aim of learning parser combinators and npm package management.

## Getting Started

Consider the following

```
import { text, digits, takeUntil, char, unit, space, word, newLineToken, between } from 'typescript-parser-combinator'

let input = "Weather (today): Sunny\r\n" +
            "Weather (yesterday): Cloudy\r\n" +
            "Weather (one week ago): Rainy"

let parser = text('Weather')
                .then(space)
                .then(between(text('('),text(')')))            .take()
                .then(text(': '))                              .drop()
                .then(word)
                .then(newLineToken.maybe())                    .drop()
                .map(([date, weather]) => ({ date, weather }))
                .many1()

let result = parser(input)

if (result.success) {
    expect(result.value[0].date).to.equal('today')
    expect(result.value[0].weather).to.equal('Sunny')
    expect(result.value[1].date).to.equal('yesterday')
    expect(result.value[1].weather).to.equal('Cloudy')
    expect(result.value[2].date).to.equal('one week ago')
    expect(result.value[2].weather).to.equal('Rainy')
}

```

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