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

Side by Side Diff: lib/src/intl/date_format_helpers.dart

Issue 878603009: Tighten up a couple method signatures to specify that int is required. (Closed) Base URL: git@github.com:dart-lang/intl.git@master
Patch Set: Created 5 years, 10 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
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 5
6 part of intl; 6 part of intl;
7 7
8 /** 8 /**
9 * A class for holding onto the data for a date so that it can be built 9 * A class for holding onto the data for a date so that it can be built
10 * up incrementally. 10 * up incrementally.
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
117 _Stream(this.contents); 117 _Stream(this.contents);
118 118
119 bool atEnd() => index >= contents.length; 119 bool atEnd() => index >= contents.length;
120 120
121 next() => contents[index++]; 121 next() => contents[index++];
122 122
123 /** 123 /**
124 * Return the next [howMany] items, or as many as there are remaining. 124 * Return the next [howMany] items, or as many as there are remaining.
125 * Advance the stream by that many positions. 125 * Advance the stream by that many positions.
126 */ 126 */
127 read([howMany = 1]) { 127 read([int howMany = 1]) {
128 var result = peek(howMany); 128 var result = peek(howMany);
129 index += howMany; 129 index += howMany;
130 return result; 130 return result;
131 } 131 }
132 132
133 /** 133 /**
134 * Does the input start with the given string, if we start from the 134 * Does the input start with the given string, if we start from the
135 * current position. 135 * current position.
136 */ 136 */
137 bool startsWith(String pattern) { 137 bool startsWith(String pattern) {
138 if (contents is String) return contents.startsWith(pattern, index); 138 if (contents is String) return contents.startsWith(pattern, index);
139 return pattern == peek(pattern.length); 139 return pattern == peek(pattern.length);
140 } 140 }
141 141
142 /** 142 /**
143 * Return the next [howMany] items, or as many as there are remaining. 143 * Return the next [howMany] items, or as many as there are remaining.
144 * Does not modify the stream position. 144 * Does not modify the stream position.
145 */ 145 */
146 peek([howMany = 1]) { 146 peek([int howMany = 1]) {
147 var result; 147 var result;
148 if (contents is String) { 148 if (contents is String) {
149 result = contents.substring( 149 result = contents.substring(
150 index, 150 index,
151 min(index + howMany, contents.length)); 151 min(index + howMany, contents.length));
152 } else { 152 } else {
153 // Assume List 153 // Assume List
154 result = contents.sublist(index, index + howMany); 154 result = contents.sublist(index, index + howMany);
155 } 155 }
156 return result; 156 return result;
(...skipping 30 matching lines...) Expand all
187 * can see and then return the corresponding integer. Advance the stream. 187 * can see and then return the corresponding integer. Advance the stream.
188 */ 188 */
189 var digitMatcher = new RegExp(r'\d+'); 189 var digitMatcher = new RegExp(r'\d+');
190 int nextInteger() { 190 int nextInteger() {
191 var string = digitMatcher.stringMatch(rest()); 191 var string = digitMatcher.stringMatch(rest());
192 if (string == null || string.isEmpty) return null; 192 if (string == null || string.isEmpty) return null;
193 read(string.length); 193 read(string.length);
194 return int.parse(string); 194 return int.parse(string);
195 } 195 }
196 } 196 }
OLDNEW
« no previous file with comments | « CHANGELOG.md ('k') | lib/src/intl/number_format.dart » ('j') | lib/src/intl/number_format.dart » ('J')

Powered by Google App Engine
This is Rietveld 408576698