Skip to content
This repository was archived by the owner on Dec 9, 2024. It is now read-only.

Commit 12156a5

Browse files
leafpetersentvolkert
authored andcommitted
Fix line splitter (#62)
Replace use of LineSplitter with wrapper that correctly implements the Converter<String, List<String>> interface.
1 parent ec7dfdb commit 12156a5

File tree

4 files changed

+32
-2
lines changed

4 files changed

+32
-2
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
#### 2.3.5
2+
3+
* Fix internal use of a cast which fails on Dart 2.0 .
4+
15
#### 2.3.4
26

37
* Bumped maximum Dart SDK version to 2.0.0-dev.infinity

lib/src/backends/record_replay/codecs.dart

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,32 @@ class _GenericEncoder extends Converter<dynamic, dynamic> {
8585
}
8686
}
8787

88+
/// A trivial conversion turning a Sink<List<String>> into a
89+
/// Sink<String>
90+
class _StringSinkWrapper implements Sink<String> {
91+
final Sink<List<String>> _sink;
92+
_StringSinkWrapper(this._sink);
93+
@override
94+
void add(String s) => _sink.add(<String>[s]);
95+
@override
96+
void close() => _sink.close();
97+
}
98+
99+
/// An Converter version of the dart:convert LineSplitter (which in
100+
/// 2.0 no longer implements the Converter interface)
101+
class LineSplitterConverter extends Converter<String, List<String>> {
102+
final LineSplitter _splitter = const LineSplitter();
103+
104+
/// Creates a new [LineSplitterConverter]
105+
const LineSplitterConverter();
106+
107+
@override
108+
List<String> convert(String input) => _splitter.convert(input);
109+
@override
110+
StringConversionSink startChunkedConversion(Sink<List<String>> sink) =>
111+
_splitter.startChunkedConversion(new _StringSinkWrapper(sink));
112+
}
113+
88114
/// Converter that leaves an object untouched.
89115
class Passthrough<T> extends Converter<T, T> {
90116
/// Creates a new [Passthrough].

lib/src/backends/record_replay/replay_file.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ class ReplayFile extends ReplayFileSystemEntity implements File {
2525
Converter<String, RandomAccessFile> reviveRandomAccessFile =
2626
new ReviveRandomAccessFile(fileSystem);
2727
Converter<String, List<String>> lineSplitter =
28-
const LineSplitter() as Converter<String, List<String>>;
28+
const LineSplitterConverter();
2929
Converter<String, List<String>> blobToLines =
3030
blobToString.fuse(lineSplitter);
3131
Converter<String, Stream<List<int>>> blobToByteStream = blobToBytes

pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name: file
2-
version: 2.3.4
2+
version: 2.3.5
33
authors:
44
- Matan Lurey <[email protected]>
55
- Yegor Jbanov <[email protected]>

0 commit comments

Comments
 (0)