How to use stdout-update - 7 common examples

To help you get started, we’ve selected a few stdout-update examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github keindev / tasktree / src / theme.ts View on Github external
return errors.reduce((acc, text): string[] => {
            const [error, ...lines] = text.split(Terminal.EOL);
            const title = Theme.join(
                Wrapper.SPACE,
                this.symbol(IndicationType.Message),
                this.symbol(type),
                error.trim()
            );

            return acc.concat([
                Theme.indent(level + 1, this.paint(title, type)),
                ...lines.map((line): string => Theme.indent(sublevel, this.paint(line.trim(), IndicationType.Dim))),
            ]);
        }, []);
    }
github keindev / tasktree / src / progress-bar.ts View on Github external
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(
github keindev / tasktree / src / progress-bar.ts View on Github external
.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;
    }
}
github keindev / tasktree / src / theme.ts View on Github external
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);
    }
github keindev / tasktree / src / theme.ts View on Github external
public static indent(count: number, ...text: string[]): string {
        return `${Theme.INDENT.padStart(count * Indent.Default)}${Theme.join(Wrapper.SPACE, ...text)}`;
    }
github keindev / tasktree / src / progress-bar.ts View on Github external
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;
    }
}
github keindev / tasktree / src / tasktree.ts View on Github external
private constructor(theme?: ThemeOptions) {
        this.tasks = [];
        this.theme = new Theme(theme);
        this.manager = UpdateManager.getInstance();
    }

stdout-update

Updates the previous output in the terminal. Useful for correct rendering progress bars, animations, etc.

MIT
Latest version published 9 months ago

Package Health Score

66 / 100
Full package analysis