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
Module System
Min. Node Version
Typescript Support
Node Version
NPM Version
931 Stars
89 Commits
36 Forks
8 Watching
3 Branches
12 Contributors
Updated on 25 Nov 2024
Minified
Minified + Gzipped
TypeScript (62.42%)
JavaScript (37.18%)
Shell (0.4%)
Cumulative downloads
Total Downloads
Last day
-8.9%
5,453,667
Compared to previous day
Last week
2.1%
32,029,685
Compared to previous week
Last month
15.1%
129,537,743
Compared to previous month
Last year
35.9%
1,251,999,838
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.
MIT
💙 This package was templated with create-typescript-app.
No vulnerabilities found.
Reason
security policy file detected
Details
Reason
no dangerous workflow patterns detected
Reason
no binaries found in the repo
Reason
license file detected
Details
Reason
6 existing vulnerabilities detected
Details
Reason
Found 9/29 approved changesets -- score normalized to 3
Reason
0 commit(s) and 1 issue activity found in the last 90 days -- score normalized to 0
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
dependency not pinned by hash detected -- score normalized to 0
Details
Reason
detected GitHub workflow tokens with excessive permissions
Details
Reason
project is not fuzzed
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Score
Last Scanned on 2024-11-25
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