join.js 441 B

1234567891011121314151617
  1. var filter = require('./filter');
  2. function isValidString(val) {
  3. return (val != null && val !== '');
  4. }
  5. /**
  6. * Joins strings with the specified separator inserted between each value.
  7. * Null values and empty strings will be excluded.
  8. */
  9. function join(items, separator) {
  10. separator = separator || '';
  11. return filter(items, isValidString).join(separator);
  12. }
  13. module.exports = join;