lib/impl/submissionExportHelper/csvHeaders.js
function generateCSVHeader(csv, field, headerName, fieldRepeatIndex) {

  //If the previous csv value is set, then a ',' is needed to separate.
  if (csv) {
    csv += ',';
  }

  // Sanity check after the headers to ensure we don't have a double ,, appearing
  // The above if is necessary and cannot be removed
  if (endsWith(csv, ',,')) {
    csv = csv.slice(0, -1);
  }

  csv += generateFieldHeader(field, headerName, fieldRepeatIndex);

  return csv;
}
function generateCSVHeader(csv, field, headerName, fieldRepeatIndex) {

  //If the previous csv value is set, then a ',' is needed to separate.
  if (csv) {
    csv += ',';
  }

  // Sanity check after the headers to ensure we don't have a double ,, appearing
  // The above if is necessary and cannot be removed
  if (endsWith(csv, ',,')) {
    csv = csv.slice(0, -1);
  }

  csv += generateFieldHeader(field, headerName, fieldRepeatIndex);

  return csv;
}
function generateCSVHeader ( csv , field , headerName , fieldRepeatIndex ) { //If the previous csv value is set, then a ',' is needed to separate. if ( csv ) { csv += ',' ; } // Sanity check after the headers to ensure we don't have a double ,, appearing // The above if is necessary and cannot be removed if ( endsWith ( csv , ',,' ) ) { csv = csv . slice ( 0 , - 1 ) ; } csv += generateFieldHeader ( field , headerName , fieldRepeatIndex ) ; return csv ; }
generateCSVHeader - Generating the Headers For All Of The Fields In The CSV

@param  {string} csv              Existing CSV String.
@param  {object} field            Field definition
@param  {string} headerName       Header Name to add
@param  {number} fieldRepeatIndex The index of a repeating field (null if it is not repeating)
@return {string}                  Generated CSV
generateCSVHeader - Generating the Headers For All Of The Fields In The CSV