Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(374)

Unified Diff: pkg/shelf/lib/src/util.dart

Issue 256753004: pkg/shelf: change helper method on Request and Response (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: nevermind Created 6 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « pkg/shelf/lib/src/shelf_unmodifiable_map.dart ('k') | pkg/shelf/test/message_change_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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);
+}
« no previous file with comments | « pkg/shelf/lib/src/shelf_unmodifiable_map.dart ('k') | pkg/shelf/test/message_change_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698