MCPcopy Create free account
hub / github.com/TruthHun/BookStack / race

Function race

static/word2md/mammoth.browser.js:8203–8230  ·  view source on GitHub ↗
(promises, parent)

Source from the content-addressed store, hash-verified

8201};
8202
8203function race(promises, parent) {
8204 var maybePromise = tryConvertToPromise(promises);
8205
8206 if (maybePromise instanceof Promise) {
8207 return raceLater(maybePromise);
8208 } else {
8209 promises = util.asArray(promises);
8210 if (promises === null)
8211 return apiRejection("expecting an array or an iterable object but got " + util.classString(promises));
8212 }
8213
8214 var ret = new Promise(INTERNAL);
8215 if (parent !== undefined) {
8216 ret._propagateFrom(parent, 3);
8217 }
8218 var fulfill = ret._fulfill;
8219 var reject = ret._reject;
8220 for (var i = 0, len = promises.length; i < len; ++i) {
8221 var val = promises[i];
8222
8223 if (val === undefined && !(i in promises)) {
8224 continue;
8225 }
8226
8227 Promise.cast(val)._then(fulfill, reject, undefined, ret, null);
8228 }
8229 return ret;
8230}
8231
8232Promise.race = function (promises) {
8233 return race(promises, undefined);

Callers 2

raceLaterFunction · 0.70
mammoth.browser.jsFile · 0.70

Calls 3

tryConvertToPromiseFunction · 0.70
raceLaterFunction · 0.70
apiRejectionFunction · 0.70

Tested by

no test coverage detected