UNPKG

581 BJavaScriptView Raw
1'use strict';
2var call = require('../internals/function-call');
3var getBuiltIn = require('../internals/get-built-in');
4var getMethod = require('../internals/get-method');
5
6module.exports = function (iterator, method, argument, reject) {
7 try {
8 var returnMethod = getMethod(iterator, 'return');
9 if (returnMethod) {
10 return getBuiltIn('Promise').resolve(call(returnMethod, iterator)).then(function () {
11 method(argument);
12 }, function (error) {
13 reject(error);
14 });
15 }
16 } catch (error2) {
17 return reject(error2);
18 } method(argument);
19};