stdout-update

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

MIT 38 个版本
安装
npm install stdout-update
yarn add stdout-update
pnpm add stdout-update
bun add stdout-update
README

Package logo

Build Status npm Standard Shared Config

Purely and accurately overwrites the previous output in the terminal, while maintaining the history of third-party logs.

Install

npm install stdout-update

Usage

import UpdateManager from 'stdout-update';

const TICKS = 60;
const TIMEOUT = 80;
const manager = UpdateManager.getInstance();
const frames = ['⠋', '⠙', '⠹', '⠸', '⠼', '⠴', '⠦', '⠧', '⠇', '⠏'];
const messages = ['Swapping time and space...', 'Have a good day.', "Don't panic...", 'Updating Updater...', '42'];
let ticks = TICKS;
let i = 0;

manager.hook();

// eslint-disable-next-line no-console
console.log(' - log message');
// eslint-disable-next-line no-console
console.error(' - error message');
// eslint-disable-next-line no-console
console.warn(' - warn message');

const id = setInterval(() => {
  if (--ticks < 0) {
    clearInterval(id);
    manager.update(['✔ Success', '', 'Messages:', 'this line is be deleted!!!']);
    manager.erase(1);
    manager.unhook(false);
  } else {
    const frame = frames[(i = ++i % frames.length)];
    const index = Math.round(ticks / 10) % messages.length;
    const message = messages[index];

    if (message) manager.update([`${frame} Some process...`, message]);
  }
}, TIMEOUT);

Examples

tasktree-cli - simple terminal task tree, helps you keep track of your tasks in a tree structure.

API

Read the API documentation for more information.

版本列表
4.0.1 2024-02-14
4.0.0 2023-08-19
3.1.1 2022-11-26
3.1.0 2022-11-24
3.0.6 2022-04-20
3.0.5 2022-04-04
3.0.4 2022-03-17
3.0.3 2022-02-17
3.0.2 2022-01-16
3.0.1 2022-01-03
3.0.0 2022-01-01
2.0.4 2021-11-25
2.0.3 2021-08-26
2.0.1 2021-05-06
2.0.0 2021-05-01
1.6.8 2021-05-06
1.6.7 2021-04-30
1.6.6 2021-04-30
1.6.5 2021-03-04
1.6.4 2021-03-03
1.6.3 2021-03-03
1.6.2 2021-03-03
1.6.1 2021-03-02
1.5.0 2020-06-08
1.4.1 2020-01-26
1.3.7 2019-09-03
1.3.6 2019-08-13
1.3.5 2019-08-08
1.3.4 2019-07-18
1.3.3 2019-06-24
1.3.2 2019-06-23
1.3.1 2019-06-23
1.3.0 2019-06-21
1.2.1 2019-06-20
1.2.0 2019-06-19
1.1.0 2019-06-10
1.0.1 2019-06-09
1.0.0 2019-06-09