Library API
    Preparing search index...

    Function evaluateWith

    • Evaluates a value or invokes a function with the provided arguments. If the value is not a function, it is returned as-is.

      Type Parameters

      • T
      • A extends any[] = any[]

      Parameters

      • val: T | ((...args: A) => T)

        A scalar value or function to evaluate

      • ...args: A

        Arguments forwarded to the function if val is callable

      Returns T

      The resolved value

      evaluateWith(42); // 42
      evaluateWith((name: string) => `Hello, ${name}`, 'World'); // 'Hello, World'