| Index: sdk/lib/async/stream.dart
|
| diff --git a/sdk/lib/async/stream.dart b/sdk/lib/async/stream.dart
|
| index 9ce21c6f926f302da3be42e3ff5816b3f96ca2b7..d63dc7c2f8659431db5b8873090e6b69cd9892f3 100644
|
| --- a/sdk/lib/async/stream.dart
|
| +++ b/sdk/lib/async/stream.dart
|
| @@ -328,6 +328,44 @@ abstract class Stream<T> {
|
| }
|
|
|
| /**
|
| + * Collects string of data events' string representations.
|
| + *
|
| + * If [separator] is provided, it is inserted between any two
|
| + * elements.
|
| + *
|
| + * Any error in the stream causes the future to complete with that
|
| + * error. Otherwise it completes with the collected string when
|
| + * the "done" event arrives.
|
| + */
|
| + Future<String> join([String separator = ""]) {
|
| + _FutureImpl<String> result = new _FutureImpl<String>();
|
| + StringBuffer buffer = new StringBuffer();
|
| + StreamSubscription subscription;
|
| + bool first = true;
|
| + subscription = this.listen(
|
| + (T element) {
|
| + if (!first) {
|
| + buffer.write(separator);
|
| + }
|
| + first = false;
|
| + try {
|
| + buffer.write(element);
|
| + } catch (e, s) {
|
| + subscription.cancel();
|
| + result._setError(_asyncError(e, s));
|
| + }
|
| + },
|
| + onError: (e) {
|
| + result._setError(e);
|
| + },
|
| + onDone: () {
|
| + result._setValue(buffer.toString());
|
| + },
|
| + cancelOnError: true);
|
| + return result;
|
| + }
|
| +
|
| + /**
|
| * Checks whether [needle] occurs in the elements provided by this stream.
|
| *
|
| * Completes the [Future] when the answer is known.
|
|
|