/**
 * Format a number between 0 and 1 as a percent with some special handling
 * around the edges where a value will round to either 100% or 0% even though
 * it's not _actually_ 100% or 0%.
 *
 * @param {number} percent
 * @returns {string}
 */
const formatPercent = function formatPercent(percent, options = {}) {
  const {
    locale = 'en-US',
    maximumFractionDigits = 1,
    minimumFractionDigits
  } = options;
  if (typeof percent !== 'number') return undefined;
  const formatPct = new Intl.NumberFormat(locale, {
    style: 'percent',
    maximumFractionDigits,
    minimumFractionDigits
  });
  if (percent < 1 && percent >= 0.9995) {
    return `>${formatPct.format(0.999)}`;
  }
  if (percent > 0 && percent < 0.0005) {
    return `<${formatPct.format(0.0005)}`;
  }
  return formatPct.format(percent);
};
export default formatPercent;