Socket
Socket
Sign inDemoInstall

multiline-string

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

multiline-string

Nicer look for multiline strings in the code


Version published
Weekly downloads
16
decreased by-69.81%
Maintainers
1
Weekly downloads
 
Created
Source

Build Status Coverage Status

multiline-string

Remove leading space characters to let you nicely indent your multiline strings in your code.

Prerequisite

  • Node v4+

Usage

By default, multiline detects indentation by looking at the first non-empty line. Notice that the first empty line is dropped from the output to let you to start the first line with the indentation level you like.

const multiline = require('multiline-string')()

const s = multiline(`
            1. xxx
              a. yyy
            2. zzz
            `)

console.log(s)
// => "1. xxx\n  a. yyy\n2. zzz"

If you want to start your string with an empty line, you can do:

const s = multiline(`

            Line 1
            Line 2
            `)
// => "\nLine 1\nLine 2\n"

You can also give marginMark to identify the start of each line to include indentation in the resulting text.

const multiline = require('multiline-string')({ marginMark: '|' })

const s = multiline(`
            |  Usage: my-command file
            |
            |    -v, --version    Show version
            |    -h, --help       Show help information
            |`)

console.log(s)
// => "  Usage: ...\n\n    -v, --version ..."

Keywords

FAQs

Package last updated on 26 Apr 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc