/**
 * Get a candidate's formatted polarity from their metadata.
 *
 * @param {CandidateMetadata} candidate
 *   The metadata of the candidate whose name you want. If no metadata is
 *   provided or if the metadata doesn't contain a polarity this function
 *   returns `undefined`.
 * @param {object} opts
 * @param {'full'|'parenthesis'} [opts.format]
 * @returns {string}
 */
const getFormattedCandidatePolarity = function getFormattedCandidatePolarity(candidate = {}, opts = {}) {
  const {
    format
  } = opts;
  const {
    polarity
  } = candidate;
  if (typeof polarity !== 'boolean') return undefined;
  const name = polarity ? 'Yes' : 'No';
  if (format === 'parenthesis') return `(${name})`;
  return name;
};
export default getFormattedCandidatePolarity;