PromiseLogic.xnor()
The PromiseLogic.xnor() method implements XNOR (exclusive NOR) logic gate semantics, succeeding when all Promises succeed OR all Promises fail. It returns a PromiseWithTimer instance which wraps native Promise and provides additional functionality.
Syntax
javascript PromiseLogic.xnor(iterable)
Parameters
| Parameter | Type | Description |
|---|---|---|
| iterable | Iterable<Promise<T>> | An iterable collection of Promise objects |
Return Value
Returns a PromiseWithTimer that resolves to array of successful results when all succeed, or empty array when all fail.
PromiseWithTimer<T[]>Behavior
Success Condition
When all Promises succeed or all Promises fail, PromiseWithTimer resolves to array of successful results (or empty array if all fail).
Failure Condition
When some Promises succeed and some fail, PromiseWithTimer is rejected.
Error Types
Examples
Basic Usage - All Succeed
XNOR Logic Example - Succeeds when all Promises succeed
Basic Usage - All Fail
XNOR Logic Example - Succeeds when all Promises fail
Error Handling
XNOR Logic Failure Example - Partial success
Timeout Control
Add timeout control with maxTimer method
Real Application
Consistency check with timeout
Important Notes
- • XNOR logic succeeds when all Promises succeed OR all Promises fail
- • Returns PromiseWithTimer which supports maxTimer() for timeout control
- • maxTimer can only detect timeout, cannot cancel Promise operation itself
- • Suitable for scenarios requiring consistency checking or symmetry verification
- • Returns array of successful results when all succeed, empty array when all fail
- • When some succeed and some fail, throws XNOR_ERROR