function formatProblem(severity, message, location, diagnostics = []) {
      // Calculate maximum width of all lines
      let maxLine;
      if (location) {
        maxLine = diagnostics.reduce(
          (t, { location }) => Math.max(t, location.start.line),
          location.start.line
        );
      } else {
        maxLine = Math.max.apply(
          null,
          diagnostics.map(d => d.location.start.line)
        );
      }
      maxLine = maxLine.toString().length;

      let str = `${severity}: ${message}`;
      if (location) {
        str += entry(location, maxLine);
      }
      for (const diag of diagnostics) {
        str += entry(diag.location, maxLine, diag.message);
      }

      return str;
    }
/**
     * Returns a formatted representation of the one problem in the error.
     *
     * @param {import("./peg").Severity} severity Importance of the message
     * @param {string} message Test message of the problem
     * @param {import("./peg").LocationRange?} location Location of the problem in the source
     * @param {import("./peg").DiagnosticNote[]} diagnostics Additional notes about the problem
     * @returns {string}
     */
Returns a formatted representation of the one problem in the error.
Returns a formatted representation of the one problem in the error .
function formatProblem(severity, message, location, diagnostics = []) {
      let maxLine;
      if (location) {
        maxLine = diagnostics.reduce(
          (t, { location }) => Math.max(t, location.start.line),
          location.start.line
        );
      } else {
        maxLine = Math.max.apply(
          null,
          diagnostics.map(d => d.location.start.line)
        );
      }
      maxLine = maxLine.toString().length;
      let str = `${severity}: ${message}`;
      if (location) {
        str += entry(location, maxLine);
      }
      for (const diag of diagnostics) {
        str += entry(diag.location, maxLine, diag.message);
      }
      return str;
    }
function formatProblem ( severity , message , location , diagnostics = [ ] ) { let maxLine ; if ( location ) { maxLine = diagnostics . reduce ( ( t , { location } ) => Math . max ( t , location . start . line ) , location . start . line ) ; } else { maxLine = Math . max . apply ( null , diagnostics . map ( d => d . location . start . line ) ) ; } maxLine = maxLine . toString ( ) . length ; let str = ` ${ severity } ${ message } ` ; if ( location ) { str += entry ( location , maxLine ) ; } for ( const diag of diagnostics ) { str += entry ( diag . location , maxLine , diag . message ) ; } return str ; }
Returns a formatted representation of the one problem in the error.
Returns a formatted representation of the one problem in the error .
// Calculate maximum width of all lines