2019-07-17 22:49:06 +02:00
|
|
|
// @flow
|
|
|
|
|
|
|
|
export function toCapitalCase(string: string) {
|
|
|
|
return string.charAt(0).toUpperCase() + string.slice(1);
|
|
|
|
}
|
2022-01-26 00:16:28 +01:00
|
|
|
|
|
|
|
export function toCompactNotation(number: string | number, lang: ?string) {
|
|
|
|
try {
|
|
|
|
return Number(number).toLocaleString(lang || 'en', {
|
|
|
|
compactDisplay: 'short',
|
|
|
|
notation: 'compact',
|
|
|
|
});
|
|
|
|
} catch (err) {
|
|
|
|
// Not all browsers support the addition options.
|
|
|
|
return Number(number).toLocaleString();
|
|
|
|
}
|
|
|
|
}
|