@pengzhanbo/utils - v3.4.1
    Preparing search index...

    Function indent

    • Adds indentation to each line of a string

      为字符串的每行添加缩进

      Parameters

      • str: string

        The string to indent. 要缩进的字符串

      • indent: string = ' '

        The indentation string. Default is ' ' (two spaces). 缩进字符串,默认为两个空格

      Returns string

      The indented string. 缩进后的字符串

      indent('hello\nworld', '  ') // => '  hello\n  world'
      indent('foo\nbar', '\t') // => '\tfoo\n\tbar'