summaryrefslogtreecommitdiff
path: root/tools/eslint/node_modules/escope/node_modules/es6-map/node_modules/es5-ext/array/#/concat/shim.js
diff options
context:
space:
mode:
Diffstat (limited to 'tools/eslint/node_modules/escope/node_modules/es6-map/node_modules/es5-ext/array/#/concat/shim.js')
-rw-r--r--tools/eslint/node_modules/escope/node_modules/es6-map/node_modules/es5-ext/array/#/concat/shim.js39
1 files changed, 39 insertions, 0 deletions
diff --git a/tools/eslint/node_modules/escope/node_modules/es6-map/node_modules/es5-ext/array/#/concat/shim.js b/tools/eslint/node_modules/escope/node_modules/es6-map/node_modules/es5-ext/array/#/concat/shim.js
new file mode 100644
index 0000000000..8b28e4ae03
--- /dev/null
+++ b/tools/eslint/node_modules/escope/node_modules/es6-map/node_modules/es5-ext/array/#/concat/shim.js
@@ -0,0 +1,39 @@
+'use strict';
+
+var isPlainArray = require('../../is-plain-array')
+ , toPosInt = require('../../../number/to-pos-integer')
+ , isObject = require('../../../object/is-object')
+
+ , 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);
+};
+
+module.exports = function (item/*, …items*/) {
+ var result;
+ if (!this || !isArray(this) || isPlainArray(this)) {
+ return concat.apply(this, arguments);
+ }
+ result = new this.constructor(this.length);
+ forEach.call(this, function (val, i) { result[i] = val; });
+ 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;
+};