1.0.0 • Published 4 months ago
commadus v1.0.0
commadus
Master 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.
Details
- 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.
Install
npm install commadus
⚙️ API
list(items, options?)
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.
Usage
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([]));
// ""
Development Homepage
https://github.com/alexstevovich/commadus-node
This link might be suffixed with "-node" in the future if conflicts arise.
License
Licensed under the Apache License 2.0.