Function sprintf

  • Converts and formats a variable number of args as is specified by format. sprintf returns the formatted string.

    See the module documentation for the available format strings.

    Parameters

    • format: string

      The format string to use

    • Rest...args: unknown[]

      The arguments to format

    Returns string

    The formatted string

    import { sprintf } from "@std/fmt/printf";
    import { assertEquals } from "@std/assert";

    assertEquals(sprintf("%d", 9), "9");

    assertEquals(sprintf("%o", 9), "11");

    assertEquals(sprintf("%f", 4), "4.000000");

    assertEquals(sprintf("%.3f", 0.9999), "1.000");