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

Side by Side Diff: pkg/http/lib/src/utils.dart

Issue 12374033: Remove the wrapStream workaround for issue 8310. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 9 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') | utils/pub/utils.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) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, 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 utils; 5 library utils;
6 6
7 import 'dart:async'; 7 import 'dart:async';
8 import 'dart:crypto'; 8 import 'dart:crypto';
9 import 'dart:io'; 9 import 'dart:io';
10 import 'dart:scalarlist'; 10 import 'dart:scalarlist';
(...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after
243 /// The return values of all [Future]s are discarded. Any errors will cause the 243 /// The return values of all [Future]s are discarded. Any errors will cause the
244 /// iteration to stop and will be piped through the return value. 244 /// iteration to stop and will be piped through the return value.
245 Future forEachFuture(Iterable input, Future fn(element)) { 245 Future forEachFuture(Iterable input, Future fn(element)) {
246 var iterator = input.iterator; 246 var iterator = input.iterator;
247 Future nextElement(_) { 247 Future nextElement(_) {
248 if (!iterator.moveNext()) return new Future.immediate(null); 248 if (!iterator.moveNext()) return new Future.immediate(null);
249 return fn(iterator.current).then(nextElement); 249 return fn(iterator.current).then(nextElement);
250 } 250 }
251 return nextElement(null); 251 return nextElement(null);
252 } 252 }
253
254 // TODO(nweiz): remove this when issue 8310 is fixed.
255 /// Returns a [Stream] identical to [stream], but piped through a new
256 /// [StreamController]. This exists to work around issue 8310.
257 Stream wrapStream(Stream stream) {
258 var controller = stream.isBroadcast
259 ? new StreamController.broadcast()
260 : new StreamController();
261 stream.listen(controller.add,
262 onError: (e) => controller.signalError(e),
263 onDone: controller.close);
264 return controller.stream;
265 }
OLDNEW
« no previous file with comments | « pkg/http/lib/src/byte_stream.dart ('k') | utils/pub/utils.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698