Miss any of our Open RFC calls?Watch the recordings here! »

@mvasilkov/outdent

1.0.5 • Public • Published

outdent

Remove extra indentation from multiline strings.

npm no dependencies


Use @mvasilkov/outdent to remove extraneous leading whitespace from multiline strings. This makes your hair silky and shiny, and probably has other uses.

Installation

npm add @mvasilkov/outdent

Usage

const { outdent } = require('@mvasilkov/outdent')
 
console.log(outdent(`
    The nine most terrifying words in the English language are,
    “I’m from the government and I’m here to help.”
`))

Syntax

outdent(string, [options])

Receives a string, returns a string with unnecessary indentation removed.

outdentLines(strings, [options])

Accepts an array of strings, returns an array of strings. Useful when you have an array of strings.

Options

{ strict: true }

Treat the indentation of the first line as meaningful. This is usually the case when loading strings from a file.

{ strict: false }

Ignore the first line's indentation, and drop the first and the last line when empty. Useful for writing multiline strings in JS. This is the default.

{ endWithNewline: true }

When enabled, insert a line break at the end of the result, if there is none. Does nothing when strict: true is in effect.

License

MIT

Install

npm i @mvasilkov/outdent

DownloadsWeekly Downloads

0

Version

1.0.5

License

MIT

Unpacked Size

5.59 kB

Total Files

5

Last publish

Collaborators

  • avatar