first
This commit is contained in:
18
node_modules/core-js/internals/array-with.js
generated
vendored
Normal file
18
node_modules/core-js/internals/array-with.js
generated
vendored
Normal file
@ -0,0 +1,18 @@
|
||||
'use strict';
|
||||
var lengthOfArrayLike = require('../internals/length-of-array-like');
|
||||
var toIntegerOrInfinity = require('../internals/to-integer-or-infinity');
|
||||
|
||||
var $RangeError = RangeError;
|
||||
|
||||
// https://tc39.es/proposal-change-array-by-copy/#sec-array.prototype.with
|
||||
// https://tc39.es/proposal-change-array-by-copy/#sec-%typedarray%.prototype.with
|
||||
module.exports = function (O, C, index, value) {
|
||||
var len = lengthOfArrayLike(O);
|
||||
var relativeIndex = toIntegerOrInfinity(index);
|
||||
var actualIndex = relativeIndex < 0 ? len + relativeIndex : relativeIndex;
|
||||
if (actualIndex >= len || actualIndex < 0) throw $RangeError('Incorrect index');
|
||||
var A = new C(len);
|
||||
var k = 0;
|
||||
for (; k < len; k++) A[k] = k === actualIndex ? value : O[k];
|
||||
return A;
|
||||
};
|
Reference in New Issue
Block a user