• Measures the time it takes for a promise to resolve or reject.

    Example


    import { duration } from "@mrspartak/promises"
    import { migrate } from "./migrate"

    const migratePromise = migrate()

    // Measure the duration of the migrate function
    const [error, result, duration] = await duration(migratePromise)

    console.log(`Migration took ${duration}ms`)

    Type Parameters

    • $Promise extends Promise<any>

    Parameters

    • promise: $Promise

      The promise to be measured.

    Returns Promise<DurationOut<Awaited<$Promise>>>

    A promise that resolves to a tuple containing either an error or a value, and the duration in milliseconds.