Options
All
  • Public
  • Public/Protected
  • All
Menu

External module "utils/if-then/docs/types/index.d"

Index

Functions

Functions

Export assignment ifthen

  • ifthen(bool: boolean, x: Function, y: Function): any
  • If a condition is truthy, invokes x; otherwise, invokes y.

    Parameters

    • bool: boolean

      condition

    • x: Function

      function to invoke if a condition is truthy

    • y: Function

      function to invoke if a condition is falsy

    Returns any

    return value of either x or y

    Example

    var randu = require( `@stdlib/random/base/randu` );
    
    function x() {
        return randu() * 100.0;
    }
    
    function y() {
        return -1.0 * randu() * 100.0;
    }
    
    var z = ifthen( randu() > 0.5, x, y );
    // returns <number>