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

Side by Side Diff: pkg/scheduled_test/test/descriptor/utils.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/http/lib/src/byte_stream.dart ('k') | runtime/bin/process_patch.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 library test.descriptor.utils; 5 library test.descriptor.utils;
6 6
7 import 'dart:async'; 7 import 'dart:async';
8 import 'dart:io'; 8 import 'dart:io';
9 9
10 import 'package:scheduled_test/descriptor.dart' as d; 10 import 'package:scheduled_test/descriptor.dart' as d;
(...skipping 14 matching lines...) Expand all
25 currentSchedule.onComplete.schedule(() { 25 currentSchedule.onComplete.schedule(() {
26 d.defaultRoot = null; 26 d.defaultRoot = null;
27 if (sandbox == null) return; 27 if (sandbox == null) return;
28 var oldSandbox = sandbox; 28 var oldSandbox = sandbox;
29 sandbox = null; 29 sandbox = null;
30 return new Directory(oldSandbox).delete(recursive: true); 30 return new Directory(oldSandbox).delete(recursive: true);
31 }); 31 });
32 } 32 }
33 33
34 Future<List<int>> byteStreamToList(Stream<List<int>> stream) { 34 Future<List<int>> byteStreamToList(Stream<List<int>> stream) {
35 return stream.reduce(<int>[], (buffer, chunk) { 35 return stream.fold(<int>[], (buffer, chunk) {
36 buffer.addAll(chunk); 36 buffer.addAll(chunk);
37 return buffer; 37 return buffer;
38 }); 38 });
39 } 39 }
40 40
41 Future<String> byteStreamToString(Stream<List<int>> stream) => 41 Future<String> byteStreamToString(Stream<List<int>> stream) =>
42 byteStreamToList(stream).then((bytes) => new String.fromCharCodes(bytes)); 42 byteStreamToList(stream).then((bytes) => new String.fromCharCodes(bytes));
43 43
OLDNEW
« no previous file with comments | « pkg/http/lib/src/byte_stream.dart ('k') | runtime/bin/process_patch.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698