PromiseLogic.and()
The PromiseLogic.and() method implements AND logic gate semantics, succeeding when all input Promises succeed. It returns a PromiseWithTimer instance which wraps the native Promise and provides additional functionality.
Syntax
javascript PromiseLogic.and(iterable)
Parameters
| Parameter | Type | Description |
|---|---|---|
| iterable | Iterable<Promise<T>> | An iterable collection of Promise objects |
Return Value
Returns a PromiseWithTimer that resolves to an array of all input Promise successful values.
PromiseWithTimer<T[]>Behavior
Success Condition
When all input Promises resolve successfully, returns a PromiseWithTimer that resolves to an array of all successful values.
Failure Condition
When any input Promise is rejected, the PromiseWithTimer is immediately rejected with the first rejection reason.
Error Types
Examples
Basic Usage
AND Logic Example - Succeeds when all Promises succeed
Error Handling
AND Logic Failure Example - Any Promise failure causes overall failure
Timeout Control
Add timeout control with maxTimer method
Real Application
Load multiple API data in parallel with timeout
Important Notes
- • AND logic behaves exactly like standard Promise.all()
- • Any Promise failure immediately causes overall failure (short-circuit behavior)
- • Returns PromiseWithTimer which supports maxTimer() for timeout control
- • maxTimer can only detect timeout, cannot cancel the Promise operation itself
- • Suitable for scenarios where all operations must succeed to continue
- • For scenarios where partial success is acceptable, consider using PromiseLogic.or()