| 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 part of dart.convert; | 5 part of dart.convert; |
| 6 | 6 |
| 7 /** | 7 /** |
| 8 * A [Converter] converts data from one representation into another. | 8 * A [Converter] converts data from one representation into another. |
| 9 * | 9 * |
| 10 * *Converters are still experimental and are subject to change without notice.* | 10 * *Converters are still experimental and are subject to change without notice.* |
| (...skipping 20 matching lines...) Expand all Loading... |
| 31 /** | 31 /** |
| 32 * Starts a chunked conversion. | 32 * Starts a chunked conversion. |
| 33 */ | 33 */ |
| 34 ChunkedConversionSink startChunkedConversion(ChunkedConversionSink sink) { | 34 ChunkedConversionSink startChunkedConversion(ChunkedConversionSink sink) { |
| 35 throw new UnsupportedError( | 35 throw new UnsupportedError( |
| 36 "This converter does not support chunked conversions: $this"); | 36 "This converter does not support chunked conversions: $this"); |
| 37 } | 37 } |
| 38 | 38 |
| 39 // Subclasses are encouraged to provide better types. | 39 // Subclasses are encouraged to provide better types. |
| 40 Stream bind(Stream source) { | 40 Stream bind(Stream source) { |
| 41 return new _ConverterTransformStream(source, this); | 41 return new Stream.eventTransformed( |
| 42 source, |
| 43 (EventSink sink) => new _ConverterStreamEventSink(this, sink)); |
| 42 } | 44 } |
| 43 } | 45 } |
| 44 | 46 |
| 45 /** | 47 /** |
| 46 * Fuses two converters. | 48 * Fuses two converters. |
| 47 * | 49 * |
| 48 * For a non-chunked conversion converts the input in sequence. | 50 * For a non-chunked conversion converts the input in sequence. |
| 49 */ | 51 */ |
| 50 class _FusedConverter<S, M, T> extends Converter<S, T> { | 52 class _FusedConverter<S, M, T> extends Converter<S, T> { |
| 51 final Converter _first; | 53 final Converter _first; |
| 52 final Converter _second; | 54 final Converter _second; |
| 53 | 55 |
| 54 _FusedConverter(this._first, this._second); | 56 _FusedConverter(this._first, this._second); |
| 55 | 57 |
| 56 T convert(S input) => _second.convert(_first.convert(input)); | 58 T convert(S input) => _second.convert(_first.convert(input)); |
| 57 | 59 |
| 58 ChunkedConversionSink startChunkedConversion(ChunkedConversionSink sink) { | 60 ChunkedConversionSink startChunkedConversion(ChunkedConversionSink sink) { |
| 59 return _first.startChunkedConversion(_second.startChunkedConversion(sink)); | 61 return _first.startChunkedConversion(_second.startChunkedConversion(sink)); |
| 60 } | 62 } |
| 61 } | 63 } |
| OLD | NEW |