Index: pkg/barback/lib/src/utils.dart |
diff --git a/pkg/barback/lib/src/utils.dart b/pkg/barback/lib/src/utils.dart |
index f1bcddde7f45085a1e977c5c1d5b03ea1653f07f..59c9d4b5375c16ff80c9d5b91cd8378da7e21284 100644 |
--- a/pkg/barback/lib/src/utils.dart |
+++ b/pkg/barback/lib/src/utils.dart |
@@ -140,10 +140,24 @@ List flatten(Iterable nested) { |
Set unionAll(Iterable<Set> sets) => |
sets.fold(new Set(), (union, set) => union.union(set)); |
-/// Passes each key/value pair in [map] to [fn] and returns a new [Map] whose |
-/// values are the return values of [fn]. |
-Map mapMapValues(Map map, fn(key, value)) => |
- new Map.fromIterable(map.keys, value: (key) => fn(key, map[key])); |
+/// Creates a new map from [map] with new keys and values. |
+/// |
+/// The return values of [keyFn] are used as the keys and the return values of |
+/// [valueFn] are used as the values for the new map. |
+Map mapMap(Map map, keyFn(key, value), valueFn(key, value)) => |
+ new Map.fromIterable(map.keys, |
+ key: (key) => keyFn(key, map[key]), |
+ value: (key) => valueFn(key, map[key])); |
+ |
+/// Creates a new map from [map] with the same keys. |
+/// |
+/// The return values of [fn] are used as the values for the new map. |
+Map mapMapValues(Map map, fn(key, value)) => mapMap(map, (key, _) => key, fn); |
+ |
+/// Creates a new map from [map] with the same keys. |
+/// |
+/// The return values of [fn] are used as the keys for the new map. |
+Map mapMapKeys(Map map, fn(key, value)) => mapMap(map, fn, (_, value) => value); |
/// Returns whether [set1] has exactly the same elements as [set2]. |
bool setEquals(Set set1, Set set2) => |