- Easily use the Oxford comma in any locale or language
- Customize the list separator (e.g.,
";") and the conjunction (e.g.,"or") - ES6-compatible for use in all modern environments
- TypeScript-first, with built-in type definitions
- Zero dependencies, for a minimal bundle footprint
npm install word-joinimport wordJoin from "word-join";
wordJoin(["pasta", "sauce", "cheese", "wine"]);
// pasta, sauce, cheese and wine
wordJoin(["pasta", "sauce", "cheese", "wine"], {
conjunction: "or",
});
// pasta, sauce, cheese or wine
wordJoin(["pasta", "sauce", "cheese", "wine"], {
conjunction: "or",
oxford: true,
});
// pasta, sauce, cheese, or wine
wordJoin(["pasta", "sauce", "cheese", "wine"], {
conjunction: "or",
oxford: true,
separator: ";",
});
// pasta; sauce; cheese; or wineType: string. Default: "and".
The conjunction used to join the last item in the list.
wordJoin(["pasta", "sauce", "cheese", "wine"], { conjunction: "or" });
// pasta, sauce, cheese or wineType: boolean. Default: false.
Whether to use an Oxford comma — i.e., a final comma before the conjunction.
wordJoin(["pasta", "sauce", "cheese", "wine"], { oxford: true });
// pasta, sauce, cheese, and wineType: string. Default: ",".
The string used to separate the list items.
wordJoin(["pasta", "sauce", "cheese", "wine"], { separator: ";" });
// pasta; sauce; cheese and wineCopyright (C) 2022-present stldo