source: trip-planner-front/node_modules/core-js/internals/array-copy-within.js

Last change on this file was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago

initial commit

  • Property mode set to 100644
File size: 1.0 KB
Line 
1'use strict';
2var toObject = require('../internals/to-object');
3var toAbsoluteIndex = require('../internals/to-absolute-index');
4var toLength = require('../internals/to-length');
5
6var 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
11module.exports = [].copyWithin || function copyWithin(target /* = 0 */, start /* = 0, end = @length */) {
12 var O = toObject(this);
13 var len = toLength(O.length);
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};
Note: See TracBrowser for help on using the repository browser.