Skip to content

Commit

Permalink
simplify conversion
Browse files Browse the repository at this point in the history
  • Loading branch information
zloirock committed Jun 25, 2022
1 parent cdbd392 commit dd3518c
Showing 1 changed file with 3 additions and 8 deletions.
11 changes: 3 additions & 8 deletions packages/core-js/modules/esnext.typed-array.to-spliced.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,13 @@
'use strict';
var ArrayBufferViewCore = require('../internals/array-buffer-view-core');
var isBigIntArray = require('../internals/is-big-int-array');
var lengthOfArrayLike = require('../internals/length-of-array-like');
var toAbsoluteIndex = require('../internals/to-absolute-index');
var toBigInt = require('../internals/to-big-int');
var toIntegerOrInfinity = require('../internals/to-integer-or-infinity');
var uncurryThis = require('../internals/function-uncurry-this');
var fails = require('../internals/fails');

var aTypedArray = ArrayBufferViewCore.aTypedArray;
var getTypedArrayConstructor = ArrayBufferViewCore.getTypedArrayConstructor;
var exportTypedArrayMethod = ArrayBufferViewCore.exportTypedArrayMethod;
var push = uncurryThis([].push);
var max = Math.max;
var min = Math.min;

Expand All @@ -38,9 +34,8 @@ exportTypedArrayMethod('toSpliced', function toSpliced(start, deleteCount /* , .
var len = lengthOfArrayLike(O);
var actualStart = toAbsoluteIndex(start, len);
var argumentsLength = arguments.length;
var convertedItems = [];
var k = 0;
var insertCount, actualDeleteCount, newLen, A;
var insertCount, actualDeleteCount, convertedItems, newLen, A;
if (argumentsLength === 0) {
insertCount = actualDeleteCount = 0;
} else if (argumentsLength === 1) {
Expand All @@ -50,9 +45,9 @@ exportTypedArrayMethod('toSpliced', function toSpliced(start, deleteCount /* , .
actualDeleteCount = min(max(toIntegerOrInfinity(deleteCount), 0), len - actualStart);
insertCount = argumentsLength - 2;
if (insertCount) {
var IS_BIG_INT = isBigIntArray(O);
convertedItems = new C(insertCount);
for (var i = 2; i < argumentsLength; i++) {
push(convertedItems, IS_BIG_INT ? toBigInt(arguments[i]) : +arguments[i]);
convertedItems[i - 2] = arguments[i];
}
}
}
Expand Down

0 comments on commit dd3518c

Please sign in to comment.