回答編集履歴

4

追記

2017/02/10 03:46

投稿

YOS_G-sepc
YOS_G-sepc

スコア29

test CHANGED
@@ -205,3 +205,39 @@
205
205
  g.next();
206
206
 
207
207
  ```
208
+
209
+
210
+
211
+ 追記:
212
+
213
+
214
+
215
+ ```js
216
+
217
+ > process.stdout
218
+
219
+ WriteStream {
220
+
221
+ ...,
222
+
223
+ columns: 80,
224
+
225
+ rows: 25,
226
+
227
+ ...,
228
+
229
+ destroy: [Function] }
230
+
231
+
232
+
233
+ > process.stdout.columns
234
+
235
+ 80
236
+
237
+ ```
238
+
239
+
240
+
241
+ process.stdoutを叩いてみたらその中にcolumns入ってました。
242
+
243
+ これで置換すればどのプラットフォームでも桁数を取得できるのではないでしょうか。

3

コード

2017/02/10 03:46

投稿

YOS_G-sepc
YOS_G-sepc

スコア29

test CHANGED
@@ -82,7 +82,7 @@
82
82
 
83
83
  const gauge=(">".repeat(widthNow)+" ".repeat(this.width-widthNow));
84
84
 
85
- const output=`#[${gauge}]#(${Math.floor(parcent*100)}%|${this.par}/${this.parMax})`;
85
+ const output=`#[${gauge}]#(${(parcent*100).toFixed(1)}%<-${this.par}/${this.parMax})`;
86
86
 
87
87
 
88
88
 
@@ -130,7 +130,7 @@
130
130
 
131
131
  gauge+="=".repeat(this.width-gauge.length)
132
132
 
133
- const output=`#[${gauge}]#(100%|${this.parMax}/${this.parMax})`;
133
+ const output=`#[${gauge}]#(100%<-${this.parMax}/${this.parMax})`;
134
134
 
135
135
 
136
136
 
@@ -162,9 +162,9 @@
162
162
 
163
163
 
164
164
 
165
- const width=60;
165
+ const width=55;
166
-
166
+
167
- const works=130;
167
+ const works=270;
168
168
 
169
169
  const prg=new Progress(width,works);
170
170
 
@@ -172,7 +172,7 @@
172
172
 
173
173
  for(let i=0;i<=works;i++){
174
174
 
175
- yield setTimeout(()=>g.next(),100);
175
+ yield setTimeout(()=>g.next(),90);
176
176
 
177
177
  if(i<40){
178
178
 

2

コード

2017/02/09 14:08

投稿

YOS_G-sepc
YOS_G-sepc

スコア29

test CHANGED
@@ -82,7 +82,7 @@
82
82
 
83
83
  const gauge=(">".repeat(widthNow)+" ".repeat(this.width-widthNow));
84
84
 
85
- const output=`#[${gauge}]#(${Math.floor(parcent*100)}%)`;
85
+ const output=`#[${gauge}]#(${Math.floor(parcent*100)}%|${this.par}/${this.parMax})`;
86
86
 
87
87
 
88
88
 
@@ -130,7 +130,7 @@
130
130
 
131
131
  gauge+="=".repeat(this.width-gauge.length)
132
132
 
133
- const output=`#[${gauge}]#(100%)`;
133
+ const output=`#[${gauge}]#(100%|${this.parMax}/${this.parMax})`;
134
134
 
135
135
 
136
136
 
@@ -164,7 +164,7 @@
164
164
 
165
165
  const width=60;
166
166
 
167
- const works=100;
167
+ const works=130;
168
168
 
169
169
  const prg=new Progress(width,works);
170
170
 
@@ -174,13 +174,13 @@
174
174
 
175
175
  yield setTimeout(()=>g.next(),100);
176
176
 
177
- if(i<30){
177
+ if(i<40){
178
178
 
179
179
  prg.view(firstMsg);
180
180
 
181
181
  }
182
182
 
183
- else if(i<70){
183
+ else if(i<90){
184
184
 
185
185
  prg.view(secondMsg);
186
186
 

1

コード

2017/02/09 13:55

投稿

YOS_G-sepc
YOS_G-sepc

スコア29

test CHANGED
@@ -28,6 +28,8 @@
28
28
 
29
29
  const readline=require("readline");
30
30
 
31
+ const exec=require("child_process").execSync;
32
+
31
33
  const rl=readline.createInterface(process.stdin,process.stdout);
32
34
 
33
35
 
@@ -38,15 +40,13 @@
38
40
 
39
41
  //最大の列数
40
42
 
41
- this.columns=require("child_process") //child_processの、
42
-
43
- .execSync("mode") //execSyncからmodeを呼び出して、
43
+ this.columns=exec("mode") //コマンドプロンプトからmodeを呼び出して、
44
-
44
+
45
- .toString() //文字列として取得して、
45
+ .toString() //文字列として取得して、
46
-
46
+
47
- .split(/\r\n/) //改行で分割し、
47
+ .split(/\r\n/) //改行で分割し、
48
-
48
+
49
- .filter(val=>{ //文字化けした" 桁数: "(=" ����: ")を検索して、
49
+ .filter(val=>{ //文字化けした" 桁数: "(=" ����: ")を検索して、
50
50
 
51
51
  if(val.replace(" ����: ","")!=val) return val;
52
52
 
@@ -204,6 +204,4 @@
204
204
 
205
205
  g.next();
206
206
 
207
-
208
-
209
207
  ```