in runtime/shared/intlList.js [44:121]
const intlList = function <TItem: React.Node>(
items: $ReadOnlyArray<TItem>,
conjunction: ?$Keys<typeof CONJUNCTIONS>,
delimiter: ?$Keys<typeof DELIMITERS>,
): TItem | Fbt {
if (__DEV__) {
items.forEach(function (item) {
invariant(
typeof item === 'string' || React.isValidElement(item),
'Must provide a string or ReactComponent to intlList.',
);
});
}
const count = items.length;
if (count === 0) {
return '';
} else if (count === 1) {
return items[0];
}
const lastItem = items[count - 1];
let output: TItem | Fbt = items[0];
for (let i = 1; i < count - 1; ++i) {
switch (delimiter) {
case DELIMITERS.SEMICOLON:
output = (
<fbt
desc={
'A list of items of various types, for example: ' +
'"Menlo Park, CA; Seattle, WA; New York City, NY". ' +
'{previous items} and {following items} are themselves ' +
'lists that contain one or more items.'
}>
<fbt:param name="previous items">{output}</fbt:param>
{'; '}
<fbt:param name="following items">{items[i]}</fbt:param>
</fbt>
);
break;
case DELIMITERS.BULLET:
output = (
<fbt
desc={
'A list of items of various types separated by bullets, for example: ' +
'"Menlo Park, CA \u2022 Seattle, WA \u2022 New York City, NY". ' +
'{previous items} and {following items} are themselves ' +
'lists that contain one or more items.'
}>
<fbt:param name="previous items">{output}</fbt:param> •{' '}
<fbt:param name="following items">{items[i]}</fbt:param>
</fbt>
);
break;
default:
output = (
<fbt
desc={
'A list of items of various types. {previous items} and' +
' {following items} are themselves lists that contain one or' +
' more items.'
}>
<fbt:param name="previous items">{output}</fbt:param>
{', '}
<fbt:param name="following items">{items[i]}</fbt:param>
</fbt>
);
}
}
return _getConjunction(
output,
lastItem,
conjunction || CONJUNCTIONS.AND,
delimiter || DELIMITERS.COMMA,
);
};