SHARE
TWEET

Untitled

a guest Aug 12th, 2017 50 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. const readline = require('readline');
  2.  
  3. console.log('start');
  4.  
  5. Array.from(Array(100), (_, i) => i + 1).forEach(i => {
  6.     setTimeout(() => {
  7.         /*
  8.         // ※ メッセージの長さが減少する場合は使えない
  9.         process.stdout.write(`working... ${i}%\r`);
  10.         /*/
  11.         // child_process でも正常に動作させるには readlineを使う
  12.         readline.clearLine(process.stdout);
  13.         readline.cursorTo(process.stdout, 0);
  14.         process.stdout.write(`working... ${i}%`);
  15.         //*/
  16.     }, i * 30);
  17. });
RAW Paste Data
Top