tamcher
TypeScript icon, indicating that this package has built-in type declarations

1.1.1 • Public • Published

Tamcher test workflow

Make composable text matchers.

Install

yarn add tamcher --save

Use

    import { mm } from 'tamcher';

    let mNumber = mm.mr(/^(\d*)(.*)/s, 'number'); // returns a matcher

    mNumber('333') // returns { number: '333' }

See esra for an example use of this library, that parses chess PGN files.

Matchers

import { mm } from 'tamcher';

mm.mr(/regex/, matcherType) Match a regex

Regex Format Regex has to match the rest of the string at the end, so it has to be in this format: /^Extra(YourCapturingGroup)Extra(.*)/s

mm.mseq3([matcher, matcher, matcher], reducer) Match three matchers in sequence:

reducer is a Reducer that defines how to combine the three matchers.

mm.mstar(matcher) Match a matcher greedily

mm.mgroup(matcher, mm.oneMatcherNode(matcherType)) Group a matcher into an object

See matchmaker.ts for all matchers.

Reducers

You can make a reducer for selecting matchers like this: _ => _[0].

import { rr } from 'tamcher';

rr.fFirstTwo(matcherType) Array of first two matchers wrapped to an object with key matcherType.

rr.fLastTwo(matcherType)

rr.fAll(matcherType) Array all matchers

See reducers.ts for all reducers.

Dependencies (0)

    Dev Dependencies (3)

    Package Sidebar

    Install

    npm i tamcher

    Weekly Downloads

    2

    Version

    1.1.1

    License

    MIT

    Unpacked Size

    65.8 kB

    Total Files

    51

    Last publish

    Collaborators

    • eguneys