Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(93)

Side by Side Diff: runtime/bin/process_patch.dart

Issue 13548002: Add Iterable.fold (and Stream.fold) which replace `reduce`. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Address comments. Created 7 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « pkg/scheduled_test/test/descriptor/utils.dart ('k') | runtime/bin/vmstats/bargraph.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 patch class _WindowsCodePageDecoder { 5 patch class _WindowsCodePageDecoder {
6 /* patch */ static String _decodeBytes(List<int> bytes) 6 /* patch */ static String _decodeBytes(List<int> bytes)
7 native "SystemEncodingToString"; 7 native "SystemEncodingToString";
8 } 8 }
9 9
10 10
(...skipping 282 matching lines...) Expand 10 before | Expand all | Expand 10 after
293 } 293 }
294 294
295 // Start the underlying process. 295 // Start the underlying process.
296 return Process.start(path, arguments, options).then((Process p) { 296 return Process.start(path, arguments, options).then((Process p) {
297 // Make sure the process stdin is closed. 297 // Make sure the process stdin is closed.
298 p.stdin.close(); 298 p.stdin.close();
299 299
300 // Setup stdout handling. 300 // Setup stdout handling.
301 Future<StringBuffer> stdout = p.stdout 301 Future<StringBuffer> stdout = p.stdout
302 .transform(new StringDecoder(stdoutEncoding)) 302 .transform(new StringDecoder(stdoutEncoding))
303 .reduce( 303 .fold(
304 new StringBuffer(), 304 new StringBuffer(),
305 (buf, data) { 305 (buf, data) {
306 buf.write(data); 306 buf.write(data);
307 return buf; 307 return buf;
308 }); 308 });
309 309
310 Future<StringBuffer> stderr = p.stderr 310 Future<StringBuffer> stderr = p.stderr
311 .transform(new StringDecoder(stderrEncoding)) 311 .transform(new StringDecoder(stderrEncoding))
312 .reduce( 312 .fold(
313 new StringBuffer(), 313 new StringBuffer(),
314 (buf, data) { 314 (buf, data) {
315 buf.write(data); 315 buf.write(data);
316 return buf; 316 return buf;
317 }); 317 });
318 318
319 return Future.wait([p.exitCode, stdout, stderr]).then((result) { 319 return Future.wait([p.exitCode, stdout, stderr]).then((result) {
320 return new _ProcessResult(result[0], 320 return new _ProcessResult(result[0],
321 result[1].toString(), 321 result[1].toString(),
322 result[2].toString()); 322 result[2].toString());
323 }); 323 });
324 }); 324 });
325 } 325 }
326 326
327 327
328 class _ProcessResult implements ProcessResult { 328 class _ProcessResult implements ProcessResult {
329 const _ProcessResult(int this.exitCode, 329 const _ProcessResult(int this.exitCode,
330 String this.stdout, 330 String this.stdout,
331 String this.stderr); 331 String this.stderr);
332 332
333 final int exitCode; 333 final int exitCode;
334 final String stdout; 334 final String stdout;
335 final String stderr; 335 final String stderr;
336 } 336 }
OLDNEW
« no previous file with comments | « pkg/scheduled_test/test/descriptor/utils.dart ('k') | runtime/bin/vmstats/bargraph.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698