Conversation
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
There was a problem hiding this comment.
No description provided.
Describe the intent of this patch. I thought of this feature when I started creating this library, but soon noticed it's just an alias of lastSeparator: ', and ':
arrayToSentence(['A', 'B', 'C'], {lastSeprator: ', and '}) //=> 'A, B, and C'Of course I'll consider merging this PR if you can convince me this option is not just an alias, though.
.gitignore
Outdated
| .nyc_output | ||
| coverage | ||
| node_modules | ||
| .idea |
There was a problem hiding this comment.
Not needed. Add this to your global gitignore instead.
| }); //=> 'Earth, Wind & Fire' | ||
| ``` | ||
|
|
||
| ### options.oxfordComma |
There was a problem hiding this comment.
The option name is confusing when you use this library for non-English languages; separator could not be a comma in those cases.
| arrayToSentence(['A', 'B', 'C'], { | ||
| oxfordComma: true | ||
| }); //=> 'A, B, and C' | ||
|
|
.gitignore
Outdated
| coverage | ||
| node_modules | ||
| .idea | ||
|
|
|
Unfortunately
but
So it is not just an alias (I added a test to reflect this) I agree the name is odd for non-english. However, it is not clear that this feature makes sense outside of english. This is also called the serial comma https://en.wikipedia.org/wiki/Serial_comma although I don't think that term is as widely known not does it seem any more suitable. Open to other suggestions for the name of the feature. Jesse |
|
This project https://www.npmjs.com/package/humanize-duration calls it serialComma |
Ahh, I didn't notice it when I created this module! Thanks for the clarification. |
There was a problem hiding this comment.
Instead of oxfordComma option, I'd like to propose a more generic one pairSeparator that will only be applied to two-element arrays.
If a user want to use Oxford commas, the code would look like:
const options = {
lastSeparator: ', and ',
pairSeparator: ' and '
};
arrayToSentence(['A', 'B', 'C']); //=> 'A, B, and C'
arrayToSentence(['A', 'B']); //=> 'A and B'What do you think, @jhullfly ?
P.S. Thanks for your patience over a month!
Support for the oxford comma.
arrayToSentence(['A', 'B'], {oxfordComma: true}) //=> 'A and B'
arrayToSentence(['A', 'B', 'C'], {oxfordComma: true}) //=> 'A, B, and C'