shift-left
TypeScript icon, indicating that this package has built-in type declarations

0.1.5 • Public • Published

shift-left

Moves formatted multiline strings to the left without ruining your code's indentation.

Why does this exist?

Have you ever wanted to log a multi-line string? If so, you've probably seen code like this:

function printStuff() {
  console.log(`
This string is all the way to the left in my code file.

  and sometimes {
    it has {
      indentation
    }
  }

I'm doing this because I want it to start all the way to the left when it appears in the console.

But I sure wish it didn't mess with my code's indentation.
  `);
}

If you wish you could preserve your code's indentation without moving your ouput to the right, this library has an answer for you.

Usage

Example code:

import { shiftLeft } from "shift-left";

const recipient = "Bob Loblaw";

const message = shiftLeft`
  I have a lovely little {
    multiline message

    for you

        and you

            and also ${recipient}
  }
`;

console.log(message);

The code above produces the following output:

I have a lovely little {
  multiline message

  for you

      and you

          and also Bob Loblaw
}

Readme

Keywords

none

Package Sidebar

Install

npm i shift-left

Weekly Downloads

3,294

Version

0.1.5

License

ISC

Unpacked Size

4.33 kB

Total Files

9

Last publish

Collaborators

  • sslotsky