UNPKG

2.43 kBMarkdownView Raw
1# TypeScript Dedent
2
3[![codecov](https://codecov.io/gh/tamino-martinius/node-ts-dedent/branch/master/graph/badge.svg)](https://codecov.io/gh/tamino-martinius/node-ts-dedent)
4
5TypeScript package which smartly trims and strips indentation from multi-line strings.
6
7## Usage Examples
8
9```js
10import dedent from 'dedent';
11
12console.log(dedent`A string that gets so long you need to break it over
13 multiple lines. Luckily dedent is here to keep it
14 readable without lots of spaces ending up in the string
15 itself.`);
16
17console.log(dedent`
18 A string that gets so long you need to break it over
19 multiple lines. Luckily dedent is here to keep it
20 readable without lots of spaces ending up in the string
21 itself.
22`);
23```
24
25```txt
26A string that gets so long you need to break it over
27multiple lines. Luckily dedent is here to keep it
28readable without lots of spaces ending up in the string
29itself.
30```
31
32---
33
34```js
35console.log(dedent`
36 Leading and trailing lines will be trimmed, so you can write something like
37 this and have it work as you expect:
38
39 * how convenient it is
40 * that I can use an indented list
41 - and still have it do the right thing
42
43 That's all.
44`);
45```
46
47```txt
48Leading and trailing lines will be trimmed, so you can write something like
49this and have it work as you expect:
50
51 * how convenient it is
52 * that I can use an indented list
53 - and still have it do the right thing
54
55That's all.
56```
57
58---
59
60```js
61console.log(dedent`
62 Also works fine
63
64 ${1}. With any kind of
65 ${2}. Placeholders
66`);
67```
68
69```txt
70Also works fine
71
721. With any kind of
732. Placeholders
74```
75
76---
77
78```js
79console.log(dedent(`
80 Wait! I lied. Dedent can also be used as a function.
81`);
82```
83
84```txt
85Wait! I lied. Dedent can also be used as a function.
86```
87
88## License
89
90MIT
91
92## Based on
93
94- [dedent](https://www.npmjs.com/package/dedent) by ~dmnd
95- [dedent-js](https://www.npmjs.com/package/dedent-js) by ~martin-kolarik
96
97## Changelog
98
99See [history](HISTORY.md) for more details.
100
101- `2.2.0` **2021-08-01** Add indentation to values with multiline strings & added ESM module
102- `2.1.1` **2021-03-31** Update dependencies
103- `2.1.0` **2021-03-24** Bugfixes
104- `2.0.0` **2020-09-28** Bugfixes
105- `1.2.0` **2020-09-28** Update dependencies and a couple of minor improvments
106- `1.1.0` **2019-07-26** Update dependencies and fixed links in readme
107- `1.0.0` **2018-06-14** Initial release