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

    Type Alias ParseResult<T>

    ParseResult: { ok: true; value: T } | { ok: false; error: LibcantusError }

    The outcome of a parse that reports failure instead of throwing it.

    A text field is parsed on every keystroke, and most of those keystrokes are halfway through a valid symbol, so failure is the normal case rather than an exceptional one. The error travels in the result — not as null — because an input field has to say what is wrong with what was typed.

    Type Parameters

    • T

      The value a successful parse produces.

    import { tryParseChordSymbol } from '@libraz/libcantus';
    const result = tryParseChordSymbol('Cmaj');
    const label = result.ok ? result.value.quality : result.error.message;