@nrsk/unindent
v1.1.0
Published
Microlibrary for unindenting multiline strings.
Downloads
1,249
Maintainers
Readme
⇤
unindent
Microlibrary for unindenting multiline strings.
Installation
Node
Just use your favorite package manager:
npm i @nrsk/unindent
Deno
You can import the library via Skypack (note that ?dts
query parameter, that will pull types as well):
import un from 'https://cdn.skypack.dev/@nrsk/unindent?dts'
Usage
This library exposes only one function as the default export, which can be used as a tagged template, or as ordinary unary function:
import un from '@nrsk/unindent'
const x = un`
Sup!
- this is indented
- this is indented too
This line has the same indentation as the 1st line.
`
// Or...
const x = un(`
Sup!
- this is indented
- this is indented too
This line has the same indentation as the 1st line.
`)
x
will contain the following (without 4 leading spaces):
Sup!
- this is indented
- this is indented too
This line has the same indentation as the 1st line.
License
MIT.