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 library unittest.utils; | 5 library unittest.utils; |
6 | 6 |
7 import 'dart:async'; | 7 import 'dart:async'; |
8 | 8 |
9 import 'package:stack_trace/stack_trace.dart'; | 9 import 'package:stack_trace/stack_trace.dart'; |
10 | 10 |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
56 if (element is Iterable) { | 56 if (element is Iterable) { |
57 helper(element); | 57 helper(element); |
58 } else { | 58 } else { |
59 result.add(element); | 59 result.add(element); |
60 } | 60 } |
61 } | 61 } |
62 } | 62 } |
63 helper(nested); | 63 helper(nested); |
64 return result; | 64 return result; |
65 } | 65 } |
| 66 |
| 67 /// Returns a sink that maps events sent to [original] using [fn]. |
| 68 StreamSink mapSink(StreamSink original, fn(event)) { |
| 69 var controller = new StreamController(sync: true); |
| 70 controller.stream.listen( |
| 71 (event) => original.add(fn(event)), |
| 72 onError: (error, stackTrace) => original.addError(error, stackTrace), |
| 73 onDone: () => original.close()); |
| 74 return controller.sink; |
| 75 } |
OLD | NEW |