0.1.0 • Published 8 years ago

superman-progress v0.1.0

Weekly downloads
2
License
MIT
Repository
github
Last release
8 years ago

superman-progress

一个好玩的进度条。─=≡Σ((( つ•̀ω•́)つ

Install

$ npm install superman-progress --save

Usage

调用start方法启动进度条,调用end方法手动关闭
example

var Progress = require('superman-progress');
var progress = new Progress();

progress.start();
setTimeout(function() { 
    progress.end();   // end in 10 seconds
}, 10 * 1000);

手动设置setInterval并在其中调用render方法
example

var progress = new Progress({
    content:'loading ...  ─=≡Σ((( つ•̀ω•́)つ'
});

var timer = setInterval(function () {
  progress.render();
}, 100);

setTimeout(function() {
    clearInterval(timer);
    progress.clear();
}, 20 * 1000);

Options

Progress构造函数接受一个对象参数,有以下配置项

  • content:显示的进度条内容,默认是一个超人'─=≡Σ((( つ•̀ω•́)つ'
  • clean:结束的时候是否清空进度条。布尔值,默认清空。
  • stream:进度条输出流。默认是process.stderr
  • interval:渲染的时间间隔,默认100毫秒。
  • maxLength:可显示的最大长度。默认50个字符长度。

Methods

  • start:启动进度条,调用start方法的话必须通过end方法终止。
  • end:终止进度条。
  • render:渲染进度条,如果是手动设置定时器的话,在定时器中调用该方法。
  • clear:清空进度条。

Thanks

progress:https://github.com/visionmedia/node-progress
node-progress:https://github.com/mauriciogior/node-progress

License

MIT