multili
Version:
Function to remove indentation in multi-lines template literals (string) based on the indented line.
97 lines (74 loc) • 1.85 kB
Markdown
# multili
[](https://travis-ci.org/MoOx/multili)
[](https://coveralls.io/github/MoOx/multili)
[](https://github.com/MoOx/multili/blob/master/CHANGELOG.md)
[](https://github.com/MoOx/multili)
[](https://gitlab.com/MoOx/multili)
[](https://bitbucket.org/MoOx/multili)
> Function to remove indentation in multi-lines template literals (string) based on the shortest indented line.
## Installation
```console
$ npm install multili
```
## Usage
```js
import multili from "multili"
multili(
`
This is a
multi-lines
string
`
)
// Will produce
/*
This is a
multi-lines
string
*/
multili(`
This is a
multi-lines
string
`)
// Will produce
/*
This is a
multi-lines
string
*/
multili(`
This is a
multi-lines
string
`)
// Will produce
/*
This is a
multi-lines
string
*/
```
You can also pass an array of lines instead of a string; in this case, the return value will also be an array.
```js
multili([
" This is a",
" milti-line",
" string",
])
// Will produce
/*
[
"This is a",
" milti-line",
" string",
]
*/
```
---
## CONTRIBUTING
* ⇄ Pull/Merge requests and ★ Stars are always welcome.
* For bugs and feature requests, please create an issue.
* Pull/Merge requests must be accompanied by passing automated tests (`$ npm test`).
## [CHANGELOG](CHANGELOG.md)
## [LICENSE](LICENSE)