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

    Function tryParseNote

    • Parse a note name, reporting failure instead of throwing it.

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

      Parameters

      • text: string

        The note name.

      • Optionalopts: NoteNameOptions

        system reads the name in that notation system instead of detecting it.

      Returns ParseResult<NoteData>

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

      import { tryParseNote } from '@libraz/libcantus';
      const result = tryParseNote('C#4');
      result.ok ? result.value.letter : result.error.message;