Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Add a new ‘isEqual’ util

  • Loading branch information...
commit 3745de4b82be7c2721c0d2f586ac87e5d0bd0cb7 1 parent b41eb02
František Hába authored
Showing with 48 additions and 0 deletions.
  1. +48 −0 src/utils/isEqual.js
48 src/utils/isEqual.js
View
@@ -0,0 +1,48 @@
+/**
+ * IsEqual
+ *
+ * @param {object} obj1
+ * @param {object} obj2
+ */
+var isEqual = function(obj1, obj2) {
+
+ /**
+ * Arrays
+ */
+ if (isArray(obj1, obj2)) {
+
+ if (arr1.length !== arr2.length) {
+ return false;
+ }
+
+ return every(arr1, function(value, index, context) {
+ return arr2[index] === value;
+ });
+
+ }
+
+ /**
+ * Objects
+ */
+ if (isObject(obj1, obj2)) {
+
+ var keys1 = keys(obj1),
+ keys2 = keys(obj2);
+
+ if (!isEqual(keys1, keys2)) {
+ return false;
+ }
+
+ for (key in obj1) {
+ if (!obj2[key] || obj1[key] !== obj2[key]) {
+ return false;
+ }
+ }
+
+ return true;
+
+ }
+
+ return false;
+
+};
Please sign in to comment.
Something went wrong with that request. Please try again.