Skip to content

formatPercentage

Formats a number as a localized percentage. The input is treated as a ratio, so 0.875 becomes an 87.5%-style label depending on locale.

Importing

ts
import { formatPercentage } from '@almighty-shogun/utils';

Usage

ts
import { formatPercentage } from '@almighty-shogun/utils';

const completion = formatPercentage(0.875, 'en');

Parameters

value: number
Value to format.

locale?: Undefinable<string>
Locale override.

Returns

A localized percentage string. The input is treated as a ratio, so 0.5 represents fifty percent.

Uses

Type signature

ts
declare function formatPercentage(
    value: number,
    locale?: Undefinable<string>
): string;

All packages are released under the MIT License.