
Security News
NVD Concedes Inability to Keep Pace with Surging CVE Disclosures in 2025
Security experts warn that recent classification changes obscure the true scope of the NVD backlog as CVE volume hits all-time highs.
The de-indent npm package is a utility for removing leading indentation from multiline strings. This can be particularly useful when dealing with template literals in JavaScript, where you want to maintain readability in your code without preserving the indentation in the resulting string.
Basic De-indentation
This feature removes the leading indentation from a multiline string, making it easier to work with template literals without preserving the indentation in the final string.
const deindent = require('de-indent');
const indentedString = `
function example() {
console.log('Hello, world!');
}
`;
const result = deindent(indentedString);
console.log(result);
De-indentation with Template Literals
This feature is useful for de-indenting HTML or XML strings defined using template literals, making the code more readable while ensuring the final string has no leading spaces.
const deindent = require('de-indent');
const indentedString = `
<div>
<p>Hello, world!</p>
</div>
`;
const result = deindent(indentedString);
console.log(result);
The strip-indent package is another utility for removing leading whitespace from multiline strings. It works similarly to de-indent but offers a slightly different API. Both packages achieve the same goal, but developers might prefer one over the other based on personal preference or specific use cases.
The dedent package is a popular alternative that not only removes leading indentation but also handles escaping of backticks and interpolation of variables within template literals. It offers more features compared to de-indent, making it a more versatile choice for complex string manipulations.
FAQs
remove extra indent from a block of code
The npm package de-indent receives a total of 3,775,531 weekly downloads. As such, de-indent popularity was classified as popular.
We found that de-indent demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
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.
Security News
Security experts warn that recent classification changes obscure the true scope of the NVD backlog as CVE volume hits all-time highs.
Security Fundamentals
Attackers use obfuscation to hide malware in open source packages. Learn how to spot these techniques across npm, PyPI, Maven, and more.
Security News
Join Socket for exclusive networking events, rooftop gatherings, and one-on-one meetings during BSidesSF and RSA 2025 in San Francisco.