0.4.2 • Published 2 years ago

@monteway/utils v0.4.2

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

@monteway/utils

Tiny but useful utilities.

Install

npm i @monteway/utils

Usage

trimMultiline

  • 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

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:

{
  // 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;
}
0.4.0-rc.2

2 years ago

0.4.0-rc.1

2 years ago

0.3.2-rc.1

2 years ago

0.3.2

2 years ago

0.4.1-rc.1

2 years ago

0.4.1

2 years ago

0.4.0

2 years ago

0.4.2

2 years ago

0.2.0-rc.6

3 years ago

0.2.0-rc.3

3 years ago

0.2.0-rc.2

3 years ago

0.2.0-rc.5

3 years ago

0.2.0-rc.4

3 years ago

0.2.0-rc.1

3 years ago

0.0.40-rc.5

3 years ago

0.0.40-rc.4

3 years ago

0.0.40-rc.7

3 years ago

0.0.40-rc.6

3 years ago

0.0.40-rc.3

3 years ago

0.0.40-rc.2

3 years ago

0.1.0

3 years ago

0.3.0

3 years ago

0.0.40-rc.9

3 years ago

0.0.40-rc.8

3 years ago

0.3.1

3 years ago

0.3.0-rc.1

3 years ago

0.2.0

3 years ago

0.0.30-rc.4

3 years ago

0.0.30-rc.3

3 years ago

0.0.30-rc.2

3 years ago

0.0.30-rc.1

3 years ago

0.0.36-rc.1

3 years ago

0.0.36-rc.2

3 years ago

0.0.37

3 years ago

0.0.38

3 years ago

0.0.39

3 years ago

0.0.30

3 years ago

0.0.31

3 years ago

0.0.32

3 years ago

0.0.38-rc.1

3 years ago

0.0.33

3 years ago

0.0.38-rc.2

3 years ago

0.0.34

3 years ago

0.0.35

3 years ago

0.0.36

3 years ago

0.0.40-rc.1

3 years ago

0.0.0

3 years ago

0.0.31-rc.1

3 years ago

0.0.37-rc.1

3 years ago

0.0.31-rc.8

3 years ago

0.0.31-rc.9

3 years ago

0.0.31-rc.6

3 years ago

0.0.31-rc.7

3 years ago

0.0.31-rc.4

3 years ago

0.0.31-rc.5

3 years ago

0.0.31-rc.2

3 years ago

0.0.31-rc.3

3 years ago

0.0.29-rc.4

3 years ago

0.0.29

3 years ago

0.0.29-rc.3

3 years ago

0.0.29-rc.2

3 years ago

0.0.29-rc.1

3 years ago

0.0.28

3 years ago

0.0.27

3 years ago

0.0.26

3 years ago

0.0.25

3 years ago

0.0.25-cjs.2

3 years ago

0.0.25-cjs.1

3 years ago

0.0.25-esm.2

3 years ago

0.0.25-esm.1

3 years ago

0.0.24

3 years ago

0.0.24-rc1

3 years ago

0.0.1

3 years ago