lbry-desktop/ui/util/string.js

18 lines
449 B
JavaScript
Raw Normal View History

2019-07-17 22:49:06 +02:00
// @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();
}
}