next.js/packages/next/src/lib/oxford-comma-list.ts
oxford-comma-list.ts15 lines306 B
export function getOxfordCommaList(items: string[]): string {
  return items
    .map(
      (v, index, { length }) =>
        (index > 0
          ? index === length - 1
            ? length > 2
              ? ', and '
              : ' and '
            : ', '
          : '') + v
    )
    .join('')
}
Quest for Codev2.0.0
/
SIGN IN