Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Commit 93ff953

Browse files
lrhncommit-bot@chromium.org
authored andcommitted
Document difference between Stream.transform and Stream.map.
Fixes #36351 Bug: http://dartbug.com/36351 Change-Id: I75f98b8fdc3a34578adab96e9993089ea69e84bd Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/98346 Commit-Queue: Lasse R.H. Nielsen <[email protected]> Reviewed-by: Nate Bosch <[email protected]>
1 parent b0b8304 commit 93ff953

File tree

4 files changed

+20
-3
lines changed

4 files changed

+20
-3
lines changed

sdk/lib/async/stream.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -689,7 +689,7 @@ abstract class Stream<T> {
689689
}
690690

691691
/**
692-
* Applies [streamTransformer] to this stream.
692+
* Applies [streamTransformer] to this stream.
693693
*
694694
* Returns the transformed stream,
695695
* that is, the result of `streamTransformer.bind(this)`.

sdk/lib/convert/json.dart

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,9 @@ class JsonCodec extends Codec<Object, String> {
181181
}
182182

183183
/// This class converts JSON objects to strings.
184+
///
185+
/// When used as a [StreamTransformer], this converter does not promise
186+
/// that the input object is emitted as a single string event.
184187
class JsonEncoder extends Converter<Object, String> {
185188
/// The string used for indention.
186189
///
@@ -470,7 +473,14 @@ class _JsonUtf8EncoderSink extends ChunkedConversionSink<Object> {
470473
}
471474
}
472475

473-
/// This class parses JSON strings and builds the corresponding objects.
476+
/// This class parses JSON strings and builds the corresponding value.
477+
///
478+
/// A JSON input must be the JSON encoding of a single JSON value,
479+
/// which can be a list or map containing other values.
480+
///
481+
/// When used as a [StreamTransformer], the input stream may emit
482+
/// multiple strings. The concatenation of all of these strings must
483+
/// be a valid JSON encoding of a single JSON value.
474484
class JsonDecoder extends Converter<String, Object> {
475485
final Function(Object key, Object value) _reviver;
476486

sdk_nnbd/lib/async/stream.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -668,7 +668,7 @@ abstract class Stream<T> {
668668
}
669669

670670
/**
671-
* Applies [streamTransformer] to this stream.
671+
* Applies [streamTransformer] to this stream.
672672
*
673673
* Returns the transformed stream,
674674
* that is, the result of `streamTransformer.bind(this)`.

sdk_nnbd/lib/convert/json.dart

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -473,6 +473,13 @@ class _JsonUtf8EncoderSink extends ChunkedConversionSink<Object?> {
473473
}
474474

475475
/// This class parses JSON strings and builds the corresponding objects.
476+
///
477+
/// A JSON input must be the JSON encoding of a single JSON value,
478+
/// which can be a list or map containing other values.
479+
///
480+
/// When used as a [StreamTransformer], the input stream may emit
481+
/// multiple strings. The concatenation of all of these strings must
482+
/// be a valid JSON encoding of a single JSON value.
476483
class JsonDecoder extends Converter<String, Object?> {
477484
final Object? Function(Object? key, Object? value)? _reviver;
478485

0 commit comments

Comments
 (0)