@intlayer/core
Version:
Includes core Intlayer functions like translation, dictionary, and utility functions shared across multiple packages.
25 lines (23 loc) • 868 B
JavaScript
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
const require_runtime = require('../_virtual/_rolldown/runtime.cjs');
const require_utils_intl = require('../utils/intl.cjs');
let _intlayer_config_built = require("@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(1200); // "1.2K"
*
* @example
* compact("1000000", { locale: Locales.FRENCH, compactDisplay: "long" });
* // "1 million"
*/
const compact = (value, options) => require_utils_intl.getCachedIntl(Intl.NumberFormat, options?.locale ?? _intlayer_config_built.internationalization?.defaultLocale, {
...options,
notation: "compact"
}).format(Number(value));
//#endregion
exports.compact = compact;
//# sourceMappingURL=compact.cjs.map