/*
 * Copyright OpenSearch Contributors
 * SPDX-License-Identifier: Apache-2.0
 */

export const formatCount = value => {
  if (value === undefined || isNaN(value) || !isFinite(value)) return '0';
  if (value >= 1000000) return "".concat((value / 1000000).toFixed(1), "M");
  if (value >= 1000) return "".concat((value / 1000).toFixed(1), "K");
  return "".concat(value);
};