Socket
Socket
Sign inDemoInstall

stdout-update

Package Overview
Dependencies
7
Maintainers
1
Versions
38
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    stdout-update

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


Version published
Weekly downloads
2.4K
decreased by-28.78%
Maintainers
1
Created
Weekly downloads
 

Readme

Source

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.

Keywords

FAQs

Last updated on 14 Feb 2024

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc