| OLD | NEW |
| 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'; | 10 import 'dart:crypto'; |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 112 for (var match in matcher.allMatches(str)) { | 112 for (var match in matcher.allMatches(str)) { |
| 113 if (match.end() == str.length) return true; | 113 if (match.end() == str.length) return true; |
| 114 } | 114 } |
| 115 return false; | 115 return false; |
| 116 } | 116 } |
| 117 | 117 |
| 118 /** | 118 /** |
| 119 * Returns the hex-encoded sha1 hash of [source]. | 119 * Returns the hex-encoded sha1 hash of [source]. |
| 120 */ | 120 */ |
| 121 String sha1(String source) => | 121 String sha1(String source) => |
| 122 CryptoUtils.bytesToHex(new SHA1().update(source.charCodes()).digest()); | 122 CryptoUtils.bytesToHex(new SHA1().update(source.charCodes).digest()); |
| 123 | 123 |
| 124 /** | 124 /** |
| 125 * Returns a [Future] that completes in [milliSeconds]. | 125 * Returns a [Future] that completes in [milliSeconds]. |
| 126 */ | 126 */ |
| 127 Future sleep(int milliSeconds) { | 127 Future sleep(int milliSeconds) { |
| 128 var completer = new Completer(); | 128 var completer = new Completer(); |
| 129 new Timer(milliSeconds, completer.complete); | 129 new Timer(milliSeconds, completer.complete); |
| 130 return completer.future; | 130 return completer.future; |
| 131 } | 131 } |
| OLD | NEW |