Package Exports
- undent
- undent/dist/index.js
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (undent) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
undent
Remove indentation from multi-line strings.
Installation
npm
npm install undent -gUsage
import undent from 'undent';
//use as a function
const first = undent(`multi-line\n\tindented\nstring`); // "multi-line\n\t\nstring"
//use as a template literal tag
const second = undent`
multi-line
indented
string
`; // "multi-line\n indented\nstring"The algorithm
undent finds the line with the least amount of indentation (excluding whitespace-only lines), and then removes that amount of indentation from every line.
For example:
const text = undent`
two levels in
one level in
three levels in
`;
console.log(text);prints
two levels in
one level in
three levels inFeatures
- remove leading indentation based on the smallest indentation found for all lines (excluding whitespace-only lines)
- trim the end of every line
- remove leading/trailing newlines
- retain existing newline characters (
\ror\r\n)
Changelog
Click here to view the changelog.