Extract for-of iterator handling to a helper (#11262)
* Extract for-of iterator handling to a helper Dis greatly recudes the code size when for-of is used multiple times across the codebase. Also, makes it easier to read what's happening in a compiled loop. * Unify spec and loose code * Legacy implementation fallback * Update tmp var name * Updates from review and after rebase
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"plugins": [
|
||||
"proposal-class-properties",
|
||||
"external-helpers",
|
||||
["external-helpers", { "helperVersion": "7.100.0" }],
|
||||
"syntax-typescript",
|
||||
"syntax-flow",
|
||||
"transform-parameters",
|
||||
|
||||
@@ -153,28 +153,18 @@ function forOf() {
|
||||
rest[_key16] = arguments[_key16];
|
||||
}
|
||||
|
||||
var _iteratorNormalCompletion = true;
|
||||
var _didIteratorError = false;
|
||||
var _iteratorError = undefined;
|
||||
var _iterator = babelHelpers.createForOfIteratorHelper(this),
|
||||
_step;
|
||||
|
||||
try {
|
||||
for (var _iterator = this[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
|
||||
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
||||
rest[0] = _step.value;
|
||||
;
|
||||
}
|
||||
} catch (err) {
|
||||
_didIteratorError = true;
|
||||
_iteratorError = err;
|
||||
_iterator.e(err);
|
||||
} finally {
|
||||
try {
|
||||
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
||||
_iterator.return();
|
||||
}
|
||||
} finally {
|
||||
if (_didIteratorError) {
|
||||
throw _iteratorError;
|
||||
}
|
||||
}
|
||||
_iterator.f();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,7 +1,3 @@
|
||||
function _createSuper(Derived) { return function () { var Super = babelHelpers.getPrototypeOf(Derived), result; if (_isNativeReflectConstruct()) { var NewTarget = babelHelpers.getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return babelHelpers.possibleConstructorReturn(this, result); }; }
|
||||
|
||||
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }
|
||||
|
||||
function broken(x) {
|
||||
if (true) {
|
||||
var Foo = /*#__PURE__*/function (_Bar) {
|
||||
@@ -9,7 +5,7 @@ function broken(x) {
|
||||
|
||||
babelHelpers.inherits(Foo, _Bar);
|
||||
|
||||
var _super = _createSuper(Foo);
|
||||
var _super = babelHelpers.createSuper(Foo);
|
||||
|
||||
function Foo() {
|
||||
babelHelpers.classCallCheck(this, Foo);
|
||||
|
||||
Reference in New Issue
Block a user