Elegantly formats lists with proper punctuation, including support for the Oxford comma.
npm install commadusMaster the art of the comma.
> Archetype: Node.js package
> Purpose: Formats lists with elegant punctuation, including optional Oxford commas.
Commadus elegantly formats lists with proper punctuation, including support for the Oxford comma.
- Proper List Formatting – Outputs grammatically correct lists in prose.
- Oxford Comma Support – Toggle the famous oxford comma on or off.
- Handles Edge Cases – Works with lists of any length, from empty arrays to long item lists.
- Lightweight & Fast – A single function, no dependencies.
``sh`
npm install commadus
Formats an array of items into a human-readable list with optional Oxford comma.
#### Parameters
| Name | Type | Default | Description |
| ---------------- | ---------- | ------------------ | ----------------------------------------------------- |
| items | string[] | Required | The list of items to format. |options
| | Object | { oxford: true } | Formatting options. |options.oxford
| | boolean | true | Whether to include the Oxford comma before "and". |
#### Returns
- string – The formatted list.
`js
import list from 'commadus';
console.log(list(['apple', 'banana', 'cherry']));
// "apple, banana, and cherry"
console.log(list(['apple', 'banana', 'cherry'], { oxford: false }));
// "apple, banana and cherry"
console.log(list(['moon', 'stars']));
// "moon and stars"
console.log(list(['sun']));
// "sun"
console.log(list([]));
// ""
``
https://github.com/alexstevovich/commadus-node
_This link might be suffixed with "-node" in the future if conflicts arise._
Licensed under the Apache License 2.0.