(innerFn, self, context)
| 20143 | }; |
| 20144 | |
| 20145 | function makeInvokeMethod(innerFn, self, context) { |
| 20146 | var state = GenStateSuspendedStart; |
| 20147 | |
| 20148 | return function invoke(method, arg) { |
| 20149 | if (state === GenStateExecuting) { |
| 20150 | throw new Error("Generator is already running"); |
| 20151 | } |
| 20152 | |
| 20153 | if (state === GenStateCompleted) { |
| 20154 | if (method === "throw") { |
| 20155 | throw arg; |
| 20156 | } |
| 20157 | |
| 20158 | // Be forgiving, per 25.3.3.3.3 of the spec: |
| 20159 | // https://people.mozilla.org/~jorendorff/es6-draft.html#sec-generatorresume |
| 20160 | return doneResult(); |
| 20161 | } |
| 20162 | |
| 20163 | context.method = method; |
| 20164 | context.arg = arg; |
| 20165 | |
| 20166 | while (true) { |
| 20167 | var delegate = context.delegate; |
| 20168 | if (delegate) { |
| 20169 | var delegateResult = maybeInvokeDelegate(delegate, context); |
| 20170 | if (delegateResult) { |
| 20171 | if (delegateResult === ContinueSentinel) continue; |
| 20172 | return delegateResult; |
| 20173 | } |
| 20174 | } |
| 20175 | |
| 20176 | if (context.method === "next") { |
| 20177 | // Setting context._sent for legacy support of Babel's |
| 20178 | // function.sent implementation. |
| 20179 | context.sent = context._sent = context.arg; |
| 20180 | |
| 20181 | } else if (context.method === "throw") { |
| 20182 | if (state === GenStateSuspendedStart) { |
| 20183 | state = GenStateCompleted; |
| 20184 | throw context.arg; |
| 20185 | } |
| 20186 | |
| 20187 | context.dispatchException(context.arg); |
| 20188 | |
| 20189 | } else if (context.method === "return") { |
| 20190 | context.abrupt("return", context.arg); |
| 20191 | } |
| 20192 | |
| 20193 | state = GenStateExecuting; |
| 20194 | |
| 20195 | var record = tryCatch(innerFn, self, context); |
| 20196 | if (record.type === "normal") { |
| 20197 | // If an exception is thrown from innerFn, we leave state === |
| 20198 | // GenStateExecuting and loop back for another invocation. |
| 20199 | state = context.done |
| 20200 | ? GenStateCompleted |
| 20201 | : GenStateSuspendedYield; |
| 20202 |
no test coverage detected