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 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 map(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 /** | |
144 * Create a wrapper Stream that intercepts some errors from this stream. | 137 * Create a wrapper Stream that intercepts some errors from this stream. |
145 * | 138 * |
146 * If this stream sends an error that matches [test], then it is intercepted | 139 * If this stream sends an error that matches [test], then it is intercepted |
147 * by the [handle] function. | 140 * by the [handle] function. |
148 * | 141 * |
149 * An [AsyncError] [:e:] is matched by a test function if [:test(e):] returns | 142 * An [AsyncError] [:e:] is matched by a test function if [:test(e):] returns |
150 * true. If [test] is omitted, every error is considered matching. | 143 * true. If [test] is omitted, every error is considered matching. |
151 * | 144 * |
152 * If the error is intercepted, the [handle] function can decide what to do | 145 * If the error is intercepted, the [handle] function can decide what to do |
153 * with it. It can throw if it wants to raise a new (or the same) error, | 146 * 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... |
1111 } | 1104 } |
1112 | 1105 |
1113 class _StreamOutputSinkWrapper<T> implements StreamSink<T> { | 1106 class _StreamOutputSinkWrapper<T> implements StreamSink<T> { |
1114 _StreamOutputSink _sink; | 1107 _StreamOutputSink _sink; |
1115 _StreamOutputSinkWrapper(this._sink); | 1108 _StreamOutputSinkWrapper(this._sink); |
1116 | 1109 |
1117 void add(T data) => _sink._sendData(data); | 1110 void add(T data) => _sink._sendData(data); |
1118 void signalError(AsyncError error) => _sink._sendError(error); | 1111 void signalError(AsyncError error) => _sink._sendError(error); |
1119 void close() => _sink._sendDone(); | 1112 void close() => _sink._sendDone(); |
1120 } | 1113 } |
OLD | NEW |