main
Last change
on this file was 79a0317, checked in by stefan toskovski <stefantoska84@…>, 3 days ago |
F4 Finalna Verzija
|
-
Property mode
set to
100644
|
File size:
1.0 KB
|
Line | |
---|
1 | 'use strict';
|
---|
2 | var $ = require('../internals/export');
|
---|
3 | var call = require('../internals/function-call');
|
---|
4 | var aCallable = require('../internals/a-callable');
|
---|
5 | var newPromiseCapabilityModule = require('../internals/new-promise-capability');
|
---|
6 | var perform = require('../internals/perform');
|
---|
7 | var iterate = require('../internals/iterate');
|
---|
8 | var PROMISE_STATICS_INCORRECT_ITERATION = require('../internals/promise-statics-incorrect-iteration');
|
---|
9 |
|
---|
10 | // `Promise.race` method
|
---|
11 | // https://tc39.es/ecma262/#sec-promise.race
|
---|
12 | $({ target: 'Promise', stat: true, forced: PROMISE_STATICS_INCORRECT_ITERATION }, {
|
---|
13 | race: function race(iterable) {
|
---|
14 | var C = this;
|
---|
15 | var capability = newPromiseCapabilityModule.f(C);
|
---|
16 | var reject = capability.reject;
|
---|
17 | var result = perform(function () {
|
---|
18 | var $promiseResolve = aCallable(C.resolve);
|
---|
19 | iterate(iterable, function (promise) {
|
---|
20 | call($promiseResolve, C, promise).then(capability.resolve, reject);
|
---|
21 | });
|
---|
22 | });
|
---|
23 | if (result.error) reject(result.value);
|
---|
24 | return capability.promise;
|
---|
25 | }
|
---|
26 | });
|
---|
Note:
See
TracBrowser
for help on using the repository browser.