Code coverage report for master/toSentence.js

Statements: 100% (8 / 8)      Branches: 100% (10 / 10)      Functions: 100% (1 / 1)      Lines: 100% (7 / 7)      Ignored: none     

All files » master/ » toSentence.js
1 2 3 4 5 6 7 8 9 10 11 12 131   1 8 8 8     8   8    
var rtrim = require('./rtrim');
 
module.exports = function toSentence(array, separator, lastSeparator, serial) {
  separator = separator || ', ';
  lastSeparator = lastSeparator || ' and ';
  var a = array.slice(),
    lastMember = a.pop();
 
  if (array.length > 2 && serial) lastSeparator = rtrim(separator) + lastSeparator;
 
  return a.length ? a.join(separator) + lastSeparator + lastMember : lastMember;
};