summaryrefslogtreecommitdiff
path: root/tools/eslint/node_modules/escope/node_modules/es6-weak-map/node_modules/es5-ext/array/#/copy-within
diff options
context:
space:
mode:
Diffstat (limited to 'tools/eslint/node_modules/escope/node_modules/es6-weak-map/node_modules/es5-ext/array/#/copy-within')
-rw-r--r--tools/eslint/node_modules/escope/node_modules/es6-weak-map/node_modules/es5-ext/array/#/copy-within/implement.js7
-rw-r--r--tools/eslint/node_modules/escope/node_modules/es6-weak-map/node_modules/es5-ext/array/#/copy-within/index.js4
-rw-r--r--tools/eslint/node_modules/escope/node_modules/es6-weak-map/node_modules/es5-ext/array/#/copy-within/is-implemented.js7
-rw-r--r--tools/eslint/node_modules/escope/node_modules/es6-weak-map/node_modules/es5-ext/array/#/copy-within/shim.js39
4 files changed, 57 insertions, 0 deletions
diff --git a/tools/eslint/node_modules/escope/node_modules/es6-weak-map/node_modules/es5-ext/array/#/copy-within/implement.js b/tools/eslint/node_modules/escope/node_modules/es6-weak-map/node_modules/es5-ext/array/#/copy-within/implement.js
new file mode 100644
index 0000000000..eedbad77ee
--- /dev/null
+++ b/tools/eslint/node_modules/escope/node_modules/es6-weak-map/node_modules/es5-ext/array/#/copy-within/implement.js
@@ -0,0 +1,7 @@
+'use strict';
+
+if (!require('./is-implemented')()) {
+ Object.defineProperty(Array.prototype, 'copyWithin',
+ { value: require('./shim'), configurable: true, enumerable: false,
+ writable: true });
+}
diff --git a/tools/eslint/node_modules/escope/node_modules/es6-weak-map/node_modules/es5-ext/array/#/copy-within/index.js b/tools/eslint/node_modules/escope/node_modules/es6-weak-map/node_modules/es5-ext/array/#/copy-within/index.js
new file mode 100644
index 0000000000..bb89d0b879
--- /dev/null
+++ b/tools/eslint/node_modules/escope/node_modules/es6-weak-map/node_modules/es5-ext/array/#/copy-within/index.js
@@ -0,0 +1,4 @@
+'use strict';
+
+module.exports = require('./is-implemented')() ?
+ Array.prototype.copyWithin : require('./shim');
diff --git a/tools/eslint/node_modules/escope/node_modules/es6-weak-map/node_modules/es5-ext/array/#/copy-within/is-implemented.js b/tools/eslint/node_modules/escope/node_modules/es6-weak-map/node_modules/es5-ext/array/#/copy-within/is-implemented.js
new file mode 100644
index 0000000000..8f17e06d81
--- /dev/null
+++ b/tools/eslint/node_modules/escope/node_modules/es6-weak-map/node_modules/es5-ext/array/#/copy-within/is-implemented.js
@@ -0,0 +1,7 @@
+'use strict';
+
+module.exports = function () {
+ var arr = [1, 2, 3, 4, 5];
+ if (typeof arr.copyWithin !== 'function') return false;
+ return String(arr.copyWithin(1, 3)) === '1,4,5,4,5';
+};
diff --git a/tools/eslint/node_modules/escope/node_modules/es6-weak-map/node_modules/es5-ext/array/#/copy-within/shim.js b/tools/eslint/node_modules/escope/node_modules/es6-weak-map/node_modules/es5-ext/array/#/copy-within/shim.js
new file mode 100644
index 0000000000..c0bfb8b060
--- /dev/null
+++ b/tools/eslint/node_modules/escope/node_modules/es6-weak-map/node_modules/es5-ext/array/#/copy-within/shim.js
@@ -0,0 +1,39 @@
+// Taken from: https://github.com/paulmillr/es6-shim/
+
+'use strict';
+
+var toInteger = require('../../../number/to-integer')
+ , toPosInt = require('../../../number/to-pos-integer')
+ , validValue = require('../../../object/valid-value')
+
+ , hasOwnProperty = Object.prototype.hasOwnProperty
+ , max = Math.max, min = Math.min;
+
+module.exports = function (target, start/*, end*/) {
+ var o = validValue(this), end = arguments[2], l = toPosInt(o.length)
+ , to, from, fin, count, direction;
+
+ target = toInteger(target);
+ start = toInteger(start);
+ end = (end === undefined) ? l : toInteger(end);
+
+ to = target < 0 ? max(l + target, 0) : min(target, l);
+ from = start < 0 ? max(l + start, 0) : min(start, l);
+ fin = end < 0 ? max(l + end, 0) : min(end, l);
+ count = min(fin - from, l - to);
+ direction = 1;
+
+ if ((from < to) && (to < (from + count))) {
+ direction = -1;
+ from += count - 1;
+ to += count - 1;
+ }
+ while (count > 0) {
+ if (hasOwnProperty.call(o, from)) o[to] = o[from];
+ else delete o[from];
+ from += direction;
+ to += direction;
+ count -= 1;
+ }
+ return o;
+};