[gnome-maps] transitOptions: Add function to test two objects for equality
- From: Marcus Lundblad <mlundblad src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-maps] transitOptions: Add function to test two objects for equality
- Date: Tue, 30 May 2017 20:55:29 +0000 (UTC)
commit 2357178a1f646a5cd1cf849b1e19de235b6b8288
Author: Marcus Lundblad <ml update uu se>
Date: Wed May 24 23:10:25 2017 +0200
transitOptions: Add function to test two objects for equality
Add a function to test if two TransitOption objects are equal.
Either if both are set to accept any type, or if they contain the same
set of types, consider them equal, otherwise not.
https://bugzilla.gnome.org/show_bug.cgi?id=783009
src/transitOptions.js | 19 +++++++++++++++++++
1 files changed, 19 insertions(+), 0 deletions(-)
---
diff --git a/src/transitOptions.js b/src/transitOptions.js
index db88861..27bc09a 100644
--- a/src/transitOptions.js
+++ b/src/transitOptions.js
@@ -52,3 +52,22 @@ const TransitOptions = new Lang.Class({
return this._transitTypes;
}
});
+
+/* return true if the passed in options objects are equal, either both
+ * accept any transit type, or both contains the same set of types, otherwise
+ * return false
+ */
+function equals(first, second) {
+ if (first.showAllTransitTypes && second.showAllTransitTypes) {
+ return true;
+ } else if (first.transitTypes.length !== second.transitTypes.length) {
+ return false;
+ } else {
+ for (let type of first.transitTypes) {
+ if (second.transitTypes.indexOf(type) === -1)
+ return false;
+ }
+
+ return true;
+ }
+}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]