Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
public render(theme: Theme): string {
const length = Math.round(this.width * this.getRatio());
const type = Theme.type(this.status);
let blocks = Wrapper.EMPTY.padStart(length, this.completeBlock);
if (!this.isCompleted() && this.gradient) {
blocks = theme.gradient(blocks, {
position: this.getRatio(),
begin: Theme.type(this.status),
end: IndicationType.Success,
});
} else {
blocks = theme.paint(blocks, type);
}
let result = this.template
.replace(TemplateToken.Current, this.current.toString())
.replace(TemplateToken.Total, this.total.toString())
.replace(TemplateToken.Percent, `${this.getPercent().toFixed(ProgressBar.MIN_POINT_POSITION)}%`)
.replace(
.replace(TemplateToken.Current, this.current.toString())
.replace(TemplateToken.Total, this.total.toString())
.replace(TemplateToken.Percent, `${this.getPercent().toFixed(ProgressBar.MIN_POINT_POSITION)}%`)
.replace(
TemplateToken.ETA,
(this.getETA() / ProgressBar.TIME_DIMENSION).toFixed(ProgressBar.MAX_POINT_POSITION)
)
.replace(TemplateToken.Rate, Math.round(this.getRate()).toString())
.replace(
TemplateToken.Elapsed,
(this.getElapsed() / ProgressBar.TIME_DIMENSION).toFixed(ProgressBar.MAX_POINT_POSITION)
)
.replace(
TemplateToken.Bar,
Theme.join(
Wrapper.EMPTY,
blocks,
theme.paint(
Wrapper.EMPTY.padStart(this.width - length, this.incompleteBlock),
IndicationType.Subtask
)
)
);
this.tokens.forEach((value: string, key: string): void => {
result = result.replace(`:${key}`, value);
});
return this.badges ? Theme.join(Wrapper.SPACE, result, theme.badge(type)) : result;
}
}
public title(task: Task, level: number): string {
const type = Theme.type(task.getStatus(), task.haveSubtasks());
const badge = this.badge(type);
const symbol = this.symbol(type);
let prefix = Wrapper.EMPTY;
if (level)
prefix = task.haveSubtasks() ? this.symbol(IndicationType.Subtask) : this.symbol(IndicationType.Default);
return Theme.indent(level, prefix, symbol, task.getText(), badge);
}