@sundersb/parser-mini

1.0.1 • Public • Published

parser-mini Readme

This library provides simple text parsing functionality.

Installation

Run the following command:

npm install --save @sundersb/parser-mini

Examples

const Parser = require('@sundersb/parser-mini');

const join = cs => cs.join('');

const lineBreakParser = Parser
    .char('\n')
    .or(Parser.string('\r\n'));

expect(lineBreakParser.parseText('\nText')).to.deep.equal({
    parsed: '\n',
    rest: 'Text'
});
expect(lineBreakParser.parseText('text')).to.be.undefined;

const untilSpaceParser = Parser.sat(c => c != ' ')
    .many()
    .fmap(join);

expect(untilSpaceParser.parseText('some text')).to.deep.equal({
    parsed: 'some',
    rest: ' text'
});

GitHub page

https://github.com/sundersb/parser-mini

See also

Readme

Keywords

Package Sidebar

Install

npm i @sundersb/parser-mini

Weekly Downloads

5

Version

1.0.1

License

ISC

Unpacked Size

29.6 kB

Total Files

6

Last publish

Collaborators

  • sundersb