calculatePrimaryLanguage = (files) => {
  const languages = {};
  for (const file of files) {
    if (file.language) {
      if (languages[file.language.name]) {
        languages[file.language.name] += file.size;
      } else {
        languages[file.language.name] = file.size;
      }
    }
  }
  let primaryLanguage = Object.keys(languages)[0];
  for (const language in languages) {
    if (languages[language] > languages[primaryLanguage]) {
      primaryLanguage = language;
    }
  }
  return primaryLanguage;
}
This function calculates the primary language of a gist by files size.

@param {GistFile[]} files Files.
@returns {string} Primary language.