Sha256: 039d78a3924962bb08e7f895ecb2c83a8756f3ce2dd63fddd0c372b71d22cccf

Contents?: true

Size: 1.26 KB

Versions: 46

Compression:

Stored size: 1.26 KB

Contents

"use strict";

var isPlainArray       = require("../../is-plain-array")
  , toPosInt           = require("../../../number/to-pos-integer")
  , isObject           = require("../../../object/is-object")
  , isConcatSpreadable = require("es6-symbol").isConcatSpreadable
  , isArray            = Array.isArray
  , concat             = Array.prototype.concat
  , forEach            = Array.prototype.forEach
  , isSpreadable;

isSpreadable = function (value) {
	if (!value) return false;
	if (!isObject(value)) return false;
	if (value[isConcatSpreadable] !== undefined) {
		return Boolean(value[isConcatSpreadable]);
	}
	return isArray(value);
};

// eslint-disable-next-line no-unused-vars
module.exports = function (item /*, …items*/) {
	var result;
	if (!this || !isArray(this) || isPlainArray(this)) {
		return concat.apply(this, arguments);
	}
	result = new this.constructor();
	if (isSpreadable(this)) {
		forEach.call(this, function (val, i) {
			result[i] = val;
		});
	} else {
		result[0] = this;
	}
	forEach.call(arguments, function (arg) {
		var base;
		if (isSpreadable(arg)) {
			base = result.length;
			result.length += toPosInt(arg.length);
			forEach.call(arg, function (val, i) {
				result[base + i] = val;
			});
			return;
		}
		result.push(arg);
	});
	return result;
};

Version data entries

46 entries across 46 versions & 3 rubygems

Version Path
govuk_publishing_components-18.0.0 node_modules/es5-ext/array/#/concat/shim.js
govuk_publishing_components-17.21.0 node_modules/es5-ext/array/#/concat/shim.js
govuk_publishing_components-17.20.0 node_modules/es5-ext/array/#/concat/shim.js
govuk_publishing_components-17.19.1 node_modules/es5-ext/array/#/concat/shim.js
govuk_publishing_components-17.19.0 node_modules/es5-ext/array/#/concat/shim.js
govuk_publishing_components-17.18.0 node_modules/es5-ext/array/#/concat/shim.js
govuk_publishing_components-17.17.0 node_modules/es5-ext/array/#/concat/shim.js
govuk_publishing_components-17.16.0 node_modules/es5-ext/array/#/concat/shim.js
govuk_publishing_components-17.15.0 node_modules/es5-ext/array/#/concat/shim.js
govuk_publishing_components-17.14.0 node_modules/es5-ext/array/#/concat/shim.js
govuk_publishing_components-17.13.0 node_modules/es5-ext/array/#/concat/shim.js
govuk_publishing_components-17.12.2 node_modules/es5-ext/array/#/concat/shim.js
govuk_publishing_components-17.12.1 node_modules/es5-ext/array/#/concat/shim.js
govuk_publishing_components-17.12.0 node_modules/es5-ext/array/#/concat/shim.js
govuk_publishing_components-17.11.0 node_modules/es5-ext/array/#/concat/shim.js
govuk_publishing_components-17.10.0 node_modules/es5-ext/array/#/concat/shim.js
govuk_publishing_components-17.9.0 node_modules/es5-ext/array/#/concat/shim.js
govuk_publishing_components-17.8.0 node_modules/es5-ext/array/#/concat/shim.js
govuk_publishing_components-17.7.0 node_modules/es5-ext/array/#/concat/shim.js
govuk_publishing_components-17.6.1 node_modules/es5-ext/array/#/concat/shim.js