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 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
170 | 170 |
171 /// Add all key/value pairs from [source] to [destination], overwriting any | 171 /// Add all key/value pairs from [source] to [destination], overwriting any |
172 /// pre-existing values. | 172 /// pre-existing values. |
173 void mapAddAll(Map destination, Map source) => | 173 void mapAddAll(Map destination, Map source) => |
174 source.forEach((key, value) => destination[key] = value); | 174 source.forEach((key, value) => destination[key] = value); |
175 | 175 |
176 /// Decodes a URL-encoded string. Unlike [decodeUriComponent], this includes | 176 /// Decodes a URL-encoded string. Unlike [decodeUriComponent], this includes |
177 /// replacing `+` with ` `. | 177 /// replacing `+` with ` `. |
178 String urlDecode(String encoded) => | 178 String urlDecode(String encoded) => |
179 decodeUriComponent(encoded.replaceAll("+", " ")); | 179 decodeUriComponent(encoded.replaceAll("+", " ")); |
180 | |
181 // TODO(rnystrom): Remove this when #7781 is fixed. | |
182 /// When an error is rethrown in an async callback, you can end up with nested | |
183 /// AsyncErrors. This unwraps them to find the real originating error. | |
184 getRealError(error) { | |
185 while (error is AsyncError) { | |
186 error = error.error; | |
187 } | |
188 | |
189 return error; | |
190 } | |
191 | |
192 // TODO(nweiz): Remove this when #7781 is fixed. | |
193 /// When an error is rethrown in an async callback, you can end up with nested | |
194 /// AsyncErrors. This unwraps them to find the real originating stack trace. | |
195 getRealStackTrace(error) { | |
196 var trace = null; | |
197 while (error is AsyncError) { | |
198 trace = error.stackTrace; | |
199 error = error.error; | |
200 } | |
201 | |
202 return trace; | |
203 } | |
OLD | NEW |