MCPcopy Index your code
hub / github.com/angular/angular / formatPercent

Function formatPercent

packages/common/src/i18n/format_number.ts:235–251  ·  view source on GitHub ↗
(value: number, locale: string, digitsInfo?: string)

Source from the content-addressed store, hash-verified

233 *
234 */
235export function formatPercent(value: number, locale: string, digitsInfo?: string): string {
236 const format = getLocaleNumberFormat(locale, NumberFormatStyle.Percent);
237 const pattern = parseNumberFormat(format, getLocaleNumberSymbol(locale, NumberSymbol.MinusSign));
238 const res = formatNumberToLocaleString(
239 value,
240 pattern,
241 locale,
242 NumberSymbol.Group,
243 NumberSymbol.Decimal,
244 digitsInfo,
245 true,
246 );
247 return res.replace(
248 new RegExp(PERCENT_CHAR, 'g'),
249 getLocaleNumberSymbol(locale, NumberSymbol.PercentSign),
250 );
251}
252
253/**
254 * @ngModule CommonModule

Callers 2

transformMethod · 0.90

Calls 5

getLocaleNumberFormatFunction · 0.90
getLocaleNumberSymbolFunction · 0.90
parseNumberFormatFunction · 0.85
replaceMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…