PromiseLogic.or()
Core Logic GateOR Logic - Returns the first successful Promise
The PromiseLogic.or() method implements OR logic gate semantics, returning the value of the first Promise that resolves successfully. It is equivalent to standard Promise.any(), but provides more intuitive logical semantics.
Syntax
javascript
PromiseLogic.or(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 successful Promise.
Promise<T>Behavior
Success Condition
Returns the value of the first Promise that resolves successfully.
Failure Condition
When all input Promises are rejected, the returned Promise is rejected with an AggregateError containing all rejection reasons.
Examples
Basic Usage
OR Logic Example - Returns the first successful Promise
JAVASCRIPT
Loading...
Error Handling
OR Logic Failure Example - All Promises fail
JAVASCRIPT
Loading...
Real Application
Service degradation strategy
JAVASCRIPT
Loading...
Important Notes
- • OR logic behaves similarly to standard Promise.any(), but provides more intuitive logical semantics
- • Suitable for scenarios requiring service degradation or failover
- • When all Promises fail, returns AggregateError containing all failure reasons
- • For scenarios where all operations must succeed, consider using PromiseLogic.and()