arrford

Array to human readable list converter
Install
Node
npm install --save arrford
Web
arrford is exported for web and usable with the variable arrford
<script src="https://rawgit.com/dawsonbotsford/arrford/master/bundle.js"></script>
Usage
const arrford = require('arrford');
arrford(['run', 'climb', 'jump!']);
Fewer than 3 elements in array
arrford(['run', 'climb!']);
arrford(['run!']);
Abort the Oxford comma
arrford(['run', 'climb', 'jump!'], false);
Replace the word 'and'
arrford(['spring', 'klättra', 'hoppa!'], true, 'och');
Replace the word 'and' and abort the Oxford comma
arrford(['spring', 'klättra', 'hoppa!'], false, 'och');
API
arrford(target [, oxford, join])
target
Type: Array
of string
s
oxford
optional
Type: boolean
Default: true
Description: whether to use the Oxford comma or not
join
optional
Type: string
Default: 'and'
Description: word used to join the list with the last element
returns
Type: string
Description: Take an array of strings and return a string of these items as a list. Insert "," and "and" in a grammatically correct way. Follow the Oxford comma trend unless false
is passed in for the second argument. Use the word 'and' to join the list unless some other "join" word is specified for the third argument.
License
MIT © Dawson Botsford