use native repeat function

pull/4005/head
daszgfz 6 years ago
parent cea152fb59
commit 9614e66dfb

@ -1,5 +1,4 @@
import * as acorn from '../acorn';
import repeat from '../../utils/repeat';
import { Parser } from '../index';
import { Script } from '../../interfaces';
import { Node, Program } from 'estree';
@ -38,8 +37,7 @@ export default function read_script(parser: Parser, start: number, attributes: N
message: `<script> must have a closing tag`
});
const source =
repeat(' ', script_start) + parser.template.slice(script_start, script_end);
const source = ' '.repeat(script_start) + parser.template.slice(script_start, script_end);
parser.index = script_end + script_closing_tag.length;
let ast: Program;

@ -1,5 +1,3 @@
import repeat from './repeat';
function tabs_to_spaces(str: string) {
return str.replace(/^\t+/, match => match.split('\t').join(' '));
}
@ -25,8 +23,7 @@ export default function get_code_frame(
while (line_num.length < digits) line_num = ` ${line_num}`;
if (isErrorLine) {
const indicator =
repeat(' ', digits + 2 + tabs_to_spaces(str.slice(0, column)).length) + '^';
const indicator = ' '.repeat(digits + 2 + tabs_to_spaces(str.slice(0, column)).length) + '^';
return `${line_num}: ${tabs_to_spaces(str)}\n${indicator}`;
}

@ -1,5 +0,0 @@
export default function repeat(str: string, i: number) {
let result = '';
while (i--) result += str;
return result;
}
Loading…
Cancel
Save