3f0cc0bf2e
* Factor out 'toCompactNotation' * File page: use compact view count (w/ tooltip for full res) Co-authored-by: infinite-persistence <inf.persistence@gmail.com>
17 lines
449 B
JavaScript
17 lines
449 B
JavaScript
// @flow
|
|
|
|
export function toCapitalCase(string: string) {
|
|
return string.charAt(0).toUpperCase() + string.slice(1);
|
|
}
|
|
|
|
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();
|
|
}
|
|
}
|