Skip to content
中文

Actual rules for rejection checks and match short-circuiting ​

The policy implementation follows.

ts
export function breakWhile(
  occur: readonly BreakPredicate[],
  error?: BreakReason,
  tags?: readonly string[],
): void;

export function matchRule<Input, Result>(
  rules: readonly MatchRule<Input, Result>[],
  input: Input,
): Result | undefined {
  return rules
    .find(
      (rule) =>
        rule.pattern === undefined ||
        booleanResult(rule.pattern(input), 'Rule patterns must return boolean synchronously'),
    )
    ?.handle(input);
}

export function walkRules(rules: readonly WalkRule[]): void;

API reference, usage examples and developer guides.