0.4.2 • Published 1 year ago

@monteway/utils v0.4.2

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year 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

1 year ago

0.4.0-rc.1

1 year ago

0.3.2-rc.1

1 year ago

0.3.2

1 year ago

0.4.1-rc.1

1 year ago

0.4.1

1 year ago

0.4.0

1 year ago

0.4.2

1 year ago

0.2.0-rc.6

1 year ago

0.2.0-rc.3

1 year ago

0.2.0-rc.2

1 year ago

0.2.0-rc.5

1 year ago

0.2.0-rc.4

1 year ago

0.2.0-rc.1

1 year ago

0.0.40-rc.5

1 year ago

0.0.40-rc.4

1 year ago

0.0.40-rc.7

1 year ago

0.0.40-rc.6

1 year ago

0.0.40-rc.3

1 year ago

0.0.40-rc.2

1 year ago

0.1.0

1 year ago

0.3.0

1 year ago

0.0.40-rc.9

1 year ago

0.0.40-rc.8

1 year ago

0.3.1

1 year ago

0.3.0-rc.1

1 year ago

0.2.0

1 year ago

0.0.30-rc.4

2 years ago

0.0.30-rc.3

2 years ago

0.0.30-rc.2

2 years ago

0.0.30-rc.1

2 years ago

0.0.36-rc.1

2 years ago

0.0.36-rc.2

2 years ago

0.0.37

2 years ago

0.0.38

2 years ago

0.0.39

2 years ago

0.0.30

2 years ago

0.0.31

2 years ago

0.0.32

2 years ago

0.0.38-rc.1

2 years ago

0.0.33

2 years ago

0.0.38-rc.2

2 years ago

0.0.34

2 years ago

0.0.35

2 years ago

0.0.36

2 years ago

0.0.40-rc.1

2 years ago

0.0.0

2 years ago

0.0.31-rc.1

2 years ago

0.0.37-rc.1

2 years ago

0.0.31-rc.8

2 years ago

0.0.31-rc.9

2 years ago

0.0.31-rc.6

2 years ago

0.0.31-rc.7

2 years ago

0.0.31-rc.4

2 years ago

0.0.31-rc.5

2 years ago

0.0.31-rc.2

2 years ago

0.0.31-rc.3

2 years ago

0.0.29-rc.4

2 years ago

0.0.29

2 years ago

0.0.29-rc.3

2 years ago

0.0.29-rc.2

2 years ago

0.0.29-rc.1

2 years ago

0.0.28

2 years ago

0.0.27

2 years ago

0.0.26

2 years ago

0.0.25

2 years ago

0.0.25-cjs.2

2 years ago

0.0.25-cjs.1

2 years ago

0.0.25-esm.2

2 years ago

0.0.25-esm.1

2 years ago

0.0.24

2 years ago

0.0.24-rc1

2 years ago

0.0.1

2 years ago