/**
 * Function to find and return an array of the candidate IDs of a contest's
 * incumbents given an array of candidate metadata. Note that most major
 * contests will only have a single incumbent, but there are some edge cases
 * where a contest can have multiple winners elected to hold office, and
 * contests like that can have multiple incumbents.
 *
 * @param {CandidateMetadata[]} candidates
 *   An array of candidate metadata
 * @returns {CandidateId[]}
 */
const getIncumbentIds = function getIncumbentIds(candidates) {
  if (!candidates) return [];
  return candidates.filter(({
    isIncumbent
  }) => isIncumbent).map(({
    id
  }) => id);
};
export default getIncumbentIds;