| OLD | NEW |
| 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 part of dart.async; | 5 part of dart.async; |
| 6 | 6 |
| 7 // ------------------------------------------------------------------- | 7 // ------------------------------------------------------------------- |
| 8 // Core Stream types | 8 // Core Stream types |
| 9 // ------------------------------------------------------------------- | 9 // ------------------------------------------------------------------- |
| 10 | 10 |
| (...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 242 | 242 |
| 243 /** | 243 /** |
| 244 * Chains this stream as the input of the provided [StreamTransformer]. | 244 * Chains this stream as the input of the provided [StreamTransformer]. |
| 245 * | 245 * |
| 246 * Returns the result of [:streamTransformer.bind:] itself. | 246 * Returns the result of [:streamTransformer.bind:] itself. |
| 247 */ | 247 */ |
| 248 Stream transform(StreamTransformer<T, dynamic> streamTransformer) { | 248 Stream transform(StreamTransformer<T, dynamic> streamTransformer) { |
| 249 return streamTransformer.bind(this); | 249 return streamTransformer.bind(this); |
| 250 } | 250 } |
| 251 | 251 |
| 252 /** |
| 253 * Reduces a sequence of values by repeatedly applying [combine]. |
| 254 * |
| 255 * *WARNING UPCOMING API-CHANGE*: This method will be changed so that |
| 256 * it doesn't take an initial value. Use [fold] instead. |
| 257 */ |
| 258 Future reduce(var initialValue, combine(var previous, T element)) { |
| 259 return fold(initialValue, combine); |
| 260 } |
| 261 |
| 252 /** Reduces a sequence of values by repeatedly applying [combine]. */ | 262 /** Reduces a sequence of values by repeatedly applying [combine]. */ |
| 253 Future reduce(var initialValue, combine(var previous, T element)) { | 263 Future fold(var initialValue, combine(var previous, T element)) { |
| 254 _FutureImpl result = new _FutureImpl(); | 264 _FutureImpl result = new _FutureImpl(); |
| 255 var value = initialValue; | 265 var value = initialValue; |
| 256 StreamSubscription subscription; | 266 StreamSubscription subscription; |
| 257 subscription = this.listen( | 267 subscription = this.listen( |
| 258 // TODO(ahe): Restore type when feature is implemented in dart2js | 268 // TODO(ahe): Restore type when feature is implemented in dart2js |
| 259 // checked mode. http://dartbug.com/7733 | 269 // checked mode. http://dartbug.com/7733 |
| 260 (/*T*/ element) { | 270 (/*T*/ element) { |
| 261 _runUserCode( | 271 _runUserCode( |
| 262 () => combine(value, element), | 272 () => combine(value, element), |
| 263 (result) { value = result; }, | 273 (result) { value = result; }, |
| (...skipping 928 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1192 | 1202 |
| 1193 /* TODO(8997): Implement EventSink instead, */ | 1203 /* TODO(8997): Implement EventSink instead, */ |
| 1194 class _EventOutputSinkWrapper<T> extends StreamSink<T> { | 1204 class _EventOutputSinkWrapper<T> extends StreamSink<T> { |
| 1195 _EventOutputSink _sink; | 1205 _EventOutputSink _sink; |
| 1196 _EventOutputSinkWrapper(this._sink); | 1206 _EventOutputSinkWrapper(this._sink); |
| 1197 | 1207 |
| 1198 void add(T data) { _sink._sendData(data); } | 1208 void add(T data) { _sink._sendData(data); } |
| 1199 void addError(AsyncError error) { _sink._sendError(error); } | 1209 void addError(AsyncError error) { _sink._sendError(error); } |
| 1200 void close() { _sink._sendDone(); } | 1210 void close() { _sink._sendDone(); } |
| 1201 } | 1211 } |
| OLD | NEW |