Skip to content

Commit

Permalink
temporarily revert change the order of operations in `%TypedArray%.pr…
Browse files Browse the repository at this point in the history
…ototype.with`
  • Loading branch information
zloirock committed Jun 1, 2022
1 parent 0460543 commit b931062
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
1 change: 0 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
## Changelog
##### Unreleased
- Changed the order of operations in `%TypedArray%.prototype.with` following [proposal-change-array-by-copy/86](https://github.com/tc39/proposal-change-array-by-copy/issues/86)
- Fixed possible multiple call of `ToBigInt` / `ToNumber` conversion of the argument passed to `%TypedArray%.prototype.fill` in V8 ~ Chrome < 59, Safari < 14.1, FF < 55, Edge <=18
- Fixed some cases of `DeletePropertyOrThrow` in IE9-
- Fixed the kind of error (`TypeError` instead of `Error`) on incorrect `exec` result in `RegExp.prototype.test` polyfill
Expand Down
19 changes: 10 additions & 9 deletions packages/core-js/modules/esnext.typed-array.with.js
Original file line number Diff line number Diff line change
@@ -1,21 +1,22 @@
'use strict';
var arrayWith = require('../internals/array-with');
var ArrayBufferViewCore = require('../internals/array-buffer-view-core');
var toIntegerOrInfinity = require('../internals/to-integer-or-infinity');
var toBigInt = require('../internals/to-big-int');
var classof = require('../internals/classof');
var uncurryThis = require('../internals/function-uncurry-this');
// var toIntegerOrInfinity = require('../internals/to-integer-or-infinity');
// var toBigInt = require('../internals/to-big-int');
// var classof = require('../internals/classof');
// var uncurryThis = require('../internals/function-uncurry-this');

var aTypedArray = ArrayBufferViewCore.aTypedArray;
var exportTypedArrayMethod = ArrayBufferViewCore.exportTypedArrayMethod;
var TYPED_ARRAY_CONSTRUCTOR = ArrayBufferViewCore.TYPED_ARRAY_CONSTRUCTOR;
var slice = uncurryThis(''.slice);
// var slice = uncurryThis(''.slice);

// `%TypedArray%.prototype.with` method
// https://tc39.es/proposal-change-array-by-copy/#sec-%typedarray%.prototype.with
exportTypedArrayMethod('with', { 'with': function (index, value) {
aTypedArray(this);
var relativeIndex = toIntegerOrInfinity(index);
var actualValue = slice(classof(this), 0, 3) === 'Big' ? toBigInt(value) : +value;
return arrayWith(this, this[TYPED_ARRAY_CONSTRUCTOR], relativeIndex, actualValue);
// aTypedArray(this);
// var relativeIndex = toIntegerOrInfinity(index);
// var actualValue = slice(classof(this), 0, 3) === 'Big' ? toBigInt(value) : +value;
// return arrayWith(this, this[TYPED_ARRAY_CONSTRUCTOR], relativeIndex, actualValue);
return arrayWith(aTypedArray(this), this[TYPED_ARRAY_CONSTRUCTOR], index, value);
} }['with']);

0 comments on commit b931062

Please sign in to comment.