PromiseLogic.xnor()

Composite Logic GateXNOR Logic - Succeeds when all Promises succeed or all fail

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

ParameterTypeDescription
iterableIterable<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

XNOR_ERRORThrown when some Promises succeed and some fail (partial success)

Examples

Basic Usage - All Succeed

XNOR Logic Example - Succeeds when all Promises succeed

JAVASCRIPT
Loading...

Basic Usage - All Fail

XNOR Logic Example - Succeeds when all Promises fail

JAVASCRIPT
Loading...

Error Handling

XNOR Logic Failure Example - Partial success

JAVASCRIPT
Loading...

Timeout Control

Add timeout control with maxTimer method

JAVASCRIPT
Loading...

Real Application

Consistency check with timeout

JAVASCRIPT
Loading...

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