UNPKG

word-join

Version:

Tiny module to join arrays with commas, "and", and Oxford comma support

1 lines 396 B
Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:`Module`}});function e(e=[],t={}){let n=e.length;if(n===0)return``;if(n===1)return`${e[0]}`;let r=t.conjunction||`and`;if(n===2)return`${e[0]} ${r} ${e[1]}`;let i=n-1,a=t.separator||`,`,o=e[0];for(let t=1;t<i;t++)o+=`${a} ${e[t]}`;let s=` ${r} ${e[i]}`;return t.oxford?`${o}${a}${s}`:`${o}${s}`}exports.default=e;