Options
All
  • Public
  • Public/Protected
  • All
Menu

Module constant

Index

References

Functions Util

References

Renames and re-exports constant

Util Functions

  • constant<T>(value?: T): (() => T)
  • Creates a function that returns value.

    since

    5.0.0

    example
    var objects = times(2, constant({ 'a': 1 }));

    console.log(objects);
    // => [{ 'a': 1 }, { 'a': 1 }]

    console.log(objects[0] === objects[1]);
    // => true

    Type Parameters

    • T

    Parameters

    • Optional value: T

      The value to return from the new function.

    Returns (() => T)

    Returns the new constant function.

      • (): T
      • Creates a function that returns value.

        since

        5.0.0

        category

        Util

        example
        var objects = times(2, constant({ 'a': 1 }));

        console.log(objects);
        // => [{ 'a': 1 }, { 'a': 1 }]

        console.log(objects[0] === objects[1]);
        // => true

        Returns T

        Returns the new constant function.