Index: lib/src/utils.dart |
diff --git a/lib/src/utils.dart b/lib/src/utils.dart |
index 7793d3084deaa94f9493ecd1f7b64039ea32b181..4516351a9bbe2bf943a8d4b512363611ed8a3d90 100644 |
--- a/lib/src/utils.dart |
+++ b/lib/src/utils.dart |
@@ -189,6 +189,19 @@ Map mergeMaps(Map map1, Map map2) { |
return result; |
} |
+/// Returns a new list with all elements in both [list1] and [list2]. |
+/// |
+/// If an element exists in both lists, it is listed only once in the result. |
+List mergeLists(List list1, List list2) { |
+ var result = []..addAll(list1); |
+ list2.forEach((element) { |
+ if (!result.contains(element)) { |
+ result.add(element); |
+ } |
+ }); |
+ return result; |
+} |
+ |
/// Returns a sink that maps events sent to [original] using [fn]. |
StreamSink mapSink(StreamSink original, fn(event)) { |
var controller = new StreamController(sync: true); |
@@ -403,3 +416,9 @@ shelf.Middleware nestingMiddleware(String beneath) { |
return pathHandler.handler; |
}; |
} |
+ |
+/// Returns `true` iff [a] and [b] are both not null and share at least one |
+/// element. |
+bool intersect(Iterable a, Iterable b) { |
+ return a != null && b != null && a.any(b.contains); |
+} |