| Index: pkg/serialization/lib/src/serialization_helpers.dart
|
| diff --git a/pkg/serialization/lib/src/serialization_helpers.dart b/pkg/serialization/lib/src/serialization_helpers.dart
|
| index 335bc0d475297ba09bd3af5e05b55c6cba057237..407c6562d2b765f6c5c5553e9f6e371672b3196b 100644
|
| --- a/pkg/serialization/lib/src/serialization_helpers.dart
|
| +++ b/pkg/serialization/lib/src/serialization_helpers.dart
|
| @@ -18,7 +18,7 @@ doNothing(x) => x;
|
|
|
| /** Concatenate two lists. Handle the case where one or both might be null. */
|
| // TODO(alanknight): Remove once issue 5342 is resolved.
|
| -List append(List a, List b) {
|
| +List append(Iterable a, Iterable b) {
|
| if (a == null) {
|
| return (b == null) ? [] : new List.from(b);
|
| }
|
| @@ -29,11 +29,11 @@ List append(List a, List b) {
|
| }
|
|
|
| /**
|
| - * Return a sorted version of [aCollection], using the default sort criterion.
|
| - * Always returns a List, regardless of the type of [aCollection].
|
| + * Return a sorted version of [anIterable], using the default sort criterion.
|
| + * Always returns a List, regardless of the type of [anIterable].
|
| */
|
| -List sorted(aCollection) {
|
| - var result = new List.from(aCollection);
|
| +List sorted(anIterable) {
|
| + var result = new List.from(anIterable);
|
| result.sort();
|
| return result;
|
| }
|
| @@ -105,9 +105,10 @@ class MapLikeIterableForList extends MapLikeIterable {
|
| MapLikeIterableForList(collection) : super(collection);
|
|
|
| void forEach(f) {
|
| - Iterator iterator = collection.iterator();
|
| + Iterator iterator = collection.iterator;
|
| for (var i = 0; i < collection.length; i++) {
|
| - f(i, iterator.next());
|
| + iterator.moveNext();
|
| + f(i, iterator.current);
|
| }
|
| }
|
|
|
| @@ -129,6 +130,13 @@ values(x) {
|
| throw new ArgumentError("Invalid argument");
|
| }
|
|
|
| +mapValues(x, f) {
|
| + if (x is Set) return x.mappedBy(f).toSet();
|
| + if (x is Iterable) return x.mappedBy(f).toList();
|
| + if (x is Map) return new ListLikeIterable(x).map(f);
|
| + throw new ArgumentError("Invalid argument");
|
| +}
|
| +
|
| /**
|
| * A class for iterating over things as if they were Lists, which primarily
|
| * means that forEach passes one argument, and map() returns a new Map
|
| @@ -159,7 +167,7 @@ class ListLikeIterable {
|
| /**
|
| * Return an iterator that behaves like a List iterator, taking one parameter.
|
| */
|
| - Iterator iterator() => collection.values.iterator();
|
| + Iterator get iterator => collection.values.iterator;
|
| }
|
|
|
| /**
|
|
|