Options
All
  • Public
  • Public/Protected
  • All
Menu

Module chrono

Functions

executionTime

  • executionTime<I, O>(fn: SyncFunction<I, O>, context?: ObjMap, ...args: I[]): TimedExecutionResult<O>
  • Measure execution time of the given function.

    Type parameters

    • I

      Function arguments type.

    • O

      Function output type.

    Parameters

    • fn: SyncFunction<I, O>

      Function instance.

    • Optional context: ObjMap

      Function calling context (i.e. this).

    • Rest ...args: I[]

      Function arguments.

    Returns TimedExecutionResult<O>

    Function result and it's execution time.

executionTimeAsync

  • executionTimeAsync<I, O>(fn: AsyncFunction<I, O>, context?: ObjMap, ...args: I[]): Promise<TimedExecutionResult<O>>
  • Measure execution time of the given async function.

    Type parameters

    • I

      Function arguments type.

    • O

      Function output type.

    Parameters

    • fn: AsyncFunction<I, O>

      Async function instance.

    • Optional context: ObjMap

      Function calling context (i.e. this).

    • Rest ...args: I[]

      Function arguments.

    Returns Promise<TimedExecutionResult<O>>

    Function result and it's execution time.

firstDayOfNextMonth

  • firstDayOfNextMonth(): Date
  • Computes the date for next month at midnight time.

    Returns Date

    Date of first day for next month.

fromUnixTime

  • fromUnixTime(elapsed: Seconds): Date
  • Converts given UNIX time to Date equivalent.

    Parameters

    • elapsed: Seconds

      UNIX time.

    Returns Date

    Date equivalent.

milliseconds

  • milliseconds(hours?: Hours, minutes?: Minutes, seconds?: Seconds): Milliseconds
  • Convert hours, minutes and seconds to milliseconds.

    Parameters

    • hours: Hours = 0

      Number of hours.
      Defaults to 0.

    • minutes: Minutes = 0

      Number of minutes.
      Defaults to 0.

    • seconds: Seconds = 0

      Number of seconds.
      Defaults to 0.

    Returns Milliseconds

    Number of milliseconds.

millisecondsToSeconds

  • millisecondsToSeconds(ms: Milliseconds): Seconds
  • Converts milliseconds to seconds.

    Parameters

    • ms: Milliseconds

    Returns Seconds

minutesToSeconds

  • minutesToSeconds(minutes: Minutes): Seconds
  • Converts minutes to seconds.

    Parameters

    • minutes: Minutes

    Returns Seconds

secondsToMilliseconds

  • secondsToMilliseconds(seconds: Seconds): Milliseconds
  • Converts seconds to milliseconds.

    Parameters

    • seconds: Seconds

    Returns Milliseconds

sleep

  • sleep(ms: Milliseconds): Promise<void>
  • Sleeps for specified amount of milliseconds

    Parameters

    • ms: Milliseconds

      Number of milliseconds to sleep.

    Returns Promise<void>

tomorrow

  • tomorrow(): Date
  • Computes the date of tomorrow. Tomorrow computation will have current time.

    Returns Date

    Date of tomorrow.

unixTime

  • unixTime(date?: Date): Seconds
  • Convert given date to UNIX time.

    Parameters

    • date: Date = ...

      Date to be converted.

    Returns Seconds

    UNIX time equivalent of the date.