Options
All
  • Public
  • Public/Protected
  • All
Menu

Class Lazy<T>

Represent a lazily evaluated value. You give a function which will return a value; that function is only called when the value is requested from Lazy, but it will be computed at most once. If the value is requested again, the previously computed result will be returned: Lazy is memoizing.

Type parameters

  • T

Hierarchy

  • Lazy

Index

Methods

Static of

  • of<T>(thunk: function): Lazy<T>
  • Build a Lazy from a computation returning a value. The computation will be called at most once.

    Type parameters

    • T

    Parameters

    • thunk: function
        • (): T
        • Returns T

    Returns Lazy<T>

__computed

  • __computed(): string
  • Used by the node REPL to display values. Most of the time should be the same as toString()

    Returns string

get

  • get(): T
  • Evaluate the value, cache its value, and return it, or return the previously computed value.

    Returns T

isEvaluated

  • isEvaluated(): boolean
  • Returns true if the computation underlying this Lazy was already performed, false otherwise.

    Returns boolean

map

  • map<U>(mapper: function): Lazy<U>
  • Return a new lazy where the element was transformed by the mapper function you give.

    Type parameters

    • U

    Parameters

    • mapper: function
        • (v: T): U
        • Parameters

          • v: T

          Returns U

    Returns Lazy<U>

toString

  • toString(): string
  • Get a human-friendly string representation of that value.

    Returns string

Generated using TypeDoc