Skip to content

Commit

Permalink
fix ToString conversion / built-ins nature of some accessors
Browse files Browse the repository at this point in the history
  • Loading branch information
zloirock committed Mar 8, 2023
1 parent dbc1d6b commit ce955d0
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 19 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
## Changelog
##### Unreleased
- [`String.prototype.{ isWellFormed, toWellFormed }`](https://github.com/tc39/proposal-is-usv-string) marked as supported from V8 ~ Chrome 111
- Fixed `ToString` conversion / built-ins nature of some accessors
- Added Opera Android 74 compat data mapping

##### [3.29.0 - 2023.02.27](https://github.com/zloirock/core-js/releases/tag/v3.29.0)
Expand Down
35 changes: 16 additions & 19 deletions packages/core-js/internals/numeric-range-iterator.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ var createIteratorConstructor = require('../internals/iterator-create-constructo
var createIterResultObject = require('../internals/create-iter-result-object');
var isNullOrUndefined = require('../internals/is-null-or-undefined');
var isObject = require('../internals/is-object');
var defineProperties = require('../internals/object-define-properties').f;
var defineBuiltInAccessor = require('../internals/define-built-in-accessor');
var DESCRIPTORS = require('../internals/descriptors');

var INCORRECT_RANGE = 'Incorrect Iterator.range arguments';
Expand Down Expand Up @@ -53,7 +53,7 @@ var $RangeIterator = createIteratorConstructor(function NumericRangeIterator(sta
start: start,
end: end,
step: step,
inclusiveEnd: inclusiveEnd,
inclusive: inclusiveEnd,
hitsEnd: hitsEnd,
currentCount: zero,
zero: zero
Expand All @@ -72,7 +72,7 @@ var $RangeIterator = createIteratorConstructor(function NumericRangeIterator(sta
var step = state.step;
var currentYieldingValue = start + (step * state.currentCount++);
if (currentYieldingValue === end) state.hitsEnd = true;
var inclusiveEnd = state.inclusiveEnd;
var inclusiveEnd = state.inclusive;
var endCondition;
if (end > start) {
endCondition = inclusiveEnd ? currentYieldingValue > end : currentYieldingValue >= end;
Expand All @@ -85,25 +85,22 @@ var $RangeIterator = createIteratorConstructor(function NumericRangeIterator(sta
} return createIterResultObject(currentYieldingValue, false);
});

var getter = function (fn) {
return { get: fn, set: function () { /* empty */ }, configurable: true, enumerable: false };
var addGetter = function (key) {
defineBuiltInAccessor($RangeIterator.prototype, key, {
get: function () {
return getInternalState(this)[key];
},
set: function () { /* empty */ },
configurable: true,
enumerable: false
});
};

if (DESCRIPTORS) {
defineProperties($RangeIterator.prototype, {
start: getter(function () {
return getInternalState(this).start;
}),
end: getter(function () {
return getInternalState(this).end;
}),
inclusive: getter(function () {
return getInternalState(this).inclusiveEnd;
}),
step: getter(function () {
return getInternalState(this).step;
})
});
addGetter('start');
addGetter('end');
addGetter('inclusive');
addGetter('step');
}

module.exports = $RangeIterator;

0 comments on commit ce955d0

Please sign in to comment.