Library API
    Preparing search index...

    Function evaluateAsync

    Evaluates asynchronous candidates in order and stops at the first defined value.

    Values, promises, or supplier functions to evaluate.

    The first defined result, or undefined if all candidates resolve to undefined.

    • Evaluates candidate synchronous or asynchronous scalars, Promises, or supplier functions in order, returning the first defined result (async lazy coalesce). Supplier functions represent deferred asynchronous work and are invoked lazily only when reached during evaluation. Rejection handlers are attached upfront to direct Promise candidates to prevent unobserved rejections if iteration short-circuits on an earlier defined candidate. If all candidates evaluate to undefined, returns undefined. Any exception or rejection thrown by an evaluated candidate bubbles directly to the caller.

      Type Parameters

      • T

      Parameters

      Returns Promise<T>

      A Promise resolving to the first defined value, or undefined if none resolved

      await evaluateAsync('apiKey123'); // 'apiKey123'
      await evaluateAsync(undefined, async () => fetchSecret(), 'defaultKey'); // 'secret'
    • Evaluates candidate synchronous or asynchronous scalars, Promises, or supplier functions in order, returning the first defined result (async lazy coalesce). Supplier functions represent deferred asynchronous work and are invoked lazily only when reached during evaluation. Rejection handlers are attached upfront to direct Promise candidates to prevent unobserved rejections if iteration short-circuits on an earlier defined candidate. If all candidates evaluate to undefined, returns undefined. Any exception or rejection thrown by an evaluated candidate bubbles directly to the caller.

      Type Parameters

      • T

      Parameters

      • ...values: (AsyncEvaluable<T> | undefined)[]

        One or more scalars, Promises, or async supplier functions to evaluate in sequence

      Returns Promise<T | undefined>

      A Promise resolving to the first defined value, or undefined if none resolved

      await evaluateAsync('apiKey123'); // 'apiKey123'
      await evaluateAsync(undefined, async () => fetchSecret(), 'defaultKey'); // 'secret'