1 | 'use strict';
|
2 |
|
3 | Object.defineProperty(exports, "__esModule", {
|
4 | value: true
|
5 | });
|
6 | exports.default = dedent;
|
7 |
|
8 |
|
9 |
|
10 |
|
11 |
|
12 |
|
13 |
|
14 |
|
15 |
|
16 |
|
17 |
|
18 |
|
19 | function fixIdent(str) {
|
20 | var indent = /^\n?( *)/.exec(str)[1];
|
21 | return str.replace(RegExp('^' + indent, 'mg'), '')
|
22 | .replace(/^\n*/m, '')
|
23 | .replace(/ *$/, '');
|
24 | }
|
25 |
|
26 |
|
27 |
|
28 |
|
29 |
|
30 |
|
31 |
|
32 |
|
33 |
|
34 |
|
35 |
|
36 |
|
37 |
|
38 | function dedent(strings) {
|
39 | var raw = typeof strings === 'string' ? [strings] : strings.raw;
|
40 | var res = '';
|
41 |
|
42 | for (var i = 0; i < raw.length; i++) {
|
43 | res += raw[i].replace(/\\`/g, '`');
|
44 |
|
45 | if (i < (arguments.length <= 1 ? 0 : arguments.length - 1)) {
|
46 | res += arguments.length <= i + 1 ? undefined : arguments[i + 1];
|
47 | }
|
48 | }
|
49 |
|
50 | return fixIdent(res);
|
51 | } |
\ | No newline at end of file |