Dashboard sipadu mbip
Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

join.js 405B

1234567891011121314151617181920212223
  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. };