Skip to content

v1.1.0 - Includes the `skip` combinator

Latest
Compare
Choose a tag to compare
@MCluck90 MCluck90 released this 17 Sep 16:36
· 4 commits to main since this release

It's common when parsing to want to match something, extract the value, match another parser, then use the original extracted value. Previously this was done with a pattern like this:

parser.bind(value => anotherParser.map(() => value)

This release includes the new skip combinator which simplifies this pattern.

parser.skip(anotherParser)

As with other combinators, it's chainable:

const parser = regexp(/a/y)
  .skip(regexp(/b/y))
  .skip(regexp(/c/y))
const result = parser.parseToEnd('abc')
result === 'a'