fd22b0bf58
V2 (Laravel re-make)
23 lines
405 B
JavaScript
23 lines
405 B
JavaScript
'use strict';
|
|
|
|
module.exports = function join(glue, finalGlue) {
|
|
var collection = this.values();
|
|
|
|
if (finalGlue === undefined) {
|
|
return collection.implode(glue);
|
|
}
|
|
|
|
var count = collection.count();
|
|
|
|
if (count === 0) {
|
|
return '';
|
|
}
|
|
|
|
if (count === 1) {
|
|
return collection.last();
|
|
}
|
|
|
|
var finalItem = collection.pop();
|
|
|
|
return collection.implode(glue) + finalGlue + finalItem;
|
|
}; |