File tree 1 file changed +5
-7
lines changed
1 file changed +5
-7
lines changed Original file line number Diff line number Diff line change @@ -19,18 +19,18 @@ export default function ftl(
19
19
let code = strings . reduce ( ( acc , cur ) => acc + values . shift ( ) + cur ) ;
20
20
let lines = code . split ( "\n" ) ;
21
21
22
- let first = lines . shift ( ) ;
22
+ const first = lines . shift ( ) ;
23
23
if ( first === undefined || ! RE_BLANK . test ( first ) ) {
24
24
throw new RangeError ( "Content must start on a new line." ) ;
25
25
}
26
26
27
- let commonIndent = lines . pop ( ) ;
27
+ const commonIndent = lines . pop ( ) ;
28
28
if ( commonIndent === undefined || ! RE_BLANK . test ( commonIndent ) ) {
29
29
throw new RangeError ( "Closing delimiter must appear on a new line." ) ;
30
30
}
31
31
32
- function dedent ( line : string , idx : number ) : string {
33
- let lineIndent = line . slice ( 0 , ( commonIndent as string ) . length ) ;
32
+ return lines . map ( ( line : string , idx : number ) : string => {
33
+ let lineIndent = line . slice ( 0 , commonIndent . length ) ;
34
34
if ( lineIndent . length === 0 ) {
35
35
// Empty blank lines are preserved even if technically they are not
36
36
// indented at all. This also short-circuits the dedentation logic when
@@ -43,7 +43,5 @@ export default function ftl(
43
43
}
44
44
// Strip commonIndent.
45
45
return line . slice ( commonIndent . length ) ;
46
- }
47
-
48
- return lines . map ( dedent ) . join ( "\n" ) ;
46
+ } ) . join ( "\n" ) ;
49
47
}
You can’t perform that action at this time.
0 commit comments