everyTransactionPlanResult

function everyTransactionPlanResult(
    transactionPlanResult,
    predicate,
): boolean;

Checks if every transaction plan result in the tree satisfies the given predicate.

This function performs a depth-first traversal through the transaction plan result tree, returning true only if the predicate returns true for every result in the tree (including the root result and all nested results).

Parameters

ParameterTypeDescription
transactionPlanResultTransactionPlanResultThe transaction plan result tree to check.
predicate(plan) => booleanA function that returns true if the result satisfies the condition.

Returns

boolean

true if every result in the tree satisfies the predicate, false otherwise.

Examples

Checking if all transactions were successful.

const result = parallelTransactionPlanResult([
  successfulSingleTransactionPlanResult(messageA, transactionA),
  successfulSingleTransactionPlanResult(messageB, transactionB),
]);
 
const allSuccessful = everyTransactionPlanResult(
  result,
  (r) => r.kind !== 'single' || r.status.kind === 'successful',
);
// Returns true because all single results are successful.

Checking if no transactions were canceled.

const result = sequentialTransactionPlanResult([resultA, resultB, resultC]);
 
const noCanceled = everyTransactionPlanResult(
  result,
  (r) => r.kind !== 'single' || r.status.kind !== 'canceled',
);

See

On this page