Places delimiters between items in an array. Defaults to a comma-separated list with an Oxford comma.
npm install delimiter --save
oryarn add delimiter
delimiter(arr, serial, del)
The array to which you want to add delimiters.
The separator for the last item in the array. (default: and
)
delimiter([ 1, 2 ], 'or') === [ 1, ' or ', 2 ]);
delimiter([ 1, 2, 3 ], 'or') === [ 1, ', ', 2, ', or ', 3 ]
The delimiter you want to use. (default: ,
)
delimiter(
[ 'Stover, Charles', 'Quisido, Ace', 'Gates, Bill' ],
'and', ';'
) === [ 'Stover, Charles', '; ', 'Quisido, Ace', '; and ', 'Gates, Bill' ]
This package was designed to separate React links using an Oxford comma but is extensible to other use cases.
import delimiter from 'delimiter';
// JSX
const myLinks = [
<CharlesStover />,
<Quisido />
];
delimiter(myLinks); // [ <CharlesStover />, ' and ', <Quisido /> ]
import delimiter from 'delimiter';
// JSX
const myLinks = [
<CharlesStover />,
<Quisido />,
<Mtgenius />
];
delimiter(myLinks); // [ <CharlesStover />, ', ', <Quisido />, ', and ', <Mtgenius /> ]
If you are a fan of this project, you may become a sponsor via GitHub's Sponsors Program.