node-vk-sdk
Version:
VK API SDK for Node.js
34 lines (26 loc) • 742 B
text/typescript
import CodeLine from "./CodeLine";
export default class SourceCode {
private _lines: CodeLine[]
constructor(lines: CodeLine[] = []) {
this._lines = lines
}
public add(data: string, tab: number = 0) {
this._lines.push(new CodeLine(data, tab))
}
public append(code: SourceCode, tab: number = 0) {
code.tab(tab)
this._lines.push(...code.lines)
}
public render(): string {
return this._lines.map(line => line.data).join('\n')
}
public tab(n: number) {
this._lines.forEach(line => line.tab(n))
}
get lines(): CodeLine[] {
return this._lines
}
private genTab(n: number): string {
return new Array(n).join(' ')
}
}