Library API
    Preparing search index...

    Function evaluate

    Evaluates candidates in order and returns the first defined result.

    Values or zero-argument functions that produce candidate results

    The first result that is not undefined, or undefined if no candidate produces one

    • Evaluates candidate synchronous scalars or supplier functions in order, returning the first defined result (lazy coalesce). If a candidate is a function, it is invoked with zero arguments. Candidates after the first defined value are never evaluated (short-circuiting). If all candidates evaluate to undefined, returns undefined. Any exception thrown by an evaluated supplier function bubbles directly to the caller.

      Type Parameters

      • T

      Parameters

      Returns T

      The first resolved defined value, or undefined if none resolved

      evaluate(42); // 42
      evaluate(() => 'UTC'); // 'UTC'
      evaluate(undefined, 'fallback'); // 'fallback'
      evaluate(undefined, () => undefined, () => 'dynamic-fallback', 'final'); // 'dynamic-fallback'
    • Evaluates candidate synchronous scalars or supplier functions in order, returning the first defined result (lazy coalesce). If a candidate is a function, it is invoked with zero arguments. Candidates after the first defined value are never evaluated (short-circuiting). If all candidates evaluate to undefined, returns undefined. Any exception thrown by an evaluated supplier function bubbles directly to the caller.

      Type Parameters

      • T

      Parameters

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

        One or more scalars or synchronous supplier functions to evaluate in sequence

      Returns T | undefined

      The first resolved defined value, or undefined if none resolved

      evaluate(42); // 42
      evaluate(() => 'UTC'); // 'UTC'
      evaluate(undefined, 'fallback'); // 'fallback'
      evaluate(undefined, () => undefined, () => 'dynamic-fallback', 'final'); // 'dynamic-fallback'