Module utils

Synopsis

Functions
utils.assertEq()

Asserts that two expressions are equal to each other

utils.assertNe()

Asserts that two expressions are not equal to each other

utils.secs()

Converts seconds to nanoseconds

utils.millis()

Converts milliseconds to nanoseconds

utils.micros()

Converts microseconds to nanoseconds

utils.nanos()

Converts nanoseconds to nanoseconds

utils.assertEq(lhs, rhs, msg)

Asserts that two expressions are equal to each other. Raises an error otherwise.

Parameters
lhs (any)

Left value

rhs (any)

Right value

msg (string or nil)

Optional custom error message

utils.assertNe(lhs, rhs, msg)

Asserts that two expressions are not equal to each other. Raises an error otherwise.

Parameters
lhs (any)

Left value

rhs (any)

Right value

msg (string or nil)

Optional custom error message

utils.secs(time)

Converts seconds to nanoseconds. Useful for explicitly specifying MainLoopScheduler timer duration.

Example
token = MainLoopScheduler.prependTimer(
    MainLoopStage.USER,
    "MyTimer",
    TimerRecurrence.Recurring,
    secs(5),
    handler
)
Parameters
time (number)

Seconds

Return Values
(number)

Nanoseconds

utils.millis(time)

Converts milliseconds to nanoseconds. Useful for explicitly specifying MainLoopScheduler timer duration.

Example
token = MainLoopScheduler.prependTimer(
    MainLoopStage.USER,
    "MyTimer",
    TimerRecurrence.Recurring,
    millis(5),
    handler
)
Parameters
time (number)

Milliseconds

Return Values
(number)

Nanoseconds

utils.micros(time)

Converts microseconds to nanoseconds. Useful for explicitly specifying MainLoopScheduler timer duration.

Example
token = MainLoopScheduler.prependTimer(
    MainLoopStage.USER,
    "MyTimer",
    TimerRecurrence.Recurring,
    micros(5),
    handler
)
Parameters
time (number)

Microseconds

Return Values
(number)

Nanoseconds

utils.nanos(time)

Converts nanoseconds to nanoseconds. Useful for explicitly specifying MainLoopScheduler timer duration.

Example
token = MainLoopScheduler.prependTimer(
    MainLoopStage.USER,
    "MyTimer",
    TimerRecurrence.Recurring,
    nanos(5),
    handler
)
Parameters
time (number)

Nanoseconds

Return Values
(number)

Nanoseconds