| Index: sdk/lib/_internal/pub/lib/src/utils.dart
|
| diff --git a/sdk/lib/_internal/pub/lib/src/utils.dart b/sdk/lib/_internal/pub/lib/src/utils.dart
|
| index 8a63d52579beec62bf94877919ada0c0be509af6..c17546e7be8489e8c2794764fcf2b92acee9ec17 100644
|
| --- a/sdk/lib/_internal/pub/lib/src/utils.dart
|
| +++ b/sdk/lib/_internal/pub/lib/src/utils.dart
|
| @@ -393,6 +393,25 @@ Stream mergeStreams(Stream stream1, Stream stream2) {
|
| return controller.stream;
|
| }
|
|
|
| +/// Returns a [Stream] that will emit the same values as the stream returned by
|
| +/// [callback].
|
| +///
|
| +/// [callback] will only be called when the returned [Stream] gets a subscriber.
|
| +Stream callbackStream(Stream callback()) {
|
| + var subscription;
|
| + var controller;
|
| + controller = new StreamController(onListen: () {
|
| + subscription = callback().listen(controller.add,
|
| + onError: controller.addError,
|
| + onDone: controller.close);
|
| + },
|
| + onCancel: () => subscription.cancel(),
|
| + onPause: () => subscription.pause(),
|
| + onResume: () => subscription.resume(),
|
| + sync: true);
|
| + return controller.stream;
|
| +}
|
| +
|
| /// A regular expression matching a trailing CR character.
|
| final _trailingCR = new RegExp(r"\r$");
|
|
|
|
|