-
Notifications
You must be signed in to change notification settings - Fork 63
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Get rid of displayList #388
Comments
Been thinking about this one. Using else if (xs.length > n + 2) {
return `${xs.slice(0, n).join(", ")}, ${conj} ${xs.length - n} others`
} Utilizing export default <T>(xs: T[], conj = "and", n = 6, locale = "en-US") => {
if (xs.length > n + 2) {
const formattedList = new Intl.ListFormat(locale, { style: "long", type: "conjunction" }).format(xs.slice(0, n));
return `${formattedList}, ${conj} ${xs.length - n} others`;
}
return new Intl.ListFormat(locale, { style: "long", type: "conjunction" }).format(xs);
} Do you think it makes more sense to move this logic into the project via a utility function, or update it in your |
Use new
Intl.ListFormat(getLocale(), {style: "long", type: "conjunction"})
instead. Stick it in a utility function.The text was updated successfully, but these errors were encountered: