Make Stdin act like a Stream<Uint8List> (#39)
* Make Stdin act like a Stream<Uint8List>
In preparation for https://github.com/dart-lang/sdk/issues/36900
* Bump version, and add changelog entry
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 104c05a..ab64309 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,3 +1,7 @@
+## 0.1.21
+
+* Make `TestStdinAsync` behave like a `Stream<Uint8List>`
+
## 0.1.20
* Close worker `outputStream` on `cancel`.
diff --git a/lib/testing.dart b/lib/testing.dart
index a8b66c1..1e7ccc3 100644
--- a/lib/testing.dart
+++ b/lib/testing.dart
@@ -5,6 +5,7 @@
import 'dart:async';
import 'dart:collection';
import 'dart:io';
+import 'dart:typed_data';
import 'package:bazel_worker/bazel_worker.dart';
@@ -50,12 +51,12 @@
/// Note: You must call [close] in order for the loop to exit properly.
class TestStdinAsync implements TestStdin {
/// Controls the stream for async delivery of bytes.
- final StreamController<List<int>> _controller = new StreamController();
- StreamController<List<int>> get controller => _controller;
+ final StreamController<Uint8List> _controller = new StreamController();
+ StreamController<Uint8List> get controller => _controller;
/// Adds all the [bytes] to this stream.
void addInputBytes(List<int> bytes) {
- _controller.add(bytes);
+ _controller.add(Uint8List.fromList(bytes));
}
/// Closes this stream. This is necessary for the [AsyncWorkerLoop] to exit.
@@ -64,7 +65,7 @@
}
@override
- StreamSubscription<List<int>> listen(onData(List<int> bytes),
+ StreamSubscription<Uint8List> listen(onData(Uint8List bytes),
{Function onError, void onDone(), bool cancelOnError}) {
return _controller.stream.listen(onData,
onError: onError, onDone: onDone, cancelOnError: cancelOnError);
diff --git a/pubspec.yaml b/pubspec.yaml
index b2e3641..f7da685 100644
--- a/pubspec.yaml
+++ b/pubspec.yaml
@@ -1,5 +1,5 @@
name: bazel_worker
-version: 0.1.20
+version: 0.1.21
description: Tools for creating a bazel persistent worker.
author: Dart Team <misc@dartlang.org>