DEV Community

Valeria
Valeria

Posted on

1

Day 20: Not a Dedent! 🚧

I tried to write a really funny joke about a dedent, but it just didn’t indent well πŸ₯ While my sense of humour is beyond fixing, extra identation can easily be stripped with dedent.

Let's install it e.g. with deno add npm:dedent, create a file, e.g. main.ts and try out:

import d from 'dedent'

console.log(d`
    What do you call a Christmas tree that’s lost its way?
        ...A mistletoe!
    `)
Enter fullscreen mode Exit fullscreen mode

Run with e.g. deno run -A ./main.ts and enjoy perfectly aligned lines:

deno run -A ./main.ts
#What do you call a Christmas tree that’s lost its way?
#    ...A mistletoe!
Enter fullscreen mode Exit fullscreen mode

Extra padding? Gone.
Bad taste and formatting: preservedπŸ‘Œ

Any ideas what dedent could help you with? Share in the comments!

Liked the content and would love to have more of it all year long?

Buy Me A Coffee

Heroku

Build apps, not infrastructure.

Dealing with servers, hardware, and infrastructure can take up your valuable time. Discover the benefits of Heroku, the PaaS of choice for developers since 2007.

Visit Site

Top comments (0)

A Workflow Copilot. Tailored to You.

Pieces.app image

Our desktop app, with its intelligent copilot, streamlines coding by generating snippets, extracting code from screenshots, and accelerating problem-solving.

Read the docs