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

Side by Side Diff: sdk/lib/async/stream_pipe.dart

Issue 14242008: Fix skipWhile. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: 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 | « no previous file | tests/lib/async/stream_controller_test.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 part of dart.async; 5 part of dart.async;
6 6
7 /** 7 /**
8 * Utility function to attach a stack trace to an [error] if it doesn't have 8 * Utility function to attach a stack trace to an [error] if it doesn't have
9 * one already. 9 * one already.
10 */ 10 */
(...skipping 396 matching lines...) Expand 10 before | Expand all | Expand 10 after
407 class _SkipWhileStream<T> extends _ForwardingStream<T, T> { 407 class _SkipWhileStream<T> extends _ForwardingStream<T, T> {
408 final _Predicate<T> _test; 408 final _Predicate<T> _test;
409 bool _hasFailed = false; 409 bool _hasFailed = false;
410 410
411 _SkipWhileStream(Stream<T> source, bool test(T value)) 411 _SkipWhileStream(Stream<T> source, bool test(T value))
412 : this._test = test, super(source); 412 : this._test = test, super(source);
413 413
414 void _handleData(T inputEvent, _EventOutputSink<T> sink) { 414 void _handleData(T inputEvent, _EventOutputSink<T> sink) {
415 if (_hasFailed) { 415 if (_hasFailed) {
416 sink._sendData(inputEvent); 416 sink._sendData(inputEvent);
417 return;
417 } 418 }
418 bool satisfies; 419 bool satisfies;
419 try { 420 try {
420 satisfies = _test(inputEvent); 421 satisfies = _test(inputEvent);
421 } catch (e, s) { 422 } catch (e, s) {
422 sink._sendError(_asyncError(e, s)); 423 sink._sendError(_asyncError(e, s));
423 // A failure to return a boolean is considered "not matching". 424 // A failure to return a boolean is considered "not matching".
424 _hasFailed = true; 425 _hasFailed = true;
425 return; 426 return;
426 } 427 }
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
521 522
522 void handleError(error, EventSink<T> sink) { 523 void handleError(error, EventSink<T> sink) {
523 _handleError(error, sink); 524 _handleError(error, sink);
524 } 525 }
525 526
526 void handleDone(EventSink<T> sink) { 527 void handleDone(EventSink<T> sink) {
527 _handleDone(sink); 528 _handleDone(sink);
528 } 529 }
529 } 530 }
530 531
OLDNEW
« no previous file with comments | « no previous file | tests/lib/async/stream_controller_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698