Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(662)

Side by Side Diff: sdk/lib/_internal/pub/lib/src/utils.dart

Issue 25354003: Redo StreamTransformers so they work with Stack traces. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Address comments. Created 7 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « sdk/lib/_internal/compiler/implementation/dart2js.dart ('k') | sdk/lib/async/async.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, 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 /// Generic utility functions. Stuff that should possibly be in core. 5 /// Generic utility functions. Stuff that should possibly be in core.
6 library pub.utils; 6 library pub.utils;
7 7
8 import 'dart:async'; 8 import 'dart:async';
9 import "dart:collection"; 9 import "dart:collection";
10 import "dart:convert"; 10 import "dart:convert";
(...skipping 389 matching lines...) Expand 10 before | Expand all | Expand 10 after
400 // fixed. 400 // fixed.
401 /// Splits [text] on its line breaks in a Windows-line-break-friendly way. 401 /// Splits [text] on its line breaks in a Windows-line-break-friendly way.
402 List<String> splitLines(String text) => 402 List<String> splitLines(String text) =>
403 text.split("\n").map((line) => line.replaceFirst(_trailingCR, "")).toList(); 403 text.split("\n").map((line) => line.replaceFirst(_trailingCR, "")).toList();
404 404
405 /// Converts a stream of arbitrarily chunked strings into a line-by-line stream. 405 /// Converts a stream of arbitrarily chunked strings into a line-by-line stream.
406 /// The lines don't include line termination characters. A single trailing 406 /// The lines don't include line termination characters. A single trailing
407 /// newline is ignored. 407 /// newline is ignored.
408 Stream<String> streamToLines(Stream<String> stream) { 408 Stream<String> streamToLines(Stream<String> stream) {
409 var buffer = new StringBuffer(); 409 var buffer = new StringBuffer();
410 return stream.transform(new StreamTransformer( 410 return stream.transform(new StreamTransformer.fromHandlers(
411 handleData: (chunk, sink) { 411 handleData: (chunk, sink) {
412 var lines = splitLines(chunk); 412 var lines = splitLines(chunk);
413 var leftover = lines.removeLast(); 413 var leftover = lines.removeLast();
414 for (var line in lines) { 414 for (var line in lines) {
415 if (!buffer.isEmpty) { 415 if (!buffer.isEmpty) {
416 buffer.write(line); 416 buffer.write(line);
417 line = buffer.toString(); 417 line = buffer.toString();
418 buffer = new StringBuffer(); 418 buffer = new StringBuffer();
419 } 419 }
420 420
(...skipping 313 matching lines...) Expand 10 before | Expand all | Expand 10 after
734 error is DirectoryException || 734 error is DirectoryException ||
735 error is FileException || 735 error is FileException ||
736 error is HttpException || 736 error is HttpException ||
737 error is HttpException || 737 error is HttpException ||
738 error is LinkException || 738 error is LinkException ||
739 error is OSError || 739 error is OSError ||
740 error is ProcessException || 740 error is ProcessException ||
741 error is SocketException || 741 error is SocketException ||
742 error is WebSocketException; 742 error is WebSocketException;
743 } 743 }
OLDNEW
« no previous file with comments | « sdk/lib/_internal/compiler/implementation/dart2js.dart ('k') | sdk/lib/async/async.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698