dedent
Strips the common leading whitespace from every line of a multi-line string, and trims a single leading/trailing blank line if present.
Lets you write readable, indented multi-line strings in source code (typically template literals) without that indentation leaking into the output.
Available since v3.0.0
Import
Section titled “Import”Signature
Section titled “Signature”Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
str | string | The string to dedent |
Returns
Section titled “Returns”string — The dedented string
Examples
Section titled “Examples”Write readable multi-line strings without leaking source indentation
Section titled “Write readable multi-line strings without leaking source indentation”Strips the common leading whitespace and the wrapping blank lines.
The minimum indentation across all lines is what gets removed
Section titled “The minimum indentation across all lines is what gets removed”Lines with more indentation than the minimum keep their relative indent.
