Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/uzmoi/parsea
parser combinator library for parsing array-like
https://github.com/uzmoi/parsea
array-like parser-combinator
Last synced: 27 days ago
JSON representation
parser combinator library for parsing array-like
- Host: GitHub
- URL: https://github.com/uzmoi/parsea
- Owner: uzmoi
- License: mit
- Created: 2021-08-08T09:03:30.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2024-10-12T10:18:36.000Z (3 months ago)
- Last Synced: 2024-11-18T17:16:36.821Z (about 1 month ago)
- Topics: array-like, parser-combinator
- Language: TypeScript
- Homepage:
- Size: 704 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# parsea
[![NPM Version][npm-badge]](https://www.npmjs.com/package/parsea)
[![JSR Version][jsr-badge]](https://jsr.io/@uzmoi/parsea)
[![License][license-badge]](https://opensource.org/license/MIT)
[![npm bundle size][bundle-size-badge]](https://bundlephobia.com/package/parsea)
[![Codecov][codecov-badge]](https://app.codecov.io/gh/uzmoi/parsea)[npm-badge]: https://img.shields.io/npm/v/parsea?style=flat-square
[jsr-badge]: https://img.shields.io/jsr/v/@uzmoi/parsea?style=flat-square
[license-badge]: https://img.shields.io/github/license/uzmoi/parsea?style=flat-square
[bundle-size-badge]: https://img.shields.io/bundlephobia/min/parsea?style=flat-square
[codecov-badge]: https://img.shields.io/codecov/c/gh/uzmoi/parsea?style=flat-squareparsea is a parser combinator library for parsing ArrayLike with TypeScript.
```ts
import * as P from "parsea";const parser = P.seq([
P.regex(/-?\d+(\.\d+)?/).map(Number.parseFloat),
P.regex(/[A-Z]+/i),
]).map(([value, unit]) => ({ value, unit }));P.parseA(parser, "273.15K"); // => { value: 273.15, unit: "K" }
```See also [examples/ directory](https://github.com/uzmoi/parsea/tree/main/examples).
Inspired by
- [loquat](https://github.com/susisu/loquat)
- [parsimmon](https://github.com/jneen/parsimmon)
- [parsec](https://github.com/haskell/parsec) (haskell)