JSPM

  • Created
  • Published
  • Downloads 12020
  • Score
    100M100P100Q127694F
  • License MIT

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

Package Exports

  • stdout-update
  • stdout-update/lib/Terminal

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (stdout-update) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

stdout-update 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 '../lib/UpdateManager';

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

manager.hook();

console.log(' - log message');
console.error(' - error message');
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 message = messages[(j = Math.round(ticks / 10) % messages.length)];

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

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.