orcid-parser
    Preparing search index...

    Function fromString

    • Parses a string into a valid WorkType constant.

      Parameters

      • str: string

        Input string to parse (case-insensitive, whitespace-flexible)

      Returns WorkType

      Corresponding WorkType constant, or WORK_TYPES.UNSUPPORTED if not found

      This function attempts to match the input string in multiple ways:

      1. First tries to match against WORK_TYPES constant names (e.g., "JOURNAL_ARTICLE")
      2. Falls back to matching against actual type values (e.g., "journal-article")
      3. Returns WORK_TYPES.UNSUPPORTED if no match is found

      The matching is case-insensitive and handles various whitespace formats.

      // From constant name (case-insensitive)
      WorkType.fromString('ARTICLE');
      // Returns: 'journal-article'

      WorkType.fromString('conference paper');
      // Returns: 'conference-paper'

      // From actual type value
      WorkType.fromString('journal-article');
      // Returns: 'journal-article'

      // Unknown types
      WorkType.fromString('unknown-type');
      // Returns: 'unsupported'

      // Flexible whitespace handling
      WorkType.fromString(' JOURNAL ARTICLE ');
      // Returns: 'journal-article'