# microparser

> Generic text parsing library.

Latest version **8.0.0** (published 2019-07-29) · MIT license · 0 weekly downloads

## Install

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

## 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 | 8.0.0 |
| Published | 2019-07-29 |
| First published | 2016-01-25 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 3 |
| Unpacked size | 102.7 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Simon Robert |
| Maintainers | srob |
| Keywords | parser |

## Links

- npm: https://www.npmjs.com/package/microparser
- Repository: https://github.com/srobfr/microparser
- Homepage: https://github.com/srobfr/microparser#readme
- Issues: https://github.com/srobfr/microparser/issues
- npm.io page: https://npm.io/package/microparser

## Dependencies (3)

- [chalk](https://npm.io/package/chalk.md) ^2.4.2
- [debug](https://npm.io/package/debug.md) ^3.1.0
- [lodash](https://npm.io/package/lodash.md) ^4.17.11

## 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

- 8.0.0 (latest) — 2019-07-29
- 7.0.2 — 2019-02-20
- 7.0.1 — 2019-02-17
- 7.0.0 — 2019-02-17
- 6.1.0 — 2017-08-18
- 6.0.1 — 2017-08-16
- 6.0.0 — 2017-07-27
- 5.0.3 — 2017-04-24
- 5.0.2 — 2017-04-14
- 5.0.1 — 2017-03-31
- 4.0.1 — 2016-10-20
- 3.0.3 — 2016-04-28
- 3.0.2 — 2016-04-28
- 3.0.1 — 2016-04-26
- 3.0.0 — 2016-03-24
- … 4 more at https://npm.io/package/microparser/versions

## README

# microparser [![NPM version](https://badge.fury.io/js/microparser.svg)](http://badge.fury.io/js/microparser) [![Build Status](https://travis-ci.org/srobfr/microparser.svg?branch=master)](https://travis-ci.org/srobfr/microparser)

> Generic text parsing library.

## Install

Using [npm](https://www.npmjs.com/) :

    npm install microparser --save

Using [yarn](https://www.npmjs.com/package/yarnpkg) :

    yarn add microparser

## Usage

    const microparser = require("microparser");

    const Parser = microparser.Parser;
    const {multiple, not, optional, optmul, or} = microparser.grammarHelpers;
    const parser = new Parser();

    // The code to parse.
    const code = "green, blue and red";

    // Grammar definition
    const color = or("green", "blue", "red", "yellow");
    const separator = g.or(", ", " and ");
    const grammar = multiple(color, separator);

    // Parsing
    const $ = parser.parse(grammar, code);

    console.log("\n#### Last color element value ####");
    console.log($.children[0].text());
    /* Output :
        #### Last color element value ####
        red
    */

A call to `parser.parse()` returns a (pseudo) DOM node, which allows you to do complex querying and manipulations.

See the `tests/examples` content for more complex examples.

## Author

**Simon Robert**

+ [github/srobfr](https://github.com/srobfr)
+ [twitter/srobfr](https://twitter.com/srobfr)

## License

Copyright © [Simon Robert](https://github.com/srobfr)

Released under the MIT license.

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