lbry-desktop/ui/util/string.js
infinite-persistence cfd234d615
ClaimPreview & sidebar: strip '@' since channel is implied (#879)
## Ticket
865: Hide @ symbol in areas where channel names are implied
2022-02-23 07:42:43 -05:00

27 lines
797 B
JavaScript

// @flow
export function toCapitalCase(string: string) {
return string.charAt(0).toUpperCase() + string.slice(1);
}
export function toCompactNotation(number: string | number, lang: ?string, minThresholdToApply?: string | number) {
const locale = lang || 'en';
if (minThresholdToApply && Number(number) >= Number(minThresholdToApply)) {
try {
return Number(number).toLocaleString(locale, {
compactDisplay: 'short',
notation: 'compact',
});
} catch (err) {
// Not all browsers support the additional options.
return Number(number).toLocaleString(locale);
}
} else {
return Number(number).toLocaleString(locale);
}
}
export function stripLeadingAtSign(str: ?string) {
return str && str.charAt(0) === '@' ? str.slice(1) : str;
}