OLD | NEW |
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 // Core Stream types | 8 // Core Stream types |
9 // ------------------------------------------------------------------- | 9 // ------------------------------------------------------------------- |
10 | 10 |
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
122 * but it only sends the data events that satisfy the [test]. | 122 * but it only sends the data events that satisfy the [test]. |
123 */ | 123 */ |
124 Stream<T> where(bool test(T event)) { | 124 Stream<T> where(bool test(T event)) { |
125 return new _WhereStream<T>(this, test); | 125 return new _WhereStream<T>(this, test); |
126 } | 126 } |
127 | 127 |
128 /** | 128 /** |
129 * Create a new stream that converts each element of this stream | 129 * Create a new stream that converts each element of this stream |
130 * to a new value using the [convert] function. | 130 * to a new value using the [convert] function. |
131 */ | 131 */ |
132 Stream mappedBy(convert(T event)) { | 132 Stream map(convert(T event)) { |
133 return new _MapStream<T, dynamic>(this, convert); | 133 return new _MapStream<T, dynamic>(this, convert); |
134 } | 134 } |
135 | 135 |
136 /** | 136 /** |
| 137 * Deprecated alias for [map]. |
| 138 * |
| 139 * @deprecated |
| 140 */ |
| 141 Stream mappedBy(f(T element)) => map(f); |
| 142 |
| 143 /** |
137 * Create a wrapper Stream that intercepts some errors from this stream. | 144 * Create a wrapper Stream that intercepts some errors from this stream. |
138 * | 145 * |
139 * If this stream sends an error that matches [test], then it is intercepted | 146 * If this stream sends an error that matches [test], then it is intercepted |
140 * by the [handle] function. | 147 * by the [handle] function. |
141 * | 148 * |
142 * An [AsyncError] [:e:] is matched by a test function if [:test(e):] returns | 149 * An [AsyncError] [:e:] is matched by a test function if [:test(e):] returns |
143 * true. If [test] is omitted, every error is considered matching. | 150 * true. If [test] is omitted, every error is considered matching. |
144 * | 151 * |
145 * If the error is intercepted, the [handle] function can decide what to do | 152 * If the error is intercepted, the [handle] function can decide what to do |
146 * with it. It can throw if it wants to raise a new (or the same) error, | 153 * with it. It can throw if it wants to raise a new (or the same) error, |
(...skipping 957 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1104 } | 1111 } |
1105 | 1112 |
1106 class _StreamOutputSinkWrapper<T> implements StreamSink<T> { | 1113 class _StreamOutputSinkWrapper<T> implements StreamSink<T> { |
1107 _StreamOutputSink _sink; | 1114 _StreamOutputSink _sink; |
1108 _StreamOutputSinkWrapper(this._sink); | 1115 _StreamOutputSinkWrapper(this._sink); |
1109 | 1116 |
1110 void add(T data) => _sink._sendData(data); | 1117 void add(T data) => _sink._sendData(data); |
1111 void signalError(AsyncError error) => _sink._sendError(error); | 1118 void signalError(AsyncError error) => _sink._sendError(error); |
1112 void close() => _sink._sendDone(); | 1119 void close() => _sink._sendDone(); |
1113 } | 1120 } |
OLD | NEW |