Class Duration

Represents a duration, typically in milliseconds, with utility methods for parsing and formatting.

Hierarchy

  • Duration

Constructors

  • Creates a new instance of Duration with the specified duration in milliseconds.

    Parameters

    • duration: number

      The duration in milliseconds.

    Returns Duration

Properties

duration: number

The duration in milliseconds.

Methods

  • Converts the duration to a string in the format hh:mm:ss.

    Returns

    A string representing the duration in hh:mm:ss format.

    Returns string

  • Converts the duration to a human-readable string.

    Returns

    A string representing the duration in a human-readable format (e.g., "1d 2h 3m 4s").

    Returns string

  • Returns the duration in milliseconds.

    Returns

    The duration in milliseconds.

    Returns number

  • Creates a Duration instance from a human-readable string representing the duration.

    Returns

    A Duration object.

    Parameters

    • data: string

      The human-readable string representing the duration (e.g., "1d 2h 3m 4s").

    Returns Duration

  • Parses a duration string (e.g., "1d 2h 3m") and converts it to milliseconds.

    Returns

    The duration in milliseconds.

    Throws

    Error if the duration format is invalid.

    Parameters

    • durationStr: string

      The string representing the duration in a human-readable format.

    Returns number

Generated using TypeDoc