my-idlers/node_modules/collect.js/dist/methods/crossJoin.js
cp6 fd22b0bf58 V2 (Laravel re-make)
V2 (Laravel re-make)
2022-03-06 02:02:12 +11:00

34 lines
838 B
JavaScript
Vendored

'use strict';
module.exports = function crossJoin() {
function join(collection, constructor, args) {
var current = args[0];
if (current instanceof constructor) {
current = current.all();
}
var rest = args.slice(1);
var last = !rest.length;
var result = [];
for (var i = 0; i < current.length; i += 1) {
var collectionCopy = collection.slice();
collectionCopy.push(current[i]);
if (last) {
result.push(collectionCopy);
} else {
result = result.concat(join(collectionCopy, constructor, rest));
}
}
return result;
}
for (var _len = arguments.length, values = Array(_len), _key = 0; _key < _len; _key++) {
values[_key] = arguments[_key];
}
return new this.constructor(join([], this.constructor, [].concat([this.items], values)));
};