Gathering detailed insights and metrics for dedent
Gathering detailed insights and metrics for dedent
Gathering detailed insights and metrics for dedent
Gathering detailed insights and metrics for dedent
⬅️ ES6 string tag that strips indentation from multi-line strings.
npm install dedent
Typescript
Module System
Node Version
NPM Version
TypeScript (64.32%)
JavaScript (35.3%)
Shell (0.38%)
Total Downloads
0
Last Day
0
Last Week
0
Last Month
0
Last Year
0
MIT License
1,036 Stars
92 Commits
38 Forks
8 Watchers
3 Branches
13 Contributors
Updated on Jul 09, 2025
Latest Version
1.6.0
Package Id
dedent@1.6.0
Unpacked Size
23.91 kB
Size
6.63 kB
File Count
8
NPM Version
10.9.0
Node Version
22.12.0
Published on
May 01, 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
1
42
A string tag that strips indentation from multi-line strings. ⬅️
1npm i dedent
1import dedent from "dedent"; 2 3function usageExample() { 4 const first = dedent`A string that gets so long you need to break it over 5 multiple lines. Luckily dedent is here to keep it 6 readable without lots of spaces ending up in the string 7 itself.`; 8 9 const second = dedent` 10 Leading and trailing lines will be trimmed, so you can write something like 11 this and have it work as you expect: 12 13 * how convenient it is 14 * that I can use an indented list 15 - and still have it do the right thing 16 17 That's all. 18 `; 19 20 const third = dedent(` 21 Wait! I lied. Dedent can also be used as a function. 22 `); 23 24 return first + "\n\n" + second + "\n\n" + third; 25} 26 27console.log(usageExample());
1A string that gets so long you need to break it over 2multiple lines. Luckily dedent is here to keep it 3readable without lots of spaces ending up in the string 4itself. 5 6Leading and trailing lines will be trimmed, so you can write something like 7this and have it work as you expect: 8 9 * how convenient it is 10 * that I can use an indented list 11 - and still have it do the right thing 12 13That's all. 14 15Wait! I lied. Dedent can also be used as a function.
You can customize the options dedent
runs with by calling its withOptions
method with an object:
1import dedent from 'dedent'; 2 3dedent.withOptions({ /* ... */ })`input`; 4dedent.withOptions({ /* ... */ })(`input`);
options
returns a new dedent
function, so if you'd like to reuse the same options, you can create a dedicated dedent
function:
1import dedent from 'dedent'; 2 3const dedenter = dedent.withOptions({ /* ... */ }); 4 5dedenter`input`; 6dedenter(`input`);
escapeSpecialCharacters
JavaScript string tags by default add an extra \
escape in front of some special characters such as $
dollar signs.
dedent
will escape those special characters when called as a string tag.
If you'd like to change the behavior, an escapeSpecialCharacters
option is available.
It defaults to:
false
: when dedent
is called as a functiontrue
: when dedent
is called as a string tag1import dedent from "dedent"; 2 3// "$hello!" 4dedent` 5 $hello! 6`; 7 8// "\$hello!" 9dedent.withOptions({ escapeSpecialCharacters: false })` 10 $hello! 11`; 12 13// "$hello!" 14dedent.withOptions({ escapeSpecialCharacters: true })` 15 $hello! 16`;
For more context, see 🚀 Feature: Add an option to disable special character escaping.
trimWhitespace
By default, dedent will trim leading and trailing whitespace from the overall string.
This can be disabled by setting trimWhitespace: false
.
1import dedent from "dedent"; 2 3// "hello!" 4dedent` 5 hello! 6`; 7 8// "\nhello! \n" 9dedent.withOptions({ trimWhitespace: false })` 10 hello! 11`; 12 13// "hello!" 14dedent.withOptions({ trimWhitespace: true })` 15 hello! 16`;
MIT
💙 This package was templated with create-typescript-app.
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
security policy file detected
Details
Reason
no dangerous workflow patterns detected
Reason
license file detected
Details
Reason
3 commit(s) and 3 issue activity found in the last 90 days -- score normalized to 5
Reason
Found 9/29 approved changesets -- score normalized to 3
Reason
dependency not pinned by hash detected -- score normalized to 0
Details
Reason
detected GitHub workflow tokens with excessive permissions
Details
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
project is not fuzzed
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Reason
11 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