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'); |
11 #import('dart:isolate'); | 11 #import('dart:isolate'); |
12 | 12 |
13 /** Thrown by methods that parse text when the text isn't a valid. */ | |
14 class FormatException implements Exception { | |
15 final String message; | |
16 | |
17 FormatException(this.message); | |
18 | |
19 String toString() => message; | |
20 } | |
21 | |
22 /** A pair of values. */ | 13 /** A pair of values. */ |
23 class Pair<E, F> { | 14 class Pair<E, F> { |
24 E first; | 15 E first; |
25 F last; | 16 F last; |
26 | 17 |
27 Pair(this.first, this.last); | 18 Pair(this.first, this.last); |
28 | 19 |
29 String toString() => '($first, $last)'; | 20 String toString() => '($first, $last)'; |
30 | 21 |
31 bool operator==(other) { | 22 bool operator==(other) { |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
121 CryptoUtils.bytesToHex(new SHA1().update(source.charCodes()).digest()); | 112 CryptoUtils.bytesToHex(new SHA1().update(source.charCodes()).digest()); |
122 | 113 |
123 /** | 114 /** |
124 * Returns a [Future] that completes in [milliSeconds]. | 115 * Returns a [Future] that completes in [milliSeconds]. |
125 */ | 116 */ |
126 Future sleep(int milliSeconds) { | 117 Future sleep(int milliSeconds) { |
127 var completer = new Completer(); | 118 var completer = new Completer(); |
128 new Timer(milliSeconds, completer.complete); | 119 new Timer(milliSeconds, completer.complete); |
129 return completer.future; | 120 return completer.future; |
130 } | 121 } |
OLD | NEW |