Skip to main content
Deno 2 is finally here 🎉️
Learn more
Module

std/strings/pad.ts>pad

Deno standard library
Go to Latest
The Standard Library has been moved to JSR. See the blog post for details.
function pad
import { pad } from "https://deno.land/std@0.36.0/strings/pad.ts";

Pad helper for strings. Input string is processed to output a string with a minimal length. If the parameter strict is set to true, the output string length is equal to the strLen parameter. Example:

pad("deno", 6, { char: "*", side: "left" }) // output : "**deno"
pad("deno", 6, { char: "*", side: "right"}) // output : "deno**"
pad("denosorusrex", 6 {
  char: "*",
  side: "left",
  strict: true,
  strictSide: "right",
  strictChar: "..."
}) // output : "den..."

Parameters

input: string

Input string

strLen: number

Output string lenght

optional
opts: FillOption = [UNSUPPORTED]

Configuration object

Returns

string