react-intlayer
Version:
Easily internationalize i18n your React applications with type-safe multilingual content management.
1 lines • 1.06 kB
Source Map (JSON)
{"version":3,"sources":["../../../../src/server/format/useCompact.ts"],"sourcesContent":["import { type LocalesValues } from '@intlayer/config/client';\nimport { compact } from '@intlayer/core';\nimport { IntlayerServerContext } from '../IntlayerServerProvider';\nimport { getServerContext } from '../serverContext';\n\n/**\n * React client hook that provides a compact number formatter\n * bound to the current application locale.\n *\n * @example\n * ```tsx\n * const formatCompact = useCompact();\n * formatCompact(1500); // \"1.5K\"\n * ```\n */\nexport const useCompact = () => {\n const locale = getServerContext<LocalesValues>(IntlayerServerContext);\n\n return (...args: Parameters<typeof compact>) =>\n compact(args[0], {\n ...args[1],\n locale: args[1]?.locale ?? locale,\n });\n};\n"],"mappings":"AACA,SAAS,eAAe;AACxB,SAAS,6BAA6B;AACtC,SAAS,wBAAwB;AAY1B,MAAM,aAAa,MAAM;AAC9B,QAAM,SAAS,iBAAgC,qBAAqB;AAEpE,SAAO,IAAI,SACT,QAAQ,KAAK,CAAC,GAAG;AAAA,IACf,GAAG,KAAK,CAAC;AAAA,IACT,QAAQ,KAAK,CAAC,GAAG,UAAU;AAAA,EAC7B,CAAC;AACL;","names":[]}