1.0.1 • Published 1 year ago

@sundersb/parser-mini v1.0.1

Weekly downloads
-
License
ISC
Repository
github
Last release
1 year ago

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

1.0.1

1 year ago

1.0.0

1 year ago