Index: pkg/shelf/lib/src/util.dart |
diff --git a/pkg/shelf/lib/src/util.dart b/pkg/shelf/lib/src/util.dart |
index 43f7238910aec1b91e38370fa37b8ef143307855..bb4847c4872f07d61f191a66a9ef2d775427f87f 100644 |
--- a/pkg/shelf/lib/src/util.dart |
+++ b/pkg/shelf/lib/src/util.dart |
@@ -23,3 +23,17 @@ catchTopLevelErrors(callback(), void onError(error, StackTrace stackTrace)) { |
return callback(); |
} |
} |
+ |
+/// Returns a [Map] with the values from [original] and the values from |
+/// [updates]. |
+/// |
+/// For keys that are the same between [original] and [updates], the value in |
+/// [updates] is used. |
+/// |
+/// If [updates] is `null` or empty, [original] is returned unchanged. |
+Map updateMap(Map original, Map updates) { |
+ if (updates == null || updates.isEmpty) return original; |
+ |
+ return new Map.from(original) |
+ ..addAll(updates); |
+} |