PromiseLogic.race()
Core Logic GateRACE Logic - Returns the first completed Promise (regardless of success or failure)
The PromiseLogic.race() method implements RACE (competition) logic gate semantics, returning the value of the first completed Promise, whether that Promise succeeded or failed. It is equivalent to standard Promise.race(), but provides more intuitive logical semantics.
Syntax
javascript
PromiseLogic.race(iterable)
Parameters
| Parameter | Type | Description |
|---|---|---|
| iterable | Iterable<Promise<T>> | An iterable collection of Promise objects |
Return Value
Returns a Promise that resolves to the value of the first completed Promise (regardless of success or failure).
Promise<T>Behavior
Completion Condition
Returns the value of the first completed Promise, whether that Promise succeeded or failed.
Special Case
If the first completed Promise failed, the returned Promise will also be rejected.
Examples
Basic Usage
RACE Logic Example - Returns the first completed Promise
JAVASCRIPT
Loading...
Error Handling
RACE Logic Example - First completed Promise fails
JAVASCRIPT
Loading...
Real Application
Timeout control
JAVASCRIPT
Loading...
Important Notes
- • RACE logic behaves exactly like standard Promise.race()
- • Returns the first completed Promise, whether successful or failed
- • Suitable for timeout control, performance racing scenarios
- • Note: If the first completed Promise fails, the entire operation will also fail