import { PatternMatcher } from './PatternMatcher.js'; import { MatchesIdentical, MatchesRegExp } from './rules/index.js'; /** * @access private */ export class StringMatcher extends PatternMatcher { when(pattern: string | RegExp, transformation: (v: string) => Output_Type): PatternMatcher { const rule = pattern instanceof RegExp ? new MatchesRegExp(pattern, transformation) : new MatchesIdentical(pattern, transformation); return new StringMatcher( this.value, this.rules.concat(rule), ); } }