0.1.5 • Published 3 years ago

shift-left v0.1.5

Weekly downloads
-
License
ISC
Repository
-
Last release
3 years ago

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
}
0.1.5

3 years ago

0.1.2

3 years ago

0.1.1

3 years ago

0.1.4

3 years ago

0.1.3

3 years ago

0.1.0

3 years ago