1 | 'use strict';
|
2 | var call = require('../internals/function-call');
|
3 | var getBuiltIn = require('../internals/get-built-in');
|
4 | var getMethod = require('../internals/get-method');
|
5 |
|
6 | module.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 | };
|