list-separator.js 482 B

12345678910111213141516171819202122232425
  1. var utils = require('../utils')
  2. , nodes = require('../nodes');
  3. /**
  4. * Return the separator of the given `list`.
  5. *
  6. * Examples:
  7. *
  8. * list1 = a b c
  9. * list-separator(list1)
  10. * // => ' '
  11. *
  12. * list2 = a, b, c
  13. * list-separator(list2)
  14. * // => ','
  15. *
  16. * @param {Experssion} list
  17. * @return {String}
  18. * @api public
  19. */
  20. (module.exports = function listSeparator(list){
  21. list = utils.unwrap(list);
  22. return new nodes.String(list.isList ? ',' : ' ');
  23. }).raw = true;