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 /// Generic utility functions. Stuff that should possibly be in core. | 5 /// Generic utility functions. Stuff that should possibly be in core. |
6 library utils; | 6 library utils; |
7 | 7 |
8 import 'dart:async'; | 8 import 'dart:async'; |
9 import 'dart:crypto'; | 9 import 'dart:crypto'; |
10 import 'dart:isolate'; | 10 import 'dart:isolate'; |
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
176 | 176 |
177 /// Add all key/value pairs from [source] to [destination], overwriting any | 177 /// Add all key/value pairs from [source] to [destination], overwriting any |
178 /// pre-existing values. | 178 /// pre-existing values. |
179 void mapAddAll(Map destination, Map source) => | 179 void mapAddAll(Map destination, Map source) => |
180 source.forEach((key, value) => destination[key] = value); | 180 source.forEach((key, value) => destination[key] = value); |
181 | 181 |
182 /// Decodes a URL-encoded string. Unlike [decodeUriComponent], this includes | 182 /// Decodes a URL-encoded string. Unlike [decodeUriComponent], this includes |
183 /// replacing `+` with ` `. | 183 /// replacing `+` with ` `. |
184 String urlDecode(String encoded) => | 184 String urlDecode(String encoded) => |
185 decodeUriComponent(encoded.replaceAll("+", " ")); | 185 decodeUriComponent(encoded.replaceAll("+", " ")); |
186 | |
187 /// When an error is rethrown in an async callback, you can end up with nested | |
188 /// AsyncErrors. This unwraps them to find the real originating error. | |
189 // TODO(rnystrom): Remove this when #7781 is fixed. | |
nweiz
2013/01/08 23:05:13
Nit: I usually put TODOs above dartdoc comments. I
Bob Nystrom
2013/01/08 23:07:23
Done.
| |
190 getRealError(error) { | |
191 while (error != null && error is AsyncError) { | |
nweiz
2013/01/08 23:05:13
"error != null" is unnecessary here. null isn't an
Bob Nystrom
2013/01/08 23:07:23
Done.
| |
192 error = error.error; | |
193 } | |
194 | |
195 return error; | |
196 } | |
OLD | NEW |