Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/pokle/js-parser-combinators
Teeny tiny javascript parser combinators
https://github.com/pokle/js-parser-combinators
Last synced: 10 days ago
JSON representation
Teeny tiny javascript parser combinators
- Host: GitHub
- URL: https://github.com/pokle/js-parser-combinators
- Owner: pokle
- Created: 2017-04-18T15:36:26.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2017-05-26T09:19:32.000Z (over 7 years ago)
- Last Synced: 2024-09-21T18:39:38.875Z (about 2 months ago)
- Language: JavaScript
- Size: 7.81 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# js-parser-combinators
Building blocks to write your own tiny and fast parsers.
[![CircleCI](https://circleci.com/gh/pokle/js-parser-combinators.svg?style=svg&circle-token=e1ed0f751c2b44469e534ee8d709112ef5732245)](https://circleci.com/gh/pokle/js-parser-combinators)
```js
const P = require('js-parser-combinators')// A parser that can parse paths such as:
// /user/1234
// /user/1234/detailsconst parser = P.exhaustive(
P.and(
P.and(
P.literal('/user/'),
P.param('userid', /^\d+/, parseInt)
),
P.optional(P.literal('/details'))
)
);parser({ input: '/user/1234/details' }).ast
// => { userid: 1234 }
```
[Run this example on RunKit](https://runkit.com/pokle/js-parser-combinators-example1)