source: imaps-frontend/node_modules/es-abstract/2019/AsyncFromSyncIteratorContinuation.js@ 79a0317

main
Last change on this file since 79a0317 was 79a0317, checked in by stefan toskovski <stefantoska84@…>, 3 days ago

F4 Finalna Verzija

  • Property mode set to 100644
File size: 1.5 KB
RevLine 
[d565449]1'use strict';
2
3var GetIntrinsic = require('get-intrinsic');
4
5var $SyntaxError = require('es-errors/syntax');
6var $TypeError = require('es-errors/type');
7var $Promise = GetIntrinsic('%Promise%', true);
8
[79a0317]9var callBound = require('call-bound');
[d565449]10
11var CreateIterResultObject = require('./CreateIterResultObject');
12var IteratorComplete = require('./IteratorComplete');
13var IteratorValue = require('./IteratorValue');
14var PromiseResolve = require('./PromiseResolve');
[79a0317]15
16var isObject = require('../helpers/isObject');
[d565449]17
18var $then = callBound('Promise.prototype.then', true);
19
20// https://262.ecma-international.org/10.0/#sec-asyncfromsynciteratorcontinuation
21
22module.exports = function AsyncFromSyncIteratorContinuation(result) {
[79a0317]23 if (!isObject(result)) {
[d565449]24 throw new $TypeError('Assertion failed: Type(O) is not Object');
25 }
26
27 if (arguments.length > 1) {
28 throw new $SyntaxError('although AsyncFromSyncIteratorContinuation should take a second argument, it is not used in this implementation');
29 }
30
31 if (!$Promise) {
32 throw new $SyntaxError('This environment does not support Promises.');
33 }
34
35 return new $Promise(function (resolve) {
36 var done = IteratorComplete(result); // step 2
37 var value = IteratorValue(result); // step 4
38 var valueWrapper = PromiseResolve($Promise, value); // step 6
39
40 // eslint-disable-next-line no-shadow
41 var onFulfilled = function (value) { // steps 8-9
42 return CreateIterResultObject(value, done); // step 8.a
43 };
44 resolve($then(valueWrapper, onFulfilled)); // step 11
45 }); // step 12
46};
Note: See TracBrowser for help on using the repository browser.