function indentString
indentString(
string: string,
count?: number,
options?: { indent?: string; includeEmptyLines?: boolean; }
): string

Prepends count repetitions of indent (default: one space) to each non-empty line of string.

indentString('hello\nworld', 2); // '  hello\n  world'
indentString('a\n\nb', 1, { indent: '\t', includeEmptyLines: true }); // '\ta\n\t\n\tb'

Parameters

string: string
optional
count: number = 1
optional
options: { indent?: string; includeEmptyLines?: boolean; }

Return Type

string

Usage

import { indentString } from "lib/utils/indent-string.ts";