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

Sentry blog image

How I fixed 20 seconds of lag for every user in just 20 minutes.

Our AI agent was running 10-20 seconds slower than it should, impacting both our own developers and our early adopters. See how I used Sentry Profiling to fix it in record time.

Read more

Top comments (0)

The Most Contextual AI Development Assistant

Pieces.app image

Our centralized storage agent works on-device, unifying various developer tools to proactively capture and enrich useful materials, streamline collaboration, and solve complex problems through a contextual understanding of your unique workflow.

πŸ‘₯ Ideal for solo developers, teams, and cross-company projects

Learn more

πŸ‘‹ Kindness is contagious

Please leave a ❀️ or a friendly comment on this post if you found it helpful!

Okay