MCPcopy Create free account
hub / github.com/Code-Bullet/Jump-King / race

Function race

libraries/p5.js:702–718  ·  view source on GitHub ↗

`Promise.race` returns a new promise which is settled in the same way as the first passed promise to settle. Example: ```javascript let promise1 = new Promise(function(resolve, reject){ setTimeout(function(){ resolve('promise 1'); }, 200); }); let promise2 = new Promise(

(entries)

Source from the content-addressed store, hash-verified

700 promise to settle.
701*/
702function race(entries) {
703 /*jshint validthis:true */
704 var Constructor = this;
705
706 if (!isArray(entries)) {
707 return new Constructor(function (_, reject) {
708 return reject(new TypeError('You must pass an array to race.'));
709 });
710 } else {
711 return new Constructor(function (resolve, reject) {
712 var length = entries.length;
713 for (var i = 0; i < length; i++) {
714 Constructor.resolve(entries[i]).then(resolve, reject);
715 }
716 });
717 }
718}
719
720/**
721 `Promise.reject` returns a promise rejected with the passed `reason`.

Callers

nothing calls this directly

Calls 1

rejectFunction · 0.85

Tested by

no test coverage detected