@libraz/libcantus - v1.1.0
    Preparing search index...

    Function tryParseTimeSignature

    • Parse a time signature, reporting failure instead of throwing it.

      The same reading as parseTimeSignature — that function is this one with its error thrown — for the callers where text that does not parse yet is the normal state of the input rather than a fault.

      Parameters

      • text: string

        The signature text.

      Returns ParseResult<TimeSignature>

      The signature, or the error explaining why the text is not one.

      import { tryParseTimeSignature } from '@libraz/libcantus';
      const result = tryParseTimeSignature('7/8');
      result.ok ? result.value.numerator : result.error.message;