• Pads the left side of a given value with a specified padding character.

    This function is used to ensure that a string or number has a certain minimum length. If the length of the value is less than the specified length, this function adds padding characters to the left side of the value until it reaches the specified length. If no padding character is specified, this function uses a space (" ") as the default padding character.

    Parameters

    • value: string | number

      The value to pad. This can be a string or a number.

    • length: number

      The minimum length for the padded value.

    • Optional padding: string

      The character to use for padding. If not specified, a space (" ") is used.

    Returns string

    The padded value as a string.

    Example

    // Pad a number with zeros
    const paddedNumber = ix.api.text.padLeft(123, 5, "0");
    console.log(paddedNumber); // Outputs: "00123"

    // Pad a string with spaces
    const paddedString = ix.api.text.padLeft("abc", 5);
    console.log(paddedString); // Outputs: " abc"