| Index: utils/pub/utils.dart
|
| diff --git a/utils/pub/utils.dart b/utils/pub/utils.dart
|
| index cf9b456164996497779c7f188c998c36d4d84b75..39c86dfa274c5b42f403da69618b84c3f92a7bb7 100644
|
| --- a/utils/pub/utils.dart
|
| +++ b/utils/pub/utils.dart
|
| @@ -18,4 +18,35 @@ String padRight(String source, int length) {
|
| }
|
|
|
| return result.toString();
|
| -}
|
| +}
|
| +
|
| +/**
|
| + * Runs [fn] after [future] completes, whether it completes successfully or not.
|
| + * Essentially an asynchronous `finally` block.
|
| + */
|
| +always(Future future, fn()) {
|
| + var completer = new Completer();
|
| + future.then((_) => fn());
|
| + future.handleException((_) {
|
| + fn();
|
| + return false;
|
| + });
|
| +}
|
| +
|
| +/**
|
| + * Flattens nested lists into a single list containing only non-list elements.
|
| + */
|
| +List flatten(List nested) {
|
| + var result = [];
|
| + helper(list) {
|
| + for (var element in list) {
|
| + if (element is List) {
|
| + helper(element);
|
| + } else {
|
| + result.add(element);
|
| + }
|
| + }
|
| + }
|
| + helper(nested);
|
| + return result;
|
| +}
|
|
|