https://github.com/mvasilkov/outdent
Remove extra indentation from multiline strings.
https://github.com/mvasilkov/outdent
no-dependencies outdent template-literal template-string typescript unindent
Last synced: 2 months ago
JSON representation
Remove extra indentation from multiline strings.
- Host: GitHub
- URL: https://github.com/mvasilkov/outdent
- Owner: mvasilkov
- License: mit
- Created: 2020-01-14T20:41:23.000Z (about 6 years ago)
- Default Branch: master
- Last Pushed: 2020-05-18T18:09:41.000Z (almost 6 years ago)
- Last Synced: 2025-10-24T22:33:48.352Z (5 months ago)
- Topics: no-dependencies, outdent, template-literal, template-string, typescript, unindent
- Language: JavaScript
- Homepage: https://www.npmjs.com/package/@mvasilkov/outdent
- Size: 21.5 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
outdent
===
Remove extra indentation from multiline strings.
[![npm][npm-badge]][npm-url]
[![no dependencies][dependencies-badge]][dependencies-url]
[![][size-badge]][npm-url]
---
Use [@mvasilkov/outdent][npm-url] to remove extraneous leading whitespace from
multiline strings. This makes your hair silky and shiny, and probably has
other uses.
Installation
---
```sh
npm add @mvasilkov/outdent
```
Usage
---
```javascript
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
[npm-badge]: https://img.shields.io/npm/v/@mvasilkov/outdent.svg?style=flat
[npm-url]: https://www.npmjs.com/package/@mvasilkov/outdent
[dependencies-badge]: https://img.shields.io/librariesio/release/npm/@mvasilkov/outdent?style=flat
[dependencies-url]: https://www.npmjs.com/package/@mvasilkov/outdent?activeTab=dependencies
[size-badge]: https://img.shields.io/github/size/mvasilkov/outdent/javascript/outdent.js.svg?style=flat