3 var isPlainArray = require('../../is-plain-array')
4 , toPosInt = require('../../../number/to-pos-integer')
5 , isObject = require('../../../object/is-object')
7 , isArray = Array.isArray, concat = Array.prototype.concat
8 , forEach = Array.prototype.forEach
12 isSpreadable = function (value) {
13 if (!value) return false;
14 if (!isObject(value)) return false;
15 if (value['@@isConcatSpreadable'] !== undefined) {
16 return Boolean(value['@@isConcatSpreadable']);
18 return isArray(value);
21 module.exports = function (item/*, …items*/) {
23 if (!this || !isArray(this) || isPlainArray(this)) {
24 return concat.apply(this, arguments);
26 result = new this.constructor(this.length);
27 forEach.call(this, function (val, i) { result[i] = val; });
28 forEach.call(arguments, function (arg) {
30 if (isSpreadable(arg)) {
32 result.length += toPosInt(arg.length);
33 forEach.call(arg, function (val, i) { result[base + i] = val; });