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

Side by Side Diff: utils/pub/utils.dart

Issue 10695132: Reverting 9527 (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 5 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 | « utils/pub/system_cache.dart ('k') | utils/tests/pub/pub_test.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 /** 5 /**
6 * Generic utility functions. Stuff that should possibly be in core. 6 * Generic utility functions. Stuff that should possibly be in core.
7 */ 7 */
8 #library('utils'); 8 #library('utils');
9 9
10 #import('dart:crypto');
11
12 /** Thrown by methods that parse text when the text isn't a valid. */ 10 /** Thrown by methods that parse text when the text isn't a valid. */
13 class FormatException implements Exception { 11 class FormatException implements Exception {
14 final String message; 12 final String message;
15 13
16 FormatException(this.message); 14 FormatException(this.message);
17 15
18 String toString() => message; 16 String toString() => message;
19 } 17 }
20 18
21 /** A pair of values. */ 19 /** A pair of values. */
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
105 103
106 /** 104 /**
107 * Returns whether or not [str] ends with [matcher]. 105 * Returns whether or not [str] ends with [matcher].
108 */ 106 */
109 bool endsWithPattern(String str, Pattern matcher) { 107 bool endsWithPattern(String str, Pattern matcher) {
110 for (var match in matcher.allMatches(str)) { 108 for (var match in matcher.allMatches(str)) {
111 if (match.end() == str.length) return true; 109 if (match.end() == str.length) return true;
112 } 110 }
113 return false; 111 return false;
114 } 112 }
115
116 /**
117 * Returns the hex-encoded sha1 hash of [source].
118 */
119 String sha1(String source) =>
120 CryptoUtils.bytesToHex(new SHA1().update(source.charCodes()).digest());
OLDNEW
« no previous file with comments | « utils/pub/system_cache.dart ('k') | utils/tests/pub/pub_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698