Skip to main content
Version: 1.3.3

buildMessageMatcher

A component that performs low-level matching for parseMessagePattern.

Syntax

buildMessageMatcher(formatters: string[]): MessageMatcher

Parameters

  • formatters: string[]
    • Array containing the names of your custom formatter functions.

Example

import { buildMessageMatcher, parseMessagePattern } from '@phensley/messageformat';

const message = '{0 foo}';

// No names specified, so 'foo' will not be detected as a valid formatter
let matcher = buildMessageMatcher([]);
let code = parseMessagePattern(message, matcher);
log(code);

// Now 'foo' shoulr parse as a formatter
matcher = buildMessageMatcher(['foo']);
code = parseMessagePattern(message, matcher);
log(code);
[ 5 ]
[ 6, 'foo', [ 0 ], [] ]

References