UNPKG

@intlayer/core

Version:

Includes core Intlayer functions like translation, dictionary, and utility functions shared across multiple packages.

23 lines (21 loc) 683 B
import { CachedIntl } from "../utils/intl.mjs"; import configuration from "@intlayer/config/built"; //#region src/formatters/compact.ts /** * Formats a numeric value using compact notation (e.g., 1K, 1M, 1B) * based on locale and formatting options. * * @example * compact({ value: 1200 }); // "1.2K" * * @example * compact({ value: "1000000", locale: Locales.FRENCH, compactDisplay: "long" }); * // "1 million" */ const compact = (value, options) => new CachedIntl.NumberFormat(options?.locale ?? configuration?.internationalization?.defaultLocale, { ...options, notation: "compact" }).format(Number(value)); //#endregion export { compact }; //# sourceMappingURL=compact.mjs.map