src/common/end-of-line.js/countEndOfLineChars
function countEndOfLineChars(text, eol) {
  let regex;

  switch (eol) {
    case "\n":
      regex = /\n/g;
      break;
    case "\r":
      regex = /\r/g;
      break;
    case "\r\n":
      regex = /\r\n/g;
      break;
    default:
      /* istanbul ignore next */
      throw new Error(`Unexpected "eol" ${JSON.stringify(eol)}.`);
  }

  const endOfLines = text.match(regex);
  return endOfLines ? endOfLines.length : 0;
}