/** * Similar to a `NumberFormatPart` returned from NumberFormat.formatToParts, this represents and individual part * of a custom number format string. */ interface CustomNumberFormatPart { /** True if the placeholder is required, false or undefined otherwise. This is used to distinguish between `0` and `#` characters. */ required?: boolean; type: "decimal" | "exponentInteger" | "exponentMinusSign" | "exponentPlusSign" | "exponentSeparator" | "fraction" | "group" | "integer" | "literal" | "minusSign" | "percentSign" | "permilleSign"; value: string; } /** * Counts the number of decimal places in the specified custom format string and returns the result. * The supplied value is treated as one of Microsoft's [Custom numeric format strings](https://learn.microsoft.com/en-us/dotnet/standard/base-types/custom-numeric-format-strings) * * There are lots of unusual ways you can combine the supported characters, but for simplicity, we support the most common use case * which is using `#` and `0` as placeholders. * * In cases where the `;` section separator is used, the number of decimals in the format may vary depending on the current value being negative, positive or zero. * * @param customFormat The custom format to be inspected. * @param value The number being formatted. * @returns The number of decimal places in the section of `customFormat` used for the specified value. */ export declare function countDecimalsInCustomFormat(customFormat: string | undefined, value: number | undefined): number | undefined; /** * Inspects the supplied {@link customFormat} to determine which features of custom formatting are defined within. * @param customFormat The custom format string to be inspected. * @returns Details of the various features of custom formatting that are enabled. */ export declare function inspectCustomFormat(customFormat: string): { /** The value to multiply the actual value by before presenting it. For example, percentages are multiplied by 100. */ multiplier: number; /** All of the individual parts of the custom format string that will be visible. Group characters are added after the placeholders are populated. */ parts: CustomNumberFormatPart[]; /** True if the formatted value should include grouping characters between sets of integer digits. */ useGrouping: boolean; }; /** * Formats a number using the specified custom numeric format string. * * This follows the behaviour of Microsoft's .NET custom format strings as described here: * * https://learn.microsoft.com/en-us/dotnet/standard/base-types/custom-numeric-format-strings * * At this time, it does not yet support the `"\"` escape character or the `";"` section separator. * * @param value The numerical value to be formatted using a custom format. * @param customFormat The custom format string describing how to format the value. * @param locale The locale to be used to format the value. * @returns A string representation of the value, formatted based on the {@link customFormat}. */ export declare function customFormatNumber(value: number, customFormat: string, locale?: string): string; /** * Inspects a value that was formatted using a custom numeric format string and split it into parts. * This allows for inspection of the parts before ultimately combining them and converting the result * to a number. * @param formattedNumber A string representation of a value that was previously formatted using the {@link customFormat}. * @param locale The locale that was used to format the value. * @returns The previously formatted string broken into parts. */ export declare function parseCustomFormattedNumberToParts(formattedNumber: string, locale?: string): Intl.NumberFormatPart[]; /** * Parses a value that was formatted using the specified custom numeric format string. * @param formattedNumber A string representation of a value that was previously formatted using the {@link customFormat}. * @param customFormat The custom format string describing how the value was formatted. * @param locale The locale that was used to format the value. * @returns The numeric value represented by the previously formatted string. */ export declare function parseCustomFormattedNumber(formattedNumber: string, customFormat: string, locale?: string): number; export {};