2022-08-22 12:12:09 +02:00
|
|
|
const shortConjunctionFormatter = new Intl.ListFormat(undefined, {
|
|
|
|
style: "short",
|
|
|
|
type: "conjunction",
|
|
|
|
});
|
|
|
|
|
|
|
|
const shortDisjunctionFormatter = new Intl.ListFormat(undefined, {
|
|
|
|
style: "short",
|
|
|
|
type: "disjunction",
|
|
|
|
});
|
|
|
|
|
2022-11-22 09:47:18 +01:00
|
|
|
const listFormatAvailable = typeof Intl?.ListFormat === "function";
|
|
|
|
|
2022-08-22 12:12:09 +02:00
|
|
|
export const listShortConjunctionFormatter = (list: Array<string>): string => {
|
2022-11-22 09:47:18 +01:00
|
|
|
return listFormatAvailable
|
|
|
|
? shortConjunctionFormatter.format(list)
|
|
|
|
: list.join(",");
|
2022-08-22 12:12:09 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
export const listShortDisjunctionFormatter = (list: Array<string>): string => {
|
2022-11-22 09:47:18 +01:00
|
|
|
return listFormatAvailable
|
|
|
|
? shortDisjunctionFormatter.format(list)
|
|
|
|
: list.join(",");
|
2022-08-22 12:12:09 +02:00
|
|
|
};
|