Documentation
    Preparing search index...

    Class Consumable<T>

    Single-shot value envelope. Holds a value until exactly one consumer calls Consumable.consume; subsequent reads return undefined.

    Type Parameters

    • T
    Index

    Constructors

    Accessors

    Methods

    Constructors

    • Wrap value. If value is already a Consumable, returns it unchanged so the type stays flat.

      Type Parameters

      • T

      Parameters

      Returns Consumable<T>

    Accessors

    • get consumed(): boolean

      true once Consumable.consume has been called.

      Returns boolean

    Methods

    • Take ownership of the wrapped value. The next call returns undefined. Use this when the value is about to be acted on exactly once.

      Returns undefined | T

    • Read the wrapped value without consuming it. undefined once consumed.

      Returns undefined | T