Gathering detailed insights and metrics for string-dedent
Gathering detailed insights and metrics for string-dedent
Gathering detailed insights and metrics for string-dedent
Gathering detailed insights and metrics for string-dedent
dedent
A string tag that strips indentation from multi-line strings. ⬅️
ts-dedent
TypeScript package which smartly trims and strips indentation from multi-line strings
endent
➡️ An ES6 string tag that makes indentation right
@dword-design/dedent
An ES6 string tag that strips indentation from multi-line strings
npm install string-dedent
Typescript
Module System
Min. Node Version
Node Version
NPM Version
TypeScript (87.74%)
JavaScript (12.26%)
Total Downloads
0
Last Day
0
Last Week
0
Last Month
0
Last Year
0
11 Stars
65 Commits
1 Forks
3 Watchers
13 Branches
3 Contributors
Updated on Jun 28, 2025
Latest Version
3.0.2
Package Id
string-dedent@3.0.2
Unpacked Size
58.31 kB
Size
9.66 kB
File Count
8
NPM Version
10.2.3
Node Version
20.10.0
Published on
Jun 28, 2025
Cumulative downloads
Total Downloads
Last Day
0%
NaN
Compared to previous day
Last Week
0%
NaN
Compared to previous week
Last Month
0%
NaN
Compared to previous month
Last Year
0%
NaN
Compared to previous year
De-indents (dedents) passed in strings
Removes the leading whitespace from each line, allowing you to break the string into multiple lines with indentation. If lines have an uneven amount of indentation, then only the common whitespace is removed.
The opening and closing lines (which contain the `
marks) must be on their own line. The
opening line must be empty, and the closing line may contain whitespace. The opening and closing
line will be removed from the output, so that only the content in between remains.
1const dedent = require('string-dedent'); 2 3function example() { 4 console.log('Outputs:'); 5 console.log(dedent` 6 This line will appear without any indentation. 7 * This list will appear with 2 spaces more than previous line. 8 * As will this line. 9 10 Empty lines (like the one above) will not affect the common indentation. 11 `); 12} 13example();
1Outputs: 2This line will appear without any indentation. 3 * This list will appear with 2 spaces more than previous line. 4 * As will this line. 5 6Empty lines (like the one above) will not affect the common indentation.
1npm install string-dedent
The most common way to dedent is to use it as a tagged template literal. It supports expression interpolation, where the expressions will not affect the dedenting:
1const exp = 'expressions'; 2const threeSpaces = ' '; 3console.log('Outputs:'); 4console.log(dedent` 5 This supports ${exp} as you would expect. 6 7 Only whitespace that appears here inside the tagged template literal 8 will be dedented. 9 ${threeSpaces}<- expression whitespace will not be removed 10`); 11 12/* 13Outputs: 14This supports expressions as you would expect. 15 16Only whitespace that appears here inside the tagged template literal 17will be dedented. 18 <- expression whitespace will not be removed 19*/
If you need to use a tagged template literal like html
, you can wrap the tag with dedent
:
1// Regular html usage: 2const html = require('lit-html'); 3render(container, html` 4 <div>The leading whitespace before this div tag will create a Text node in the output...</div> 5`); 6 7// Wrapped html usage: 8const html = dedent(require('lit-html')); 9render(container, html` 10 <div>Leading whitespace before this div tag will not make it to HTML</div> 11`);
Additionally, you may also call it like a function. This allows you to interpolate expressions into your string, and have the full string dedented.
1const threeSpaces = ' '; 2const str = ` 3 Used as a function 4${threeSpaces}<- expression whitespace will be removed 5`; 6console.log('Outputs:'); 7console.log(dedent(str)); 8 9/* 10Outputs: 11Used as a function 12 <- expression whitespace will be removed 13*/
No vulnerabilities found.
Reason
no dangerous workflow patterns detected
Reason
no binaries found in the repo
Reason
4 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 3
Reason
Found 1/25 approved changesets -- score normalized to 0
Reason
detected GitHub workflow tokens with excessive permissions
Details
Reason
dependency not pinned by hash detected -- score normalized to 0
Details
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
Reason
project is not fuzzed
Details
Reason
license file not detected
Details
Reason
branch protection not enabled on development/release branches
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Reason
15 existing vulnerabilities detected
Details
Score
Last Scanned on 2025-07-07
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More