summaryrefslogtreecommitdiff
path: root/packages/astro-parser/src/utils/list.ts
blob: 9388adb14ee72e9676ce79a54c5ef426b6392952 (plain) (blame)
1
2
3
4
5
/** Display an array of strings in a human-readable format */
export default function list(items: string[], conjunction = 'or') {
  if (items.length === 1) return items[0];
  return `${items.slice(0, -1).join(', ')} ${conjunction} ${items[items.length - 1]}`;
}