massive update, probably broken
[dotfiles/.git] / .config / coc / extensions / node_modules / coc-prettier / node_modules / core-js / internals / array-copy-within.js
1 'use strict';
2 var toObject = require('../internals/to-object');
3 var toAbsoluteIndex = require('../internals/to-absolute-index');
4 var lengthOfArrayLike = require('../internals/length-of-array-like');
5
6 var min = Math.min;
7
8 // `Array.prototype.copyWithin` method implementation
9 // https://tc39.es/ecma262/#sec-array.prototype.copywithin
10 // eslint-disable-next-line es/no-array-prototype-copywithin -- safe
11 module.exports = [].copyWithin || function copyWithin(target /* = 0 */, start /* = 0, end = @length */) {
12   var O = toObject(this);
13   var len = lengthOfArrayLike(O);
14   var to = toAbsoluteIndex(target, len);
15   var from = toAbsoluteIndex(start, len);
16   var end = arguments.length > 2 ? arguments[2] : undefined;
17   var count = min((end === undefined ? len : toAbsoluteIndex(end, len)) - from, len - to);
18   var inc = 1;
19   if (from < to && to < from + count) {
20     inc = -1;
21     from += count - 1;
22     to += count - 1;
23   }
24   while (count-- > 0) {
25     if (from in O) O[to] = O[from];
26     else delete O[to];
27     to += inc;
28     from += inc;
29   } return O;
30 };