-
Notifications
You must be signed in to change notification settings - Fork 676
Async Generators doesn't polyfilled correctly by metro-react-native-babel-preset #842
Copy link
Copy link
Closed
Description
Do you want to request a feature or report a bug?
async function* asyncGenerator() {
let i = 0;
while (i < 3) {
yield i++;
}
}
(async () => {
for await (const num of asyncGenerator()) {
console.log(num);
}
})();JS Output...
function _createForOfIteratorHelperLoose(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (it) return (it = it.call(o)).next.bind(it); if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; return function () { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
var _marked = _$$_REQUIRE(_dependencyMap[0], "@babel/runtime/regenerator").mark(asyncGenerator);
function asyncGenerator() {
var i;
return _$$_REQUIRE(_dependencyMap[0], "@babel/runtime/regenerator").async(function asyncGenerator$(_context) {
while (1) {
switch (_context.prev = _context.next) {
case 0:
i = 0;
case 1:
if (!(i < 3)) {
_context.next = 6;
break;
}
_context.next = 4;
return i++;
case 4:
_context.next = 1;
break;
case 6:
case "end":
return _context.stop();
}
}
}, _marked, null, null, Promise);
}
(function _callee() {
var _iterator, _step, num;
return _$$_REQUIRE(_dependencyMap[0], "@babel/runtime/regenerator").async(function _callee$(_context2) {
while (1) {
switch (_context2.prev = _context2.next) {
case 0:
for (_iterator = _createForOfIteratorHelperLoose(asyncGenerator()); !(_step = _iterator()).done;) {
num = _step.value;
console.log(num);
}
case 1:
case "end":
return _context2.stop();
}
}
}, null, null, null, Promise);
})();What is the current behavior?
// output
TypeError: Invalid attempt to iterate non-iterable instance.
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.What is the expected behavior?
// output
0
1
2Please provide your exact Metro configuration and mention your Metro, node, yarn/npm version and operating system.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels