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

Side by Side Diff: test/dart_codegen/expect/async/stream.dart

Issue 963593002: Disable formatting and add new-lines to make tests faster. (Closed) Base URL: git@github.com:dart-lang/dev_compiler.git@master
Patch Set: Created 5 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
OLDNEW
1 part of dart.async; 1 part of dart.async;
2 2 abstract class Stream<T> {Stream();
3 abstract class Stream<T> { 3 factory Stream.fromFuture(Future<T> future) {
4 Stream(); 4 _StreamController<T> controller = ((__x35) => DDC$RT.cast(__x35, DDC$RT.type(( StreamController<T> _) {
5 factory Stream.fromFuture(Future<T> future) { 5 }
6 _StreamController<T> controller = ((__x35) => DDC$RT.cast(__x35, 6 ), DDC$RT.type((_StreamController<T> _) {
7 DDC$RT.type((StreamController<T> _) {}), 7 }
8 DDC$RT.type((_StreamController<T> _) {}), "CastExact", 8 ), "CastExact", """line 87, column 39 of dart:async/stream.dart: """, __x35 is _StreamController<T>, false))(new StreamController<T>(sync: true));
9 """line 87, column 39 of dart:async/stream.dart: """, 9 future.then((value) {
10 __x35 is _StreamController<T>, 10 controller._add(DDC$RT.cast(value, dynamic, T, "CastGeneral", """line 89, co lumn 25 of dart:async/stream.dart: """, value is T, false));
11 false))(new StreamController<T>(sync: true)); 11 controller._closeUnchecked();
12 future.then((value) { 12 }
13 controller._add(DDC$RT.cast(value, dynamic, T, "CastGeneral", 13 , onError: (error, stackTrace) {
14 """line 89, column 25 of dart:async/stream.dart: """, value is T, 14 controller._addError(error, DDC$RT.cast(stackTrace, dynamic, StackTrace, "Ca stGeneral", """line 93, column 37 of dart:async/stream.dart: """, stackTrace is StackTrace, true));
15 false)); 15 controller._closeUnchecked();
16 controller._closeUnchecked(); 16 }
17 }, onError: (error, stackTrace) { 17 );
18 controller._addError(error, DDC$RT.cast(stackTrace, dynamic, StackTrace, 18 return controller.stream;
19 "CastGeneral", """line 93, column 37 of dart:async/stream.dart: """, 19 }
20 stackTrace is StackTrace, true)); 20 factory Stream.fromIterable(Iterable<T> data) {
21 controller._closeUnchecked(); 21 return new _GeneratedStreamImpl<T>(() => new _IterablePendingEvents<T>(data));
22 }); 22 }
23 return controller.stream; 23 factory Stream.periodic(Duration period, [T computation(int computationCount)]) {
24 } 24 if (computation == null) computation = ((__x42) => DDC$RT.wrap((dynamic f(dyna mic __u37)) {
25 factory Stream.fromIterable(Iterable<T> data) { 25 dynamic c(dynamic x0) => ((__x36) => DDC$RT.cast(__x36, Null, T, "CastResult ", """line 126, column 44 of dart:async/stream.dart: """, __x36 is T, false))(f( x0));
26 return new _GeneratedStreamImpl<T>( 26 return f == null ? null : c;
27 () => new _IterablePendingEvents<T>(data)); 27 }
28 } 28 , __x42, __t40, DDC$RT.type((__t38<T> _) {
29 factory Stream.periodic(Duration period, 29 }
30 [T computation(int computationCount)]) { 30 ), "Wrap", """line 126, column 44 of dart:async/stream.dart: """, __x42 is __t 38<T>))(((i) => null));
31 if (computation == null) computation = ((__x42) => DDC$RT.wrap( 31 Timer timer;
32 (dynamic f(dynamic __u37)) { 32 int computationCount = 0;
33 dynamic c(dynamic x0) => ((__x36) => DDC$RT.cast(__x36, Null, T, 33 StreamController<T> controller;
34 "CastResult", """line 126, column 44 of dart:async/stream.dart: """, 34 Stopwatch watch = new Stopwatch();
35 __x36 is T, false))(f(x0)); 35 void sendEvent() {
36 return f == null ? null : c; 36 watch.reset();
37 }, __x42, __t40, DDC$RT.type((__t38<T> _) {}), "Wrap", 37 T data = computation(computationCount++);
38 """line 126, column 44 of dart:async/stream.dart: """, 38 controller.add(data);
39 __x42 is __t38<T>))(((i) => null)); 39 }
40 Timer timer; 40 void startPeriodicTimer() {
41 int computationCount = 0; 41 assert (timer == null); timer = new Timer.periodic(period, (Timer timer) {
42 StreamController<T> controller; 42 sendEvent();
43 Stopwatch watch = new Stopwatch(); 43 }
44 void sendEvent() { 44 );
45 watch.reset(); 45 }
46 T data = computation(computationCount++); 46 controller = new StreamController<T>(sync: true, onListen: () {
47 controller.add(data); 47 watch.start();
48 } 48 startPeriodicTimer();
49 void startPeriodicTimer() { 49 }
50 assert(timer == null); 50 , onPause: () {
51 timer = new Timer.periodic(period, (Timer timer) { 51 timer.cancel();
52 sendEvent(); 52 timer = null;
53 }); 53 watch.stop();
54 } 54 }
55 controller = new StreamController<T>(sync: true, onListen: () { 55 , onResume: () {
56 watch.start(); 56 assert (timer == null); Duration elapsed = watch.elapsed;
57 startPeriodicTimer(); 57 watch.start();
58 }, onPause: () { 58 timer = new Timer(period - elapsed, () {
59 timer.cancel();
60 timer = null; 59 timer = null;
61 watch.stop(); 60 startPeriodicTimer();
62 }, onResume: () { 61 sendEvent();
63 assert(timer == null); 62 }
64 Duration elapsed = watch.elapsed; 63 );
65 watch.start(); 64 }
66 timer = new Timer(period - elapsed, () { 65 , onCancel: () {
67 timer = null; 66 if (timer != null) timer.cancel();
68 startPeriodicTimer(); 67 timer = null;
69 sendEvent(); 68 }
70 }); 69 );
71 }, onCancel: () { 70 return controller.stream;
72 if (timer != null) timer.cancel(); 71 }
73 timer = null; 72 factory Stream.eventTransformed(Stream source, EventSink mapSink(EventSink<T> s ink)) {
74 }); 73 return ((__x43) => DDC$RT.cast(__x43, DDC$RT.type((_BoundSinkStream<dynamic, d ynamic> _) {
75 return controller.stream; 74 }
76 } 75 ), DDC$RT.type((Stream<T> _) {
77 factory Stream.eventTransformed( 76 }
78 Stream source, EventSink mapSink(EventSink<T> sink)) { 77 ), "CastExact", """line 216, column 12 of dart:async/stream.dart: """, __x43 i s Stream<T>, false))(new _BoundSinkStream(source, mapSink));
79 return ((__x43) => DDC$RT.cast(__x43, 78 }
80 DDC$RT.type((_BoundSinkStream<dynamic, dynamic> _) {}), 79 bool get isBroadcast => false;
81 DDC$RT.type((Stream<T> _) {}), "CastExact", 80 Stream<T> asBroadcastStream({
82 """line 216, column 12 of dart:async/stream.dart: """, 81 void onListen(StreamSubscription<T> subscription), void onCancel(StreamSubscri ption<T> subscription)}
83 __x43 is Stream<T>, false))(new _BoundSinkStream(source, mapSink)); 82 ) {
84 } 83 return new _AsBroadcastStream<T>(this, onListen, onCancel);
85 bool get isBroadcast => false; 84 }
86 Stream<T> asBroadcastStream( 85 StreamSubscription<T> listen(void onData(T event), {
87 {void onListen(StreamSubscription<T> subscription), 86 Function onError, void onDone(), bool cancelOnError}
88 void onCancel(StreamSubscription<T> subscription)}) { 87 );
89 return new _AsBroadcastStream<T>(this, onListen, onCancel); 88 Stream<T> where(bool test(T event)) {
90 } 89 return new _WhereStream<T>(this, test);
91 StreamSubscription<T> listen(void onData(T event), 90 }
92 {Function onError, void onDone(), bool cancelOnError}); 91 Stream map(convert(T event)) {
93 Stream<T> where(bool test(T event)) { 92 return new _MapStream<T, dynamic>(this, convert);
94 return new _WhereStream<T>(this, test); 93 }
95 } 94 Stream asyncMap(convert(T event)) {
96 Stream map(convert(T event)) { 95 StreamController controller;
97 return new _MapStream<T, dynamic>(this, convert); 96 StreamSubscription subscription;
98 } 97 void onListen() {
99 Stream asyncMap(convert(T event)) { 98 final add = controller.add;
100 StreamController controller; 99 assert (controller is _StreamController || controller is _BroadcastStreamCo ntroller); final eventSink = controller;
101 StreamSubscription subscription; 100 final addError = eventSink._addError;
102 void onListen() { 101 subscription = this.listen((T event) {
103 final add = controller.add; 102 var newValue;
104 assert(controller is _StreamController || 103 try {
105 controller is _BroadcastStreamController); 104 newValue = convert(event);
106 final eventSink = controller; 105 }
107 final addError = eventSink._addError; 106 catch (e, s) {
108 subscription = this.listen((T event) { 107 controller.addError(e, s);
109 var newValue; 108 return;}
110 try { 109 if (newValue is Future) {
111 newValue = convert(event);
112 } catch (e, s) {
113 controller.addError(e, s);
114 return;
115 }
116 if (newValue is Future) {
117 subscription.pause();
118 newValue
119 .then(add, onError: addError)
120 .whenComplete(subscription.resume);
121 } else {
122 controller.add(newValue);
123 }
124 },
125 onError: DDC$RT.cast(addError, dynamic, Function, "CastGeneral",
126 """line 338, column 20 of dart:async/stream.dart: """,
127 addError is Function, true),
128 onDone: controller.close);
129 }
130 if (this.isBroadcast) {
131 controller = new StreamController.broadcast(
132 onListen: onListen, onCancel: () {
133 subscription.cancel();
134 }, sync: true);
135 } else {
136 controller = new StreamController(onListen: onListen, onPause: () {
137 subscription.pause(); 110 subscription.pause();
138 }, onResume: () { 111 newValue.then(add, onError: addError).whenComplete(subscription.resume) ;
139 subscription.resume(); 112 }
140 }, onCancel: () { 113 else {
141 subscription.cancel(); 114 controller.add(newValue);
142 }, sync: true); 115 }
143 } 116 }
144 return controller.stream; 117 , onError: DDC$RT.cast(addError, dynamic, Function, "CastGeneral", """line 3 38, column 20 of dart:async/stream.dart: """, addError is Function, true), onDon e: controller.close);
145 } 118 }
146 Stream asyncExpand(Stream convert(T event)) { 119 if (this.isBroadcast) {
147 StreamController controller; 120 controller = new StreamController.broadcast(onListen: onListen, onCancel: () {
148 StreamSubscription subscription; 121 subscription.cancel();
149 void onListen() { 122 }
150 assert(controller is _StreamController || 123 , sync: true);
151 controller is _BroadcastStreamController); 124 }
152 final eventSink = controller; 125 else {
153 subscription = this.listen((T event) { 126 controller = new StreamController(onListen: onListen, onPause: () {
154 Stream newStream; 127 subscription.pause();
155 try { 128 }
156 newStream = convert(event); 129 , onResume: () {
157 } catch (e, s) { 130 subscription.resume();
158 controller.addError(e, s); 131 }
159 return; 132 , onCancel: () {
160 } 133 subscription.cancel();
161 if (newStream != null) { 134 }
162 subscription.pause(); 135 , sync: true);
163 controller.addStream(newStream).whenComplete(subscription.resume); 136 }
164 } 137 return controller.stream;
165 }, 138 }
166 onError: DDC$RT.cast(eventSink._addError, dynamic, Function, 139 Stream asyncExpand(Stream convert(T event)) {
167 "CastGeneral", 140 StreamController controller;
168 """line 395, column 20 of dart:async/stream.dart: """, 141 StreamSubscription subscription;
169 eventSink._addError is Function, true), 142 void onListen() {
170 onDone: controller.close); 143 assert (controller is _StreamController || controller is _BroadcastStreamCon troller); final eventSink = controller;
171 } 144 subscription = this.listen((T event) {
172 if (this.isBroadcast) { 145 Stream newStream;
173 controller = new StreamController.broadcast( 146 try {
174 onListen: onListen, onCancel: () { 147 newStream = convert(event);
175 subscription.cancel(); 148 }
176 }, sync: true); 149 catch (e, s) {
177 } else { 150 controller.addError(e, s);
178 controller = new StreamController(onListen: onListen, onPause: () { 151 return;}
152 if (newStream != null) {
179 subscription.pause(); 153 subscription.pause();
180 }, onResume: () { 154 controller.addStream(newStream).whenComplete(subscription.resume);
181 subscription.resume(); 155 }
182 }, onCancel: () { 156 }
183 subscription.cancel(); 157 , onError: DDC$RT.cast(eventSink._addError, dynamic, Function, "CastGeneral" , """line 395, column 20 of dart:async/stream.dart: """, eventSink._addError is Function, true), onDone: controller.close);
184 }, sync: true); 158 }
185 } 159 if (this.isBroadcast) {
186 return controller.stream; 160 controller = new StreamController.broadcast(onListen: onListen, onCancel: () {
187 } 161 subscription.cancel();
188 Stream<T> handleError(Function onError, {bool test(error)}) { 162 }
189 return new _HandleErrorStream<T>(this, onError, test); 163 , sync: true);
190 } 164 }
191 Stream expand(Iterable convert(T value)) { 165 else {
192 return new _ExpandStream<T, dynamic>(this, convert); 166 controller = new StreamController(onListen: onListen, onPause: () {
193 } 167 subscription.pause();
194 Future pipe(StreamConsumer<T> streamConsumer) { 168 }
195 return streamConsumer.addStream(this).then((_) => streamConsumer.close()); 169 , onResume: () {
196 } 170 subscription.resume();
197 Stream transform(StreamTransformer<T, dynamic> streamTransformer) { 171 }
198 return streamTransformer.bind(this); 172 , onCancel: () {
199 } 173 subscription.cancel();
200 Future<T> reduce(T combine(T previous, T element)) { 174 }
201 _Future<T> result = new _Future<T>(); 175 , sync: true);
202 bool seenFirst = false; 176 }
203 T value; 177 return controller.stream;
204 StreamSubscription subscription; 178 }
205 subscription = this.listen((T element) { 179 Stream<T> handleError(Function onError, {
206 if (seenFirst) { 180 bool test(error)}
207 _runUserCode(() => combine(value, element), ((__x49) => DDC$RT.wrap( 181 ) {
208 (dynamic f(T __u44)) { 182 return new _HandleErrorStream<T>(this, onError, test);
209 dynamic c(T x0) => f(DDC$RT.cast(x0, dynamic, T, "CastParam", 183 }
210 """line 500, column 24 of dart:async/stream.dart: """, x0 is T, 184 Stream expand(Iterable convert(T value)) {
211 false)); 185 return new _ExpandStream<T, dynamic>(this, convert);
212 return f == null ? null : c; 186 }
213 }, __x49, DDC$RT.type((__t47<T> _) {}), __t45, "WrapLiteral", 187 Future pipe(StreamConsumer<T> streamConsumer) {
214 """line 500, column 24 of dart:async/stream.dart: """, 188 return streamConsumer.addStream(this).then((_) => streamConsumer.close());
215 __x49 is __t45))((T newValue) { 189 }
216 value = newValue; 190 Stream transform(StreamTransformer<T, dynamic> streamTransformer) {
217 }), ((__x53) => DDC$RT.cast(__x53, dynamic, __t50, "CastGeneral", 191 return streamTransformer.bind(this);
218 """line 501, column 24 of dart:async/stream.dart: """, 192 }
219 __x53 is __t50, 193 Future<T> reduce(T combine(T previous, T element)) {
220 false))(_cancelAndErrorClosure(subscription, result))); 194 _Future<T> result = new _Future<T>();
221 } else { 195 bool seenFirst = false;
222 value = element; 196 T value;
223 seenFirst = true; 197 StreamSubscription subscription;
224 } 198 subscription = this.listen((T element) {
225 }, onError: result._completeError, onDone: () { 199 if (seenFirst) {
226 if (!seenFirst) { 200 _runUserCode(() => combine(value, element), ((__x49) => DDC$RT.wrap((dynam ic f(T __u44)) {
227 try { 201 dynamic c(T x0) => f(DDC$RT.cast(x0, dynamic, T, "CastParam", """line 50 0, column 24 of dart:async/stream.dart: """, x0 is T, false));
228 throw IterableElementError.noElement(); 202 return f == null ? null : c;
229 } catch (e, s) { 203 }
230 _completeWithErrorCallback(result, e, s); 204 , __x49, DDC$RT.type((__t47<T> _) {
231 } 205 }
232 } else { 206 ), __t45, "WrapLiteral", """line 500, column 24 of dart:async/stream.dart: """, __x49 is __t45))((T newValue) {
233 result._complete(value);
234 }
235 }, cancelOnError: true);
236 return result;
237 }
238 Future fold(var initialValue, combine(var previous, T element)) {
239 _Future result = new _Future();
240 var value = initialValue;
241 StreamSubscription subscription;
242 subscription = this.listen((T element) {
243 _runUserCode(() => combine(value, element), (newValue) {
244 value = newValue; 207 value = newValue;
245 }, ((__x54) => DDC$RT.cast(__x54, dynamic, __t50, "CastGeneral", 208 }
246 """line 534, column 11 of dart:async/stream.dart: """, __x54 is __t50, 209 ), ((__x53) => DDC$RT.cast(__x53, dynamic, __t50, "CastGeneral", """line 5 01, column 24 of dart:async/stream.dart: """, __x53 is __t50, false))(_cancelAnd ErrorClosure(subscription, result)));
247 false))(_cancelAndErrorClosure(subscription, result))); 210 }
248 }, onError: (e, st) { 211 else {
249 result._completeError(e, DDC$RT.cast(st, dynamic, StackTrace, 212 value = element;
250 "CastGeneral", """line 538, column 34 of dart:async/stream.dart: """, 213 seenFirst = true;
251 st is StackTrace, true)); 214 }
252 }, onDone: () { 215 }
253 result._complete(value); 216 , onError: result._completeError, onDone: () {
254 }, cancelOnError: true); 217 if (!seenFirst) {
255 return result;
256 }
257 Future<String> join([String separator = ""]) {
258 _Future<String> result = new _Future<String>();
259 StringBuffer buffer = new StringBuffer();
260 StreamSubscription subscription;
261 bool first = true;
262 subscription = this.listen((T element) {
263 if (!first) {
264 buffer.write(separator);
265 }
266 first = false;
267 try {
268 buffer.write(element);
269 } catch (e, s) {
270 _cancelAndErrorWithReplacement(subscription, result, e, s);
271 }
272 }, onError: (e) {
273 result._completeError(e);
274 }, onDone: () {
275 result._complete(buffer.toString());
276 }, cancelOnError: true);
277 return result;
278 }
279 Future<bool> contains(Object needle) {
280 _Future<bool> future = new _Future<bool>();
281 StreamSubscription subscription;
282 subscription = this.listen((T element) {
283 _runUserCode(() => (element == needle), ((__x58) => DDC$RT.wrap(
284 (dynamic f(bool __u55)) {
285 dynamic c(bool x0) => f(DDC$RT.cast(x0, dynamic, bool, "CastParam",
286 """line 597, column 13 of dart:async/stream.dart: """, x0 is bool,
287 true));
288 return f == null ? null : c;
289 }, __x58, __t56, __t45, "WrapLiteral",
290 """line 597, column 13 of dart:async/stream.dart: """,
291 __x58 is __t45))((bool isMatch) {
292 if (isMatch) {
293 _cancelAndValue(subscription, future, true);
294 }
295 }), ((__x59) => DDC$RT.cast(__x59, dynamic, __t50, "CastGeneral",
296 """line 602, column 13 of dart:async/stream.dart: """, __x59 is __t50,
297 false))(_cancelAndErrorClosure(subscription, future)));
298 }, onError: future._completeError, onDone: () {
299 future._complete(false);
300 }, cancelOnError: true);
301 return future;
302 }
303 Future forEach(void action(T element)) {
304 _Future future = new _Future();
305 StreamSubscription subscription;
306 subscription = this.listen((T element) {
307 _runUserCode(() => action(element), (_) {}, ((__x60) => DDC$RT.cast(__x60,
308 dynamic, __t50, "CastGeneral",
309 """line 628, column 13 of dart:async/stream.dart: """, __x60 is __t50,
310 false))(_cancelAndErrorClosure(subscription, future)));
311 }, onError: future._completeError, onDone: () {
312 future._complete(null);
313 }, cancelOnError: true);
314 return future;
315 }
316 Future<bool> every(bool test(T element)) {
317 _Future<bool> future = new _Future<bool>();
318 StreamSubscription subscription;
319 subscription = this.listen((T element) {
320 _runUserCode(() => test(element), ((__x62) => DDC$RT.wrap(
321 (dynamic f(bool __u61)) {
322 dynamic c(bool x0) => f(DDC$RT.cast(x0, dynamic, bool, "CastParam",
323 """line 652, column 13 of dart:async/stream.dart: """, x0 is bool,
324 true));
325 return f == null ? null : c;
326 }, __x62, __t56, __t45, "WrapLiteral",
327 """line 652, column 13 of dart:async/stream.dart: """,
328 __x62 is __t45))((bool isMatch) {
329 if (!isMatch) {
330 _cancelAndValue(subscription, future, false);
331 }
332 }), ((__x63) => DDC$RT.cast(__x63, dynamic, __t50, "CastGeneral",
333 """line 657, column 13 of dart:async/stream.dart: """, __x63 is __t50,
334 false))(_cancelAndErrorClosure(subscription, future)));
335 }, onError: future._completeError, onDone: () {
336 future._complete(true);
337 }, cancelOnError: true);
338 return future;
339 }
340 Future<bool> any(bool test(T element)) {
341 _Future<bool> future = new _Future<bool>();
342 StreamSubscription subscription;
343 subscription = this.listen((T element) {
344 _runUserCode(() => test(element), ((__x65) => DDC$RT.wrap(
345 (dynamic f(bool __u64)) {
346 dynamic c(bool x0) => f(DDC$RT.cast(x0, dynamic, bool, "CastParam",
347 """line 689, column 13 of dart:async/stream.dart: """, x0 is bool,
348 true));
349 return f == null ? null : c;
350 }, __x65, __t56, __t45, "WrapLiteral",
351 """line 689, column 13 of dart:async/stream.dart: """,
352 __x65 is __t45))((bool isMatch) {
353 if (isMatch) {
354 _cancelAndValue(subscription, future, true);
355 }
356 }), ((__x66) => DDC$RT.cast(__x66, dynamic, __t50, "CastGeneral",
357 """line 694, column 13 of dart:async/stream.dart: """, __x66 is __t50,
358 false))(_cancelAndErrorClosure(subscription, future)));
359 }, onError: future._completeError, onDone: () {
360 future._complete(false);
361 }, cancelOnError: true);
362 return future;
363 }
364 Future<int> get length {
365 _Future<int> future = new _Future<int>();
366 int count = 0;
367 this.listen((_) {
368 count++;
369 }, onError: future._completeError, onDone: () {
370 future._complete(count);
371 }, cancelOnError: true);
372 return future;
373 }
374 Future<bool> get isEmpty {
375 _Future<bool> future = new _Future<bool>();
376 StreamSubscription subscription;
377 subscription = this.listen((_) {
378 _cancelAndValue(subscription, future, false);
379 }, onError: future._completeError, onDone: () {
380 future._complete(true);
381 }, cancelOnError: true);
382 return future;
383 }
384 Future<List<T>> toList() {
385 List<T> result = <T>[];
386 _Future<List<T>> future = new _Future<List<T>>();
387 this.listen((T data) {
388 result.add(data);
389 }, onError: future._completeError, onDone: () {
390 future._complete(result);
391 }, cancelOnError: true);
392 return future;
393 }
394 Future<Set<T>> toSet() {
395 Set<T> result = new Set<T>();
396 _Future<Set<T>> future = new _Future<Set<T>>();
397 this.listen((T data) {
398 result.add(data);
399 }, onError: future._completeError, onDone: () {
400 future._complete(result);
401 }, cancelOnError: true);
402 return future;
403 }
404 Future drain([var futureValue]) =>
405 listen(null, cancelOnError: true).asFuture(futureValue);
406 Stream<T> take(int count) {
407 return ((__x67) => DDC$RT.cast(__x67,
408 DDC$RT.type((_TakeStream<dynamic> _) {}), DDC$RT.type((Stream<T> _) {}),
409 "CastExact", """line 819, column 12 of dart:async/stream.dart: """,
410 __x67 is Stream<T>, false))(new _TakeStream(this, count));
411 }
412 Stream<T> takeWhile(bool test(T element)) {
413 return ((__x68) => DDC$RT.cast(__x68,
414 DDC$RT.type((_TakeWhileStream<dynamic> _) {}),
415 DDC$RT.type((Stream<T> _) {}), "CastExact",
416 """line 841, column 12 of dart:async/stream.dart: """,
417 __x68 is Stream<T>, false))(new _TakeWhileStream(this, test));
418 }
419 Stream<T> skip(int count) {
420 return ((__x69) => DDC$RT.cast(__x69,
421 DDC$RT.type((_SkipStream<dynamic> _) {}), DDC$RT.type((Stream<T> _) {}),
422 "CastExact", """line 852, column 12 of dart:async/stream.dart: """,
423 __x69 is Stream<T>, false))(new _SkipStream(this, count));
424 }
425 Stream<T> skipWhile(bool test(T element)) {
426 return ((__x70) => DDC$RT.cast(__x70,
427 DDC$RT.type((_SkipWhileStream<dynamic> _) {}),
428 DDC$RT.type((Stream<T> _) {}), "CastExact",
429 """line 868, column 12 of dart:async/stream.dart: """,
430 __x70 is Stream<T>, false))(new _SkipWhileStream(this, test));
431 }
432 Stream<T> distinct([bool equals(T previous, T next)]) {
433 return ((__x71) => DDC$RT.cast(__x71,
434 DDC$RT.type((_DistinctStream<dynamic> _) {}),
435 DDC$RT.type((Stream<T> _) {}), "CastExact",
436 """line 885, column 12 of dart:async/stream.dart: """,
437 __x71 is Stream<T>, false))(new _DistinctStream(this, equals));
438 }
439 Future<T> get first {
440 _Future<T> future = new _Future<T>();
441 StreamSubscription subscription;
442 subscription = this.listen((T value) {
443 _cancelAndValue(subscription, future, value);
444 }, onError: future._completeError, onDone: () {
445 try { 218 try {
446 throw IterableElementError.noElement(); 219 throw IterableElementError.noElement();
447 } catch (e, s) { 220 }
448 _completeWithErrorCallback(future, e, s); 221 catch (e, s) {
449 } 222 _completeWithErrorCallback(result, e, s);
450 }, cancelOnError: true); 223 }
451 return future; 224 }
452 } 225 else {
453 Future<T> get last { 226 result._complete(value);
454 _Future<T> future = new _Future<T>(); 227 }
455 T result = ((__x72) => DDC$RT.cast(__x72, Null, T, "CastLiteral", 228 }
456 """line 936, column 16 of dart:async/stream.dart: """, __x72 is T, 229 , cancelOnError: true);
457 false))(null); 230 return result;
458 bool foundResult = false; 231 }
459 StreamSubscription subscription; 232 Future fold(var initialValue, combine(var previous, T element)) {
460 subscription = this.listen((T value) { 233 _Future result = new _Future();
461 foundResult = true; 234 var value = initialValue;
462 result = value; 235 StreamSubscription subscription;
463 }, onError: future._completeError, onDone: () { 236 subscription = this.listen((T element) {
464 if (foundResult) { 237 _runUserCode(() => combine(value, element), (newValue) {
465 future._complete(result); 238 value = newValue;
466 return; 239 }
467 } 240 , ((__x54) => DDC$RT.cast(__x54, dynamic, __t50, "CastGeneral", """line 534, column 11 of dart:async/stream.dart: """, __x54 is __t50, false))(_cancelAndErr orClosure(subscription, result)));
241 }
242 , onError: (e, st) {
243 result._completeError(e, DDC$RT.cast(st, dynamic, StackTrace, "CastGeneral", """line 538, column 34 of dart:async/stream.dart: """, st is StackTrace, true)) ;
244 }
245 , onDone: () {
246 result._complete(value);
247 }
248 , cancelOnError: true);
249 return result;
250 }
251 Future<String> join([String separator = ""]) {
252 _Future<String> result = new _Future<String>();
253 StringBuffer buffer = new StringBuffer();
254 StreamSubscription subscription;
255 bool first = true;
256 subscription = this.listen((T element) {
257 if (!first) {
258 buffer.write(separator);
259 }
260 first = false;
261 try {
262 buffer.write(element);
263 }
264 catch (e, s) {
265 _cancelAndErrorWithReplacement(subscription, result, e, s);
266 }
267 }
268 , onError: (e) {
269 result._completeError(e);
270 }
271 , onDone: () {
272 result._complete(buffer.toString());
273 }
274 , cancelOnError: true);
275 return result;
276 }
277 Future<bool> contains(Object needle) {
278 _Future<bool> future = new _Future<bool>();
279 StreamSubscription subscription;
280 subscription = this.listen((T element) {
281 _runUserCode(() => (element == needle), ((__x58) => DDC$RT.wrap((dynamic f(b ool __u55)) {
282 dynamic c(bool x0) => f(DDC$RT.cast(x0, dynamic, bool, "CastParam", """lin e 597, column 13 of dart:async/stream.dart: """, x0 is bool, true));
283 return f == null ? null : c;
284 }
285 , __x58, __t56, __t45, "WrapLiteral", """line 597, column 13 of dart:async/s tream.dart: """, __x58 is __t45))((bool isMatch) {
286 if (isMatch) {
287 _cancelAndValue(subscription, future, true);
288 }
289 }
290 ), ((__x59) => DDC$RT.cast(__x59, dynamic, __t50, "CastGeneral", """line 602 , column 13 of dart:async/stream.dart: """, __x59 is __t50, false))(_cancelAndEr rorClosure(subscription, future)));
291 }
292 , onError: future._completeError, onDone: () {
293 future._complete(false);
294 }
295 , cancelOnError: true);
296 return future;
297 }
298 Future forEach(void action(T element)) {
299 _Future future = new _Future();
300 StreamSubscription subscription;
301 subscription = this.listen((T element) {
302 _runUserCode(() => action(element), (_) {
303 }
304 , ((__x60) => DDC$RT.cast(__x60, dynamic, __t50, "CastGeneral", """line 628, column 13 of dart:async/stream.dart: """, __x60 is __t50, false))(_cancelAndErr orClosure(subscription, future)));
305 }
306 , onError: future._completeError, onDone: () {
307 future._complete(null);
308 }
309 , cancelOnError: true);
310 return future;
311 }
312 Future<bool> every(bool test(T element)) {
313 _Future<bool> future = new _Future<bool>();
314 StreamSubscription subscription;
315 subscription = this.listen((T element) {
316 _runUserCode(() => test(element), ((__x62) => DDC$RT.wrap((dynamic f(bool __ u61)) {
317 dynamic c(bool x0) => f(DDC$RT.cast(x0, dynamic, bool, "CastParam", """lin e 652, column 13 of dart:async/stream.dart: """, x0 is bool, true));
318 return f == null ? null : c;
319 }
320 , __x62, __t56, __t45, "WrapLiteral", """line 652, column 13 of dart:async/s tream.dart: """, __x62 is __t45))((bool isMatch) {
321 if (!isMatch) {
322 _cancelAndValue(subscription, future, false);
323 }
324 }
325 ), ((__x63) => DDC$RT.cast(__x63, dynamic, __t50, "CastGeneral", """line 657 , column 13 of dart:async/stream.dart: """, __x63 is __t50, false))(_cancelAndEr rorClosure(subscription, future)));
326 }
327 , onError: future._completeError, onDone: () {
328 future._complete(true);
329 }
330 , cancelOnError: true);
331 return future;
332 }
333 Future<bool> any(bool test(T element)) {
334 _Future<bool> future = new _Future<bool>();
335 StreamSubscription subscription;
336 subscription = this.listen((T element) {
337 _runUserCode(() => test(element), ((__x65) => DDC$RT.wrap((dynamic f(bool __ u64)) {
338 dynamic c(bool x0) => f(DDC$RT.cast(x0, dynamic, bool, "CastParam", """lin e 689, column 13 of dart:async/stream.dart: """, x0 is bool, true));
339 return f == null ? null : c;
340 }
341 , __x65, __t56, __t45, "WrapLiteral", """line 689, column 13 of dart:async/s tream.dart: """, __x65 is __t45))((bool isMatch) {
342 if (isMatch) {
343 _cancelAndValue(subscription, future, true);
344 }
345 }
346 ), ((__x66) => DDC$RT.cast(__x66, dynamic, __t50, "CastGeneral", """line 694 , column 13 of dart:async/stream.dart: """, __x66 is __t50, false))(_cancelAndEr rorClosure(subscription, future)));
347 }
348 , onError: future._completeError, onDone: () {
349 future._complete(false);
350 }
351 , cancelOnError: true);
352 return future;
353 }
354 Future<int> get length {
355 _Future<int> future = new _Future<int>();
356 int count = 0;
357 this.listen((_) {
358 count++;
359 }
360 , onError: future._completeError, onDone: () {
361 future._complete(count);
362 }
363 , cancelOnError: true);
364 return future;
365 }
366 Future<bool> get isEmpty {
367 _Future<bool> future = new _Future<bool>();
368 StreamSubscription subscription;
369 subscription = this.listen((_) {
370 _cancelAndValue(subscription, future, false);
371 }
372 , onError: future._completeError, onDone: () {
373 future._complete(true);
374 }
375 , cancelOnError: true);
376 return future;
377 }
378 Future<List<T>> toList() {
379 List<T> result = <T> [];
380 _Future<List<T>> future = new _Future<List<T>>();
381 this.listen((T data) {
382 result.add(data);
383 }
384 , onError: future._completeError, onDone: () {
385 future._complete(result);
386 }
387 , cancelOnError: true);
388 return future;
389 }
390 Future<Set<T>> toSet() {
391 Set<T> result = new Set<T>();
392 _Future<Set<T>> future = new _Future<Set<T>>();
393 this.listen((T data) {
394 result.add(data);
395 }
396 , onError: future._completeError, onDone: () {
397 future._complete(result);
398 }
399 , cancelOnError: true);
400 return future;
401 }
402 Future drain([var futureValue]) => listen(null, cancelOnError: true).asFuture(f utureValue);
403 Stream<T> take(int count) {
404 return ((__x67) => DDC$RT.cast(__x67, DDC$RT.type((_TakeStream<dynamic> _) {
405 }
406 ), DDC$RT.type((Stream<T> _) {
407 }
408 ), "CastExact", """line 819, column 12 of dart:async/stream.dart: """, __x67 i s Stream<T>, false))(new _TakeStream(this, count));
409 }
410 Stream<T> takeWhile(bool test(T element)) {
411 return ((__x68) => DDC$RT.cast(__x68, DDC$RT.type((_TakeWhileStream<dynamic> _ ) {
412 }
413 ), DDC$RT.type((Stream<T> _) {
414 }
415 ), "CastExact", """line 841, column 12 of dart:async/stream.dart: """, __x68 i s Stream<T>, false))(new _TakeWhileStream(this, test));
416 }
417 Stream<T> skip(int count) {
418 return ((__x69) => DDC$RT.cast(__x69, DDC$RT.type((_SkipStream<dynamic> _) {
419 }
420 ), DDC$RT.type((Stream<T> _) {
421 }
422 ), "CastExact", """line 852, column 12 of dart:async/stream.dart: """, __x69 i s Stream<T>, false))(new _SkipStream(this, count));
423 }
424 Stream<T> skipWhile(bool test(T element)) {
425 return ((__x70) => DDC$RT.cast(__x70, DDC$RT.type((_SkipWhileStream<dynamic> _ ) {
426 }
427 ), DDC$RT.type((Stream<T> _) {
428 }
429 ), "CastExact", """line 868, column 12 of dart:async/stream.dart: """, __x70 i s Stream<T>, false))(new _SkipWhileStream(this, test));
430 }
431 Stream<T> distinct([bool equals(T previous, T next)]) {
432 return ((__x71) => DDC$RT.cast(__x71, DDC$RT.type((_DistinctStream<dynamic> _) {
433 }
434 ), DDC$RT.type((Stream<T> _) {
435 }
436 ), "CastExact", """line 885, column 12 of dart:async/stream.dart: """, __x71 i s Stream<T>, false))(new _DistinctStream(this, equals));
437 }
438 Future<T> get first {
439 _Future<T> future = new _Future<T>();
440 StreamSubscription subscription;
441 subscription = this.listen((T value) {
442 _cancelAndValue(subscription, future, value);
443 }
444 , onError: future._completeError, onDone: () {
445 try {
446 throw IterableElementError.noElement();
447 }
448 catch (e, s) {
449 _completeWithErrorCallback(future, e, s);
450 }
451 }
452 , cancelOnError: true);
453 return future;
454 }
455 Future<T> get last {
456 _Future<T> future = new _Future<T>();
457 T result = ((__x72) => DDC$RT.cast(__x72, Null, T, "CastLiteral", """line 936 , column 16 of dart:async/stream.dart: """, __x72 is T, false))(null);
458 bool foundResult = false;
459 StreamSubscription subscription;
460 subscription = this.listen((T value) {
461 foundResult = true;
462 result = value;
463 }
464 , onError: future._completeError, onDone: () {
465 if (foundResult) {
466 future._complete(result);
467 return;}
468 try {
469 throw IterableElementError.noElement();
470 }
471 catch (e, s) {
472 _completeWithErrorCallback(future, e, s);
473 }
474 }
475 , cancelOnError: true);
476 return future;
477 }
478 Future<T> get single {
479 _Future<T> future = new _Future<T>();
480 T result = ((__x73) => DDC$RT.cast(__x73, Null, T, "CastLiteral", """line 970 , column 16 of dart:async/stream.dart: """, __x73 is T, false))(null);
481 bool foundResult = false;
482 StreamSubscription subscription;
483 subscription = this.listen((T value) {
484 if (foundResult) {
468 try { 485 try {
469 throw IterableElementError.noElement(); 486 throw IterableElementError.tooMany();
470 } catch (e, s) { 487 }
471 _completeWithErrorCallback(future, e, s); 488 catch (e, s) {
472 } 489 _cancelAndErrorWithReplacement(subscription, future, e, s);
473 }, cancelOnError: true); 490 }
474 return future; 491 return;}
475 } 492 foundResult = true;
476 Future<T> get single { 493 result = value;
477 _Future<T> future = new _Future<T>(); 494 }
478 T result = ((__x73) => DDC$RT.cast(__x73, Null, T, "CastLiteral", 495 , onError: future._completeError, onDone: () {
479 """line 970, column 16 of dart:async/stream.dart: """, __x73 is T, 496 if (foundResult) {
480 false))(null); 497 future._complete(result);
481 bool foundResult = false; 498 return;}
482 StreamSubscription subscription; 499 try {
483 subscription = this.listen((T value) { 500 throw IterableElementError.noElement();
484 if (foundResult) { 501 }
485 try { 502 catch (e, s) {
486 throw IterableElementError.tooMany(); 503 _completeWithErrorCallback(future, e, s);
487 } catch (e, s) { 504 }
488 _cancelAndErrorWithReplacement(subscription, future, e, s); 505 }
489 } 506 , cancelOnError: true);
490 return; 507 return future;
491 } 508 }
492 foundResult = true; 509 Future<dynamic> firstWhere(bool test(T element), {
493 result = value; 510 Object defaultValue()}
494 }, onError: future._completeError, onDone: () { 511 ) {
495 if (foundResult) { 512 _Future<dynamic> future = new _Future();
496 future._complete(result); 513 StreamSubscription subscription;
497 return; 514 subscription = this.listen((T value) {
498 } 515 _runUserCode(() => test(value), ((__x75) => DDC$RT.wrap((dynamic f(bool __u7 4)) {
499 try { 516 dynamic c(bool x0) => f(DDC$RT.cast(x0, dynamic, bool, "CastParam", """lin e 1031, column 11 of dart:async/stream.dart: """, x0 is bool, true));
500 throw IterableElementError.noElement(); 517 return f == null ? null : c;
501 } catch (e, s) { 518 }
502 _completeWithErrorCallback(future, e, s); 519 , __x75, __t56, __t45, "WrapLiteral", """line 1031, column 11 of dart:async/ stream.dart: """, __x75 is __t45))((bool isMatch) {
503 } 520 if (isMatch) {
504 }, cancelOnError: true); 521 _cancelAndValue(subscription, future, value);
505 return future; 522 }
506 } 523 }
507 Future<dynamic> firstWhere(bool test(T element), {Object defaultValue()}) { 524 ), ((__x76) => DDC$RT.cast(__x76, dynamic, __t50, "CastGeneral", """line 103 6, column 11 of dart:async/stream.dart: """, __x76 is __t50, false))(_cancelAndE rrorClosure(subscription, future)));
508 _Future<dynamic> future = new _Future(); 525 }
509 StreamSubscription subscription; 526 , onError: future._completeError, onDone: () {
510 subscription = this.listen((T value) { 527 if (defaultValue != null) {
511 _runUserCode(() => test(value), ((__x75) => DDC$RT.wrap( 528 _runUserCode(defaultValue, future._complete, future._completeError);
512 (dynamic f(bool __u74)) { 529 return;}
513 dynamic c(bool x0) => f(DDC$RT.cast(x0, dynamic, bool, "CastParam", 530 try {
514 """line 1031, column 11 of dart:async/stream.dart: """, x0 is bool, 531 throw IterableElementError.noElement();
515 true)); 532 }
516 return f == null ? null : c; 533 catch (e, s) {
517 }, __x75, __t56, __t45, "WrapLiteral", 534 _completeWithErrorCallback(future, e, s);
518 """line 1031, column 11 of dart:async/stream.dart: """, 535 }
519 __x75 is __t45))((bool isMatch) { 536 }
520 if (isMatch) { 537 , cancelOnError: true);
521 _cancelAndValue(subscription, future, value); 538 return future;
522 } 539 }
523 }), ((__x76) => DDC$RT.cast(__x76, dynamic, __t50, "CastGeneral", 540 Future<dynamic> lastWhere(bool test(T element), {
524 """line 1036, column 11 of dart:async/stream.dart: """, 541 Object defaultValue()}
525 __x76 is __t50, 542 ) {
526 false))(_cancelAndErrorClosure(subscription, future))); 543 _Future<dynamic> future = new _Future();
527 }, onError: future._completeError, onDone: () { 544 T result = ((__x77) => DDC$RT.cast(__x77, Null, T, "CastLiteral", """line 106 4, column 16 of dart:async/stream.dart: """, __x77 is T, false))(null);
528 if (defaultValue != null) { 545 bool foundResult = false;
529 _runUserCode(defaultValue, future._complete, future._completeError); 546 StreamSubscription subscription;
530 return; 547 subscription = this.listen((T value) {
531 } 548 _runUserCode(() => true == test(value), ((__x79) => DDC$RT.wrap((dynamic f(b ool __u78)) {
532 try { 549 dynamic c(bool x0) => f(DDC$RT.cast(x0, dynamic, bool, "CastParam", """lin e 1071, column 11 of dart:async/stream.dart: """, x0 is bool, true));
533 throw IterableElementError.noElement(); 550 return f == null ? null : c;
534 } catch (e, s) { 551 }
535 _completeWithErrorCallback(future, e, s); 552 , __x79, __t56, __t45, "WrapLiteral", """line 1071, column 11 of dart:async/ stream.dart: """, __x79 is __t45))((bool isMatch) {
536 } 553 if (isMatch) {
537 }, cancelOnError: true); 554 foundResult = true;
538 return future; 555 result = value;
539 } 556 }
540 Future<dynamic> lastWhere(bool test(T element), {Object defaultValue()}) { 557 }
541 _Future<dynamic> future = new _Future(); 558 ), ((__x80) => DDC$RT.cast(__x80, dynamic, __t50, "CastGeneral", """line 107 7, column 11 of dart:async/stream.dart: """, __x80 is __t50, false))(_cancelAndE rrorClosure(subscription, future)));
542 T result = ((__x77) => DDC$RT.cast(__x77, Null, T, "CastLiteral", 559 }
543 """line 1064, column 16 of dart:async/stream.dart: """, __x77 is T, 560 , onError: future._completeError, onDone: () {
544 false))(null); 561 if (foundResult) {
545 bool foundResult = false; 562 future._complete(result);
546 StreamSubscription subscription; 563 return;}
547 subscription = this.listen((T value) { 564 if (defaultValue != null) {
548 _runUserCode(() => true == test(value), ((__x79) => DDC$RT.wrap( 565 _runUserCode(defaultValue, future._complete, future._completeError);
549 (dynamic f(bool __u78)) { 566 return;}
550 dynamic c(bool x0) => f(DDC$RT.cast(x0, dynamic, bool, "CastParam", 567 try {
551 """line 1071, column 11 of dart:async/stream.dart: """, x0 is bool, 568 throw IterableElementError.noElement();
552 true)); 569 }
553 return f == null ? null : c; 570 catch (e, s) {
554 }, __x79, __t56, __t45, "WrapLiteral", 571 _completeWithErrorCallback(future, e, s);
555 """line 1071, column 11 of dart:async/stream.dart: """, 572 }
556 __x79 is __t45))((bool isMatch) { 573 }
557 if (isMatch) { 574 , cancelOnError: true);
558 foundResult = true; 575 return future;
559 result = value; 576 }
560 } 577 Future<T> singleWhere(bool test(T element)) {
561 }), ((__x80) => DDC$RT.cast(__x80, dynamic, __t50, "CastGeneral", 578 _Future<T> future = new _Future<T>();
562 """line 1077, column 11 of dart:async/stream.dart: """, 579 T result = ((__x81) => DDC$RT.cast(__x81, Null, T, "CastLiteral", """line 110 8, column 16 of dart:async/stream.dart: """, __x81 is T, false))(null);
563 __x80 is __t50, 580 bool foundResult = false;
564 false))(_cancelAndErrorClosure(subscription, future))); 581 StreamSubscription subscription;
565 }, onError: future._completeError, onDone: () { 582 subscription = this.listen((T value) {
566 if (foundResult) { 583 _runUserCode(() => true == test(value), ((__x83) => DDC$RT.wrap((dynamic f(b ool __u82)) {
567 future._complete(result); 584 dynamic c(bool x0) => f(DDC$RT.cast(x0, dynamic, bool, "CastParam", """lin e 1115, column 11 of dart:async/stream.dart: """, x0 is bool, true));
568 return; 585 return f == null ? null : c;
569 } 586 }
570 if (defaultValue != null) { 587 , __x83, __t56, __t45, "WrapLiteral", """line 1115, column 11 of dart:async/ stream.dart: """, __x83 is __t45))((bool isMatch) {
571 _runUserCode(defaultValue, future._complete, future._completeError); 588 if (isMatch) {
572 return; 589 if (foundResult) {
573 } 590 try {
574 try { 591 throw IterableElementError.tooMany();
575 throw IterableElementError.noElement();
576 } catch (e, s) {
577 _completeWithErrorCallback(future, e, s);
578 }
579 }, cancelOnError: true);
580 return future;
581 }
582 Future<T> singleWhere(bool test(T element)) {
583 _Future<T> future = new _Future<T>();
584 T result = ((__x81) => DDC$RT.cast(__x81, Null, T, "CastLiteral",
585 """line 1108, column 16 of dart:async/stream.dart: """, __x81 is T,
586 false))(null);
587 bool foundResult = false;
588 StreamSubscription subscription;
589 subscription = this.listen((T value) {
590 _runUserCode(() => true == test(value), ((__x83) => DDC$RT.wrap(
591 (dynamic f(bool __u82)) {
592 dynamic c(bool x0) => f(DDC$RT.cast(x0, dynamic, bool, "CastParam",
593 """line 1115, column 11 of dart:async/stream.dart: """, x0 is bool,
594 true));
595 return f == null ? null : c;
596 }, __x83, __t56, __t45, "WrapLiteral",
597 """line 1115, column 11 of dart:async/stream.dart: """,
598 __x83 is __t45))((bool isMatch) {
599 if (isMatch) {
600 if (foundResult) {
601 try {
602 throw IterableElementError.tooMany();
603 } catch (e, s) {
604 _cancelAndErrorWithReplacement(subscription, future, e, s);
605 } 592 }
606 return; 593 catch (e, s) {
594 _cancelAndErrorWithReplacement(subscription, future, e, s);
595 }
596 return;}
597 foundResult = true;
598 result = value;
599 }
600 }
601 ), ((__x84) => DDC$RT.cast(__x84, dynamic, __t50, "CastGeneral", """line 112 9, column 11 of dart:async/stream.dart: """, __x84 is __t50, false))(_cancelAndE rrorClosure(subscription, future)));
602 }
603 , onError: future._completeError, onDone: () {
604 if (foundResult) {
605 future._complete(result);
606 return;}
607 try {
608 throw IterableElementError.noElement();
609 }
610 catch (e, s) {
611 _completeWithErrorCallback(future, e, s);
612 }
613 }
614 , cancelOnError: true);
615 return future;
616 }
617 Future<T> elementAt(int index) {
618 if (index is! int || index < 0) throw new ArgumentError(index);
619 _Future<T> future = new _Future<T>();
620 StreamSubscription subscription;
621 int elementIndex = 0;
622 subscription = this.listen((T value) {
623 if (index == elementIndex) {
624 _cancelAndValue(subscription, future, value);
625 return;}
626 elementIndex += 1;
627 }
628 , onError: future._completeError, onDone: () {
629 future._completeError(new RangeError.index(index, this, "index", null, eleme ntIndex));
630 }
631 , cancelOnError: true);
632 return future;
633 }
634 Stream timeout(Duration timeLimit, {
635 void onTimeout(EventSink sink)}
636 ) {
637 StreamController controller;
638 StreamSubscription<T> subscription;
639 Timer timer;
640 Zone zone;
641 Function timeout;
642 void onData(T event) {
643 timer.cancel();
644 controller.add(event);
645 timer = zone.createTimer(timeLimit, DDC$RT.cast(timeout, Function, __t85, " CastGeneral", """line 1219, column 43 of dart:async/stream.dart: """, timeout is __t85, false));
646 }
647 void onError(error, StackTrace stackTrace) {
648 timer.cancel();
649 assert (controller is _StreamController || controller is _BroadcastStreamCo ntroller); var eventSink = controller;
650 eventSink._addError(error, stackTrace);
651 timer = zone.createTimer(timeLimit, DDC$RT.cast(timeout, Function, __t85, " CastGeneral", """line 1227, column 43 of dart:async/stream.dart: """, timeout is __t85, false));
652 }
653 void onDone() {
654 timer.cancel();
655 controller.close();
656 }
657 void onListen() {
658 zone = Zone.current;
659 if (onTimeout == null) {
660 timeout = () {
661 controller.addError(new TimeoutException("No stream event", timeLimit), null);
662 }
663 ;
664 }
665 else {
666 onTimeout = zone.registerUnaryCallback(DDC$RT.wrap((void f(EventSink<dynam ic> __u86)) {
667 void c(EventSink<dynamic> x0) => f(DDC$RT.cast(x0, dynamic, DDC$RT.type( (EventSink<dynamic> _) {
607 } 668 }
608 foundResult = true; 669 ), "CastParam", """line 1245, column 48 of dart:async/stream.dart: """, x0 is EventSink<dynamic>, true));
609 result = value; 670 return f == null ? null : c;
610 } 671 }
611 }), ((__x84) => DDC$RT.cast(__x84, dynamic, __t50, "CastGeneral", 672 , onTimeout, __t87, __t45, "Wrap", """line 1245, column 48 of dart:async/s tream.dart: """, onTimeout is __t45));
612 """line 1129, column 11 of dart:async/stream.dart: """, 673 _ControllerEventSinkWrapper wrapper = new _ControllerEventSinkWrapper(nul l);
613 __x84 is __t50, 674 timeout = () {
614 false))(_cancelAndErrorClosure(subscription, future))); 675 wrapper._sink = controller;
615 }, onError: future._completeError, onDone: () { 676 zone.runUnaryGuarded(DDC$RT.wrap((void f(EventSink<dynamic> __u89)) {
616 if (foundResult) { 677 void c(EventSink<dynamic> x0) => f(DDC$RT.cast(x0, dynamic, DDC$RT.typ e((EventSink<dynamic> _) {
617 future._complete(result); 678 }
618 return; 679 ), "CastParam", """line 1250, column 32 of dart:async/stream.dart: """ , x0 is EventSink<dynamic>, true));
619 } 680 return f == null ? null : c;
620 try { 681 }
621 throw IterableElementError.noElement(); 682 , onTimeout, __t87, __t45, "Wrap", """line 1250, column 32 of dart:async /stream.dart: """, onTimeout is __t45), wrapper);
622 } catch (e, s) { 683 wrapper._sink = null;
623 _completeWithErrorCallback(future, e, s); 684 }
624 } 685 ;
625 }, cancelOnError: true); 686 }
626 return future; 687 subscription = this.listen(onData, onError: onError, onDone: onDone);
627 } 688 timer = zone.createTimer(timeLimit, DDC$RT.cast(timeout, Function, __t85, " CastGeneral", """line 1256, column 43 of dart:async/stream.dart: """, timeout is __t85, false));
628 Future<T> elementAt(int index) { 689 }
629 if (index is! int || index < 0) throw new ArgumentError(index); 690 Future onCancel() {
630 _Future<T> future = new _Future<T>(); 691 timer.cancel();
631 StreamSubscription subscription; 692 Future result = subscription.cancel();
632 int elementIndex = 0; 693 subscription = null;
633 subscription = this.listen((T value) { 694 return result;
634 if (index == elementIndex) { 695 }
635 _cancelAndValue(subscription, future, value); 696 controller = isBroadcast ? new _SyncBroadcastStreamController(onListen, onCan cel) : new _SyncStreamController(onListen, () {
636 return; 697 timer.cancel();
637 } 698 subscription.pause();
638 elementIndex += 1; 699 }
639 }, onError: future._completeError, onDone: () { 700 , () {
640 future._completeError( 701 subscription.resume();
641 new RangeError.index(index, this, "index", null, elementIndex)); 702 timer = zone.createTimer(timeLimit, DDC$RT.cast(timeout, Function, __t85, " CastGeneral", """line 1275, column 53 of dart:async/stream.dart: """, timeout is __t85, false));
642 }, cancelOnError: true); 703 }
643 return future; 704 , onCancel);
644 } 705 return controller.stream;
645 Stream timeout(Duration timeLimit, {void onTimeout(EventSink sink)}) { 706 }
646 StreamController controller; 707 }
647 StreamSubscription<T> subscription; 708 abstract class StreamSubscription<T> {Future cancel();
648 Timer timer; 709 void onData(void handleData(T data));
649 Zone zone; 710 void onError(Function handleError);
650 Function timeout; 711 void onDone(void handleDone());
651 void onData(T event) { 712 void pause([Future resumeSignal]);
652 timer.cancel(); 713 void resume();
653 controller.add(event); 714 bool get isPaused;
654 timer = zone.createTimer(timeLimit, DDC$RT.cast(timeout, Function, __t85, 715 Future asFuture([var futureValue]);
655 "CastGeneral", """line 1219, column 43 of dart:async/stream.dart: """, 716 }
656 timeout is __t85, false)); 717 abstract class EventSink<T> implements Sink<T> {void add(T event);
657 } 718 void addError(errorEvent, [StackTrace stackTrace]);
658 void onError(error, StackTrace stackTrace) { 719 void close();
659 timer.cancel(); 720 }
660 assert(controller is _StreamController || 721 class StreamView<T> extends Stream<T> {Stream<T> _stream;
661 controller is _BroadcastStreamController); 722 StreamView(this._stream);
662 var eventSink = controller; 723 bool get isBroadcast => _stream.isBroadcast;
663 eventSink._addError(error, stackTrace); 724 Stream<T> asBroadcastStream({
664 timer = zone.createTimer(timeLimit, DDC$RT.cast(timeout, Function, __t85, 725 void onListen(StreamSubscription subscription), void onCancel(StreamSubscription subscription)}
665 "CastGeneral", """line 1227, column 43 of dart:async/stream.dart: """, 726 ) => _stream.asBroadcastStream(onListen: onListen, onCancel: onCancel);
666 timeout is __t85, false)); 727 StreamSubscription<T> listen(void onData(T value), {
667 } 728 Function onError, void onDone(), bool cancelOnError}
668 void onDone() { 729 ) {
669 timer.cancel(); 730 return _stream.listen(onData, onError: onError, onDone: onDone, cancelOnError: c ancelOnError);
670 controller.close(); 731 }
671 } 732 }
672 void onListen() { 733 abstract class StreamConsumer<S> {Future addStream(Stream<S> stream);
673 zone = Zone.current; 734 Future close();
674 if (onTimeout == null) { 735 }
675 timeout = () { 736 abstract class StreamSink<S> implements StreamConsumer<S>, EventSink<S> {Future close();
676 controller.addError( 737 Future get done;
677 new TimeoutException("No stream event", timeLimit), null); 738 }
678 }; 739 abstract class StreamTransformer<S, T> {const factory StreamTransformer(StreamS ubscription<T> transformer(Stream<S> stream, bool cancelOnError)) = _StreamSubsc riptionTransformer;
679 } else { 740 factory StreamTransformer.fromHandlers({
680 onTimeout = zone.registerUnaryCallback(DDC$RT.wrap( 741 void handleData(S data, EventSink<T> sink), void handleError(Object error, Stack Trace stackTrace, EventSink<T> sink), void handleDone(EventSink<T> sink)}
681 (void f(EventSink<dynamic> __u86)) { 742 ) = _StreamHandlerTransformer;
682 void c(EventSink<dynamic> x0) => f(DDC$RT.cast(x0, dynamic, 743 Stream<T> bind(Stream<S> stream);
683 DDC$RT.type((EventSink<dynamic> _) {}), "CastParam", 744 }
684 """line 1245, column 48 of dart:async/stream.dart: """, 745 abstract class StreamIterator<T> {factory StreamIterator(Stream<T> stream) => n ew _StreamIteratorImpl<T>(stream);
685 x0 is EventSink<dynamic>, true)); 746 Future<bool> moveNext();
686 return f == null ? null : c; 747 T get current;
687 }, onTimeout, __t87, __t45, "Wrap", 748 Future cancel();
688 """line 1245, column 48 of dart:async/stream.dart: """, 749 }
689 onTimeout is __t45)); 750 class _ControllerEventSinkWrapper<T> implements EventSink<T> {EventSink _sink;
690 _ControllerEventSinkWrapper wrapper = 751 _ControllerEventSinkWrapper(this._sink);
691 new _ControllerEventSinkWrapper(null); 752 void add(T data) {
692 timeout = () { 753 _sink.add(data);
693 wrapper._sink = controller; 754 }
694 zone.runUnaryGuarded(DDC$RT.wrap((void f(EventSink<dynamic> __u89)) { 755 void addError(error, [StackTrace stackTrace]) {
695 void c(EventSink<dynamic> x0) => f(DDC$RT.cast(x0, dynamic, 756 _sink.addError(error, stackTrace);
696 DDC$RT.type((EventSink<dynamic> _) {}), "CastParam", 757 }
697 """line 1250, column 32 of dart:async/stream.dart: """, 758 void close() {
698 x0 is EventSink<dynamic>, true)); 759 _sink.close();
699 return f == null ? null : c; 760 }
700 }, onTimeout, __t87, __t45, "Wrap", 761 }
701 """line 1250, column 32 of dart:async/stream.dart: """, 762 typedef T __t38<T>(int __u39);
702 onTimeout is __t45), wrapper); 763 typedef dynamic __t40(dynamic __u41);
703 wrapper._sink = null; 764 typedef dynamic __t45(dynamic __u46);
704 }; 765 typedef dynamic __t47<T>(T __u48);
705 } 766 typedef dynamic __t50(dynamic __u51, StackTrace __u52);
706 subscription = this.listen(onData, onError: onError, onDone: onDone); 767 typedef dynamic __t56(bool __u57);
707 timer = zone.createTimer(timeLimit, DDC$RT.cast(timeout, Function, __t85, 768 typedef void __t85();
708 "CastGeneral", """line 1256, column 43 of dart:async/stream.dart: """, 769 typedef void __t87(EventSink<dynamic> __u88);
709 timeout is __t85, false));
710 }
711 Future onCancel() {
712 timer.cancel();
713 Future result = subscription.cancel();
714 subscription = null;
715 return result;
716 }
717 controller = isBroadcast
718 ? new _SyncBroadcastStreamController(onListen, onCancel)
719 : new _SyncStreamController(onListen, () {
720 timer.cancel();
721 subscription.pause();
722 }, () {
723 subscription.resume();
724 timer = zone.createTimer(timeLimit, DDC$RT.cast(timeout, Function, __t85,
725 "CastGeneral", """line 1275, column 53 of dart:async/stream.dart: """,
726 timeout is __t85, false));
727 }, onCancel);
728 return controller.stream;
729 }
730 }
731 abstract class StreamSubscription<T> {
732 Future cancel();
733 void onData(void handleData(T data));
734 void onError(Function handleError);
735 void onDone(void handleDone());
736 void pause([Future resumeSignal]);
737 void resume();
738 bool get isPaused;
739 Future asFuture([var futureValue]);
740 }
741 abstract class EventSink<T> implements Sink<T> {
742 void add(T event);
743 void addError(errorEvent, [StackTrace stackTrace]);
744 void close();
745 }
746 class StreamView<T> extends Stream<T> {
747 Stream<T> _stream;
748 StreamView(this._stream);
749 bool get isBroadcast => _stream.isBroadcast;
750 Stream<T> asBroadcastStream({void onListen(StreamSubscription subscription),
751 void onCancel(StreamSubscription subscription)}) =>
752 _stream.asBroadcastStream(onListen: onListen, onCancel: onCancel);
753 StreamSubscription<T> listen(void onData(T value),
754 {Function onError, void onDone(), bool cancelOnError}) {
755 return _stream.listen(onData,
756 onError: onError, onDone: onDone, cancelOnError: cancelOnError);
757 }
758 }
759 abstract class StreamConsumer<S> {
760 Future addStream(Stream<S> stream);
761 Future close();
762 }
763 abstract class StreamSink<S> implements StreamConsumer<S>, EventSink<S> {
764 Future close();
765 Future get done;
766 }
767 abstract class StreamTransformer<S, T> {
768 const factory StreamTransformer(StreamSubscription<T> transformer(
769 Stream<S> stream, bool cancelOnError)) = _StreamSubscriptionTransformer;
770 factory StreamTransformer.fromHandlers(
771 {void handleData(S data, EventSink<T> sink),
772 void handleError(Object error, StackTrace stackTrace, EventSink<T> sink),
773 void handleDone(EventSink<T> sink)}) = _StreamHandlerTransformer;
774 Stream<T> bind(Stream<S> stream);
775 }
776 abstract class StreamIterator<T> {
777 factory StreamIterator(Stream<T> stream) =>
778 new _StreamIteratorImpl<T>(stream);
779 Future<bool> moveNext();
780 T get current;
781 Future cancel();
782 }
783 class _ControllerEventSinkWrapper<T> implements EventSink<T> {
784 EventSink _sink;
785 _ControllerEventSinkWrapper(this._sink);
786 void add(T data) {
787 _sink.add(data);
788 }
789 void addError(error, [StackTrace stackTrace]) {
790 _sink.addError(error, stackTrace);
791 }
792 void close() {
793 _sink.close();
794 }
795 }
796 typedef T __t38<T>(int __u39);
797 typedef dynamic __t40(dynamic __u41);
798 typedef dynamic __t45(dynamic __u46);
799 typedef dynamic __t47<T>(T __u48);
800 typedef dynamic __t50(dynamic __u51, StackTrace __u52);
801 typedef dynamic __t56(bool __u57);
802 typedef void __t85();
803 typedef void __t87(EventSink<dynamic> __u88);
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698