UNPKG

707 BTypeScriptView Raw
1export interface Options {
2 /**
3 The string to use for the indent.
4
5 @default ' '
6 */
7 readonly indent?: string;
8
9 /**
10 Also indent empty lines.
11
12 @default false
13 */
14 readonly includeEmptyLines?: boolean;
15}
16
17/**
18Indent each line in a string.
19
20@param string - The string to indent.
21@param count - How many times you want `options.indent` repeated. Default: `1`.
22
23@example
24```
25import indentString from 'indent-string';
26
27indentString('Unicorns\nRainbows', 4);
28//=> ' Unicorns\n Rainbows'
29
30indentString('Unicorns\nRainbows', 4, {indent: '♥'});
31//=> '♥♥♥♥Unicorns\n♥♥♥♥Rainbows'
32```
33*/
34export default function indentString(
35 string: string,
36 count?: number,
37 options?: Options
38): string;