Skip to content

formatPercent — @gj-kit/format

A public function from @gj-kit/format. The signature below is taken directly from the 0.1.1 release declaration.

import { formatPercent } from '@gj-kit/format';
/**
* A 0-1 fraction as a percentage: `0.63` becomes `'63%'`. Closes the
* {@link storageRatio} to screen pipe inside this package.
*
* The `%` sign is a literal suffix with no space, pinned like the `₩` glyph in
* {@link formatKrw}. Intl's own percentage rendering moves the sign and inserts
* a no-break space in some locales (French renders `63` then a space then `%`),
* which is exactly the drift this package refuses to inherit.
*
* A ratio that rounds to zero renders `'0%'` — never `'-0%'`, whichever side of
* zero it came from.
*/
declare function formatPercent<TFallback = string>(ratio: number | null | undefined, options: FormatPercentOptions<TFallback>): string | TFallback;

This declaration is the source of truth for parameters, optionality, generics, return values, and public union/type contracts. Check the package golden path and this subpath’s import conditions for required environment, permission, and error boundaries before calling it.

  • Package: @gj-kit/format
  • Version: 0.1.1
  • Public entry: .
  • Source: GitHub