File tree Expand file tree Collapse file tree 1 file changed +5
-7
lines changed Expand file tree Collapse file tree 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(
1919 let code = strings . reduce ( ( acc , cur ) => acc + values . shift ( ) + cur ) ;
2020 let lines = code . split ( "\n" ) ;
2121
22- let first = lines . shift ( ) ;
22+ const first = lines . shift ( ) ;
2323 if ( first === undefined || ! RE_BLANK . test ( first ) ) {
2424 throw new RangeError ( "Content must start on a new line." ) ;
2525 }
2626
27- let commonIndent = lines . pop ( ) ;
27+ const commonIndent = lines . pop ( ) ;
2828 if ( commonIndent === undefined || ! RE_BLANK . test ( commonIndent ) ) {
2929 throw new RangeError ( "Closing delimiter must appear on a new line." ) ;
3030 }
3131
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 ) ;
3434 if ( lineIndent . length === 0 ) {
3535 // Empty blank lines are preserved even if technically they are not
3636 // indented at all. This also short-circuits the dedentation logic when
@@ -43,7 +43,5 @@ export default function ftl(
4343 }
4444 // Strip commonIndent.
4545 return line . slice ( commonIndent . length ) ;
46- }
47-
48- return lines . map ( dedent ) . join ( "\n" ) ;
46+ } ) . join ( "\n" ) ;
4947}
You can’t perform that action at this time.
0 commit comments