Coder Social home page Coder Social logo

spread0x / log-update Goto Github PK

View Code? Open in Web Editor NEW

This project forked from sindresorhus/log-update

0.0 1.0 0.0 88 KB

Log by overwriting the previous output in the terminal. Useful for rendering progress bars, animations, etc.

License: MIT License

JavaScript 94.53% TypeScript 5.47%

log-update's Introduction

log-update

Log by overwriting the previous output in the terminal.
Useful for rendering progress bars, animations, etc.

Install

npm install log-update

Usage

import logUpdate from 'log-update';

const frames = ['-', '\\', '|', '/'];
let index = 0;

setInterval(() => {
	const frame = frames[index = ++index % frames.length];

	logUpdate(
`
        ♥♥
   ${frame} unicorns ${frame}
        ♥♥
`
	);
}, 80);

API

logUpdate(text…)

Log to stdout.

logUpdate.clear()

Clear the logged output.

logUpdate.done()

Persist the logged output.

Useful if you want to start a new log session below the current one.

logUpdateStderr(text…)

Log to stderr.

logUpdateStderr.clear()

logUpdateStderr.done()

createLogUpdate(stream, options?)

Get a logUpdate method that logs to the specified stream.

options

Type: object

showCursor

Type: boolean
Default: false

Show the cursor. This can be useful when a CLI accepts input from a user.

import logUpdate from 'log-update';

// Write output but don't hide the cursor
const log = logUpdate.create(process.stdout, {
	showCursor: true
});

Examples

  • listr - Uses this module to render an interactive task list
  • ora - Uses this module to render awesome spinners
  • speed-test - Uses this module to render a spinner

Get professional support for this package with a Tidelift subscription
Tidelift helps make open source sustainable for maintainers while giving companies
assurances about security, maintenance, and licensing for their dependencies.

log-update's People

Contributors

bendingbender avatar djmitche avatar etiktin avatar herecydev avatar imhoffd avatar jameskmonger avatar jamestalmage avatar kj800x avatar laurynaslubys avatar r4j4h avatar richienb avatar samverschueren avatar sapphi-red avatar sindresorhus avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.