4.0.1 • Published 3 months ago

stdout-update v4.0.1

Weekly downloads
850
License
MIT
Repository
github
Last release
3 months ago

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

3 months ago

4.0.0

9 months ago

3.1.1

1 year ago

3.1.0

1 year ago

3.0.4

2 years ago

3.0.6

2 years ago

3.0.5

2 years ago

3.0.3

2 years ago

3.0.2

2 years ago

3.0.1

2 years ago

3.0.0

2 years ago

2.0.4

2 years ago

2.0.3

3 years ago

2.0.1

3 years ago

2.0.0

3 years ago

1.6.8

3 years ago

1.6.7

3 years ago

1.6.6

3 years ago

1.6.5

3 years ago

1.6.4

3 years ago

1.6.3

3 years ago

1.6.2

3 years ago

1.6.1

3 years ago

1.5.0

4 years ago

1.4.1

4 years ago

1.3.7

5 years ago

1.3.6

5 years ago

1.3.5

5 years ago

1.3.4

5 years ago

1.3.3

5 years ago

1.3.2

5 years ago

1.3.1

5 years ago

1.3.0

5 years ago

1.2.1

5 years ago

1.2.0

5 years ago

1.1.0

5 years ago

1.0.1

5 years ago

1.0.0

5 years ago