UNPKG

@intlayer/core

Version:

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

1 lines 902 B
{"version":3,"file":"number.mjs","names":[],"sources":["../../../src/formatters/number.ts"],"sourcesContent":["import configuration from '@intlayer/config/built';\nimport type { LocalesValues } from '@intlayer/types';\nimport { Intl as CachedIntl } from '../utils/intl';\n\n/**\n * Formats a numeric value using locale-aware formatting.\n *\n * @example\n * number({ value: 123456.789 }); // \"123,456.789\"\n * number({ value: \"1000000\", locale: Locales.FRENCH }); // \"1 000 000\"\n */\nexport const number = (\n value: string | number,\n options?: Intl.NumberFormatOptions & { locale?: LocalesValues }\n): string =>\n new CachedIntl.NumberFormat(\n options?.locale ?? configuration?.internationalization?.defaultLocale,\n options\n ).format(Number(value));\n"],"mappings":";;;;;;;;;;;AAWA,MAAa,UACX,OACA,YAEA,IAAI,WAAW,aACb,SAAS,UAAU,eAAe,sBAAsB,eACxD,QACD,CAAC,OAAO,OAAO,MAAM,CAAC"}