@sundersb/parser-mini
v1.0.1
Published
Minimalistic text parser library
Downloads
56
Readme
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