Common utilities for Monterail projects
npm install @monteway/utilsTiny but useful utilities.
``bash`
npm i @monteway/utils
- Trims useless spaces from the beginning of each line.
- Removes empty new lines at the beginning and end of the input.
- Keeps the identation pattern.
#### Example
`ts
import { trimMultiline } from '@monteway/utils/format';
const code =
function foo() {
return bar;
};
const output = trimMultiline(code);
`
- If we do console.log(code), the result will be:
``
function foo() {
return bar;
}
- If we do console.log(output), the result will be different by trimming the trailing, useless spaces:
``
function foo() {
return bar;
}
> This shows, that trimMultiline acts a little bit like Prettier.
#### Options
As a second, optional arguments we might pass an object:
`ts
{
// Make sure the miniam identation is this number of spaces.
indentBy?: number;
// Keep a single new line at the beginning of the output (since by default it's removed).
startWithNewLine?: boolean;
}
``