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

Side by Side Diff: sdk/lib/io/io_sink.dart

Issue 13008021: Add optional writeAll separator argument. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 9 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
« sdk/lib/core/string_buffer.dart ('K') | « sdk/lib/io/http_impl.dart ('k') | no next file » | 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) 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.io; 5 part of dart.io;
6 6
7 /** 7 /**
8 * Helper class to wrap a [StreamConsumer<List<int>, T>] and provide 8 * Helper class to wrap a [StreamConsumer<List<int>, T>] and provide
9 * utility functions for writing to the StreamConsumer directly. The 9 * utility functions for writing to the StreamConsumer directly. The
10 * [IOSink] buffers the input given by [write], [writeAll], [writeln], 10 * [IOSink] buffers the input given by [write], [writeAll], [writeln],
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
87 } else { 87 } else {
88 string = obj.toString(); 88 string = obj.toString();
89 if (string is! String) { 89 if (string is! String) {
90 throw new ArgumentError('toString() did not return a string'); 90 throw new ArgumentError('toString() did not return a string');
91 } 91 }
92 } 92 }
93 if (string.isEmpty) return; 93 if (string.isEmpty) return;
94 writeBytes(_encodeString(string, _encoding)); 94 writeBytes(_encodeString(string, _encoding));
95 } 95 }
96 96
97 void writeAll(Iterable objects) { 97 void writeAll(Iterable objects, [String separator = ""]) {
98 for (Object obj in objects) write(obj); 98 bool isFirst = true;
99 for (Object obj in objects) {
100 if (isFirst) {
101 isFirst = false;
102 } else {
103 if (separator != "") write(separator);
104 }
105 write(obj);
106 }
99 } 107 }
100 108
101 void writeln([Object obj = ""]) { 109 void writeln([Object obj = ""]) {
102 write(obj); 110 write(obj);
103 write("\n"); 111 write("\n");
104 } 112 }
105 113
106 void writeCharCode(int charCode) { 114 void writeCharCode(int charCode) {
107 write(new String.fromCharCode(charCode)); 115 write(new String.fromCharCode(charCode));
108 } 116 }
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
225 }, 233 },
226 onError: _controller.addError); 234 onError: _controller.addError);
227 if (_paused) _pause(); 235 if (_paused) _pause();
228 if (unbind) { 236 if (unbind) {
229 return _writeStreamCompleter.future; 237 return _writeStreamCompleter.future;
230 } else { 238 } else {
231 return _pipeFuture; 239 return _pipeFuture;
232 } 240 }
233 } 241 }
234 } 242 }
OLDNEW
« sdk/lib/core/string_buffer.dart ('K') | « sdk/lib/io/http_impl.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698