| OLD | NEW |
| 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, 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 library stack_trace.src.utils; | |
| 6 | |
| 7 /// The line used in the string representation of stack chains to represent | 5 /// The line used in the string representation of stack chains to represent |
| 8 /// the gap between traces. | 6 /// the gap between traces. |
| 9 const chainGap = '===== asynchronous gap ===========================\n'; | 7 const chainGap = '===== asynchronous gap ===========================\n'; |
| 10 | 8 |
| 11 /// Returns [string] with enough spaces added to the end to make it [length] | 9 /// The line used in the string representation of VM stack chains to represent |
| 12 /// characters long. | 10 /// the gap between traces. |
| 13 String padRight(String string, int length) { | 11 const vmChainGap = '<asynchronous suspension>\n'; |
| 14 if (string.length >= length) return string; | |
| 15 | 12 |
| 16 var result = new StringBuffer(); | 13 // TODO(nweiz): When cross-platform imports work, use them to set this. |
| 17 result.write(string); | 14 /// Whether we're running in a JS context. |
| 18 for (var i = 0; i < length - string.length; i++) { | 15 final bool inJS = 0.0 is int; |
| 19 result.write(' '); | |
| 20 } | |
| 21 | |
| 22 return result.toString(); | |
| 23 } | |
| 24 | |
| 25 /// Flattens nested lists inside an iterable into a single list containing only | |
| 26 /// non-list elements. | |
| 27 List flatten(Iterable nested) { | |
| 28 var result = []; | |
| 29 helper(list) { | |
| 30 for (var element in list) { | |
| 31 if (element is List) { | |
| 32 helper(element); | |
| 33 } else { | |
| 34 result.add(element); | |
| 35 } | |
| 36 } | |
| 37 } | |
| 38 helper(nested); | |
| 39 return result; | |
| 40 } | |
| OLD | NEW |