文章 评论 浏览 27
写的牛逼,补充下下面的情况:
function* helloWorldGenerator() { const a = yield 'hello'; return a; } __webpack_require__.r(__webpack_exports__); /* harmony import */ var regenerator_runtime_runtime__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! regenerator-runtime/runtime */ "./node_modules/regenerator-runtime/runtime.js"); /* harmony import */ var regenerator_runtime_runtime__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(regenerator_runtime_runtime__WEBPACK_IMPORTED_MODULE_0__); var _marked = /*#__PURE__*/ regeneratorRuntime.mark(helloWorldGenerator); function helloWorldGenerator() { var a; return regeneratorRuntime.wrap(function helloWorldGenerator$(_context) { while (1) { switch (_context.prev = _context.next) { case 0: _context.next = 2; return 'hello'; case 2: a = _context.sent; // 补充: context 上面还有个比较重要的属性是 sent return _context.abrupt("return", a); case 4: case "end": return _context.stop(); } } }, _marked, this); }
文章 0 评论 0
接受
写的牛逼,补充下下面的情况:
ES6 系列之 Babel 将 Generator 编译成了什么样子?