You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

22 lines
405 B

4 years ago
  1. 'use strict';
  2. module.exports = function join(glue, finalGlue) {
  3. var collection = this.values();
  4. if (finalGlue === undefined) {
  5. return collection.implode(glue);
  6. }
  7. var count = collection.count();
  8. if (count === 0) {
  9. return '';
  10. }
  11. if (count === 1) {
  12. return collection.last();
  13. }
  14. var finalItem = collection.pop();
  15. return collection.implode(glue) + finalGlue + finalItem;
  16. };