@tusss/ood
    Preparing search index...

    Class Counter

    A utility class representing a counter that can be incremented and reset.

    The Counter class provides a simple mechanism to maintain an incremental state, beginning from an optional initial value (defaults to 0).

    Basic usage showing initialization, incrementing, and resetting:

    const counter = new Counter(10);
    console.log(counter.current); // 10

    counter.next(); // 11
    console.log(counter.current); // 11

    counter.reset();
    console.log(counter.current); // 10
    Index

    Constructors

    Accessors

    Methods

    Constructors

    • Initializes a new instance of the Counter class.

      Parameters

      • initialValue: number = 0

        The starting value of the counter. Defaults to 0.

      Returns Counter

    Accessors

    • get current(): number

      Gets the current value of the counter.

      Returns number

    Methods

    • Increments the counter and returns the new value.

      Returns number

      The updated counter value.

    • Resets the counter back to its initial value.

      Returns void