From 5d6ce288412fd7581b2b904f0b81467502417e1a Mon Sep 17 00:00:00 2001 From: Don Date: Wed, 24 May 2017 17:22:09 -0700 Subject: [PATCH] Remove ByteStream (#84) --- lib/http.dart | 1 - lib/src/byte_stream.dart | 36 ------------------------------------ lib/src/utils.dart | 8 -------- 3 files changed, 45 deletions(-) delete mode 100644 lib/src/byte_stream.dart diff --git a/lib/http.dart b/lib/http.dart index f59c19e732..d098a47e27 100644 --- a/lib/http.dart +++ b/lib/http.dart @@ -11,7 +11,6 @@ import 'src/client.dart'; import 'src/response.dart'; export 'src/base_client.dart'; -export 'src/byte_stream.dart'; export 'src/client.dart'; export 'src/exception.dart'; export 'src/io_client.dart'; diff --git a/lib/src/byte_stream.dart b/lib/src/byte_stream.dart deleted file mode 100644 index a9d47b075f..0000000000 --- a/lib/src/byte_stream.dart +++ /dev/null @@ -1,36 +0,0 @@ -// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file -// for details. All rights reserved. Use of this source code is governed by a -// BSD-style license that can be found in the LICENSE file. - -import 'dart:async'; -import 'dart:convert'; -import 'dart:typed_data'; - -/// A stream of chunks of bytes representing a single piece of data. -class ByteStream extends StreamView> { - ByteStream(Stream> stream) - : super(stream); - - /// Returns a single-subscription byte stream that will emit the given bytes - /// in a single chunk. - factory ByteStream.fromBytes(List bytes) => - new ByteStream(new Stream.fromIterable([bytes])); - - /// Collects the data of this stream in a [Uint8List]. - Future toBytes() { - var completer = new Completer(); - var sink = new ByteConversionSink.withCallback((bytes) => - completer.complete(new Uint8List.fromList(bytes))); - listen(sink.add, onError: completer.completeError, onDone: sink.close, - cancelOnError: true); - return completer.future; - } - - /// Collect the data of this stream in a [String], decoded according to - /// [encoding], which defaults to `UTF8`. - Future bytesToString([Encoding encoding=UTF8]) => - encoding.decodeStream(this); - - Stream toStringStream([Encoding encoding=UTF8]) => - encoding.decoder.bind(this); -} diff --git a/lib/src/utils.dart b/lib/src/utils.dart index b7e7347a3d..c19d354b9c 100644 --- a/lib/src/utils.dart +++ b/lib/src/utils.dart @@ -8,7 +8,6 @@ import 'dart:typed_data'; import 'package:collection/collection.dart'; -import 'byte_stream.dart'; import 'http_unmodifiable_map.dart'; /// Returns a [Map] with the values from [original] and the values from @@ -93,13 +92,6 @@ Uint8List toUint8List(List input) { return new Uint8List.fromList(input); } -/// If [stream] is already a [ByteStream], returns it. Otherwise, wraps it in a -/// [ByteStream]. -ByteStream toByteStream(Stream> stream) { - if (stream is ByteStream) return stream; - return new ByteStream(stream); -} - /// Calls [onDone] once [stream] (a single-subscription [Stream]) is finished. /// The return value, also a single-subscription [Stream] should be used in /// place of [stream] after calling this method.