Home
Docs
GitHub
Pricing
Blog
Log In

Run Sandworm Audit for your App

Get started
Generated on May 16, 2024 via pnpm

dedent 1.5.1

An ES6 string tag that strips indentation from multi-line strings
Package summary
Share
0
issues
1
license
1
MIT
Package created
13 Jan 2015
Version published
31 Jul 2023
Maintainers
2
Total deps
1
Direct deps
0
License
MIT

Issues

0
This package has no issues

Licenses

MIT License

Permissive
OSI Approved
This is a human-readable summary of (and not a substitute for) the license. Disclaimer.
Can
commercial-use
modify
distribute
sublicense
private-use
Cannot
hold-liable
Must
include-copyright
include-license
1 Packages, Including:
dedent@1.5.1
Disclaimer

This deed highlights only some of the key features and terms of the actual license. It is not a license and has no legal value. You should carefully review all of the terms and conditions of the actual license before using the licensed material.

Sandworm is not a law firm and does not provide legal services. Distributing, displaying, or linking to this deed or the license that it summarizes does not create a lawyer-client or any other relationship.

Direct Dependencies

0
All Dependencies CSV
β“˜ This is a list of dedent 's direct dependencies. Data on all dependencies, including transitive ones, is available via CSV download.
NameVersionSizeLicenseTypeVulnerabilities

Visualizations

Frequently Asked Questions

What does dedent do?

Dedent is an ES6 string tag utility that efficiently removes indentation from multi-line strings. It's an effective way to keep your code clean and readable, especially when dealing with long text strings that must break over several lines. Moreover, dedent also trims leading and trailing lines and properly handles indented lists, providing a smooth developer experience. It also allows usage as a function. Lastly, dedent supports special character escaping features, addressing the needs of projects of various complexities.

How do you use dedent?

A fundamental yet efficient way to use the dedent module involves importing it into your JavaScript file. After this, you can use it as a tagged template literal or as a function. Here are examples for both.

import dedent from "dedent";

function usageExample() {
  const first = dedent`A string that gets so long you need to break it over
                       multiple lines. Luckily dedent is here to keep it
                       readable without lots of spaces ending up in the string
                       itself.`;

  const second = dedent`
    Leading and trailing lines will be trimmed, so you can write something like
    this and have it work as you expect:

      * how convenient it is
      * that I can use an indented list
         - and still have it do the right thing

    That's all.
  `;

  const third = dedent(`
    Wait! I lied. Dedent can also be used as a function.
  `);

  return first + "\n\n" + second + "\n\n" + third;
}

console.log(usageExample());

If you want to customize dedent's function, you can use its withOptions method. Consider:

import dedent from 'dedent';

const dedenter = dedent.withOptions({ /* ... */ });

dedenter`input`;
dedenter(`input`);

Where are the dedent docs?

For comprehensive details on using the dedent module, the best source are the official project's docs, available on GitHub at https://github.com/dmnd/dedent. The documentation details numerous options and use cases with clear code examples, making it easier for developers to effectively use the module in their projects.