Options
All
  • Public
  • Public/Protected
  • All
Menu

External module "utils/constant-function/docs/types/index.d"

Index

Functions

Functions

Export assignment constantFunction

  • constantFunction<T>(value?: T): () => T
  • Creates a function which always returns the same value.

    Notes

    • When provided an object reference, the returned function always returns the same reference.

    Type parameters

    • T

    Parameters

    • Optional value: T

      value to always return

    Returns ( ) => T

    constant function

      • (): T
      • Returns T

    Example

    var fcn = constantFunction( 3.14 );
    
    var v = fcn();
    // returns 3.14
    
    v = fcn();
    // returns 3.14
    
    v = fcn();
    // returns 3.14