Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

dedent-js

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

dedent-js

Remove indentation from multiline strings

  • 1.0.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
155K
decreased by-17.14%
Maintainers
1
Weekly downloads
 
Created

What is dedent-js?

The dedent-js npm package is used to remove the common leading indentation from multi-line strings. This is particularly useful for maintaining readable code while working with template literals in JavaScript.

What are dedent-js's main functionalities?

Basic Dedentation

This feature allows you to remove the common leading whitespace from each line in a multi-line string, making it easier to maintain readable code.

const dedent = require('dedent-js');
const str = dedent(`
    This is a multi-line string.
    Each line will be dedented.
`);
console.log(str);

Dedentation with Variables

This feature demonstrates how dedent-js can be used with template literals that include variables, ensuring that the resulting string is properly formatted.

const dedent = require('dedent-js');
const name = 'John';
const str = dedent(`
    Hello, ${name}!
    Welcome to the dedent-js package.
`);
console.log(str);

Dedentation with Nested Templates

This feature shows how dedent-js handles nested template literals, ensuring that all levels of the template are properly dedented.

const dedent = require('dedent-js');
const inner = dedent(`
    This is an inner template.
    It will also be dedented.
`);
const outer = dedent(`
    This is an outer template.
    ${inner}
`);
console.log(outer);

Other packages similar to dedent-js

Keywords

FAQs

Package last updated on 19 Sep 2015

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc