@@ -712,6 +712,33 @@ const deleteAttribute = async (collection, attribute, isIndex = false) => {
712
712
});
713
713
}
714
714
715
+ const isEqual = (a, b) => {
716
+ if (a === b) return true;
717
+
718
+ if (a && b && typeof a === 'object' && typeof b === 'object') {
719
+ if (a.constructor && a.constructor.name === 'BigNumber' &&
720
+ b.constructor && b.constructor.name === 'BigNumber') {
721
+ return a.eq(b);
722
+ }
723
+
724
+ if (typeof a.equals === 'function') {
725
+ return a.equals(b);
726
+ }
727
+
728
+ if (typeof a.eq === 'function') {
729
+ return a.eq(b);
730
+ }
731
+ }
732
+
733
+ if (typeof a === 'number' && typeof b === 'number') {
734
+ if (isNaN(a) && isNaN(b)) return true;
735
+ if (!isFinite(a) && !isFinite(b)) return a === b;
736
+ return Math.abs(a - b) < Number.EPSILON;
737
+ }
738
+
739
+ return false;
740
+ };
741
+
715
742
const compareAttribute = (remote, local, reason, key) => {
716
743
if (isEmpty(remote) && isEmpty(local)) {
717
744
return reason;
@@ -722,7 +749,7 @@ const compareAttribute = (remote, local, reason, key) => {
722
749
const bol = reason === '' ? '' : '\n';
723
750
reason += `${bol}${key} changed from ${chalk.red(remote)} to ${chalk.green(local)}`;
724
751
}
725
- } else if (remote !== local) {
752
+ } else if (!isEqual( remote, local) ) {
726
753
const bol = reason === '' ? '' : '\n';
727
754
reason += `${bol}${key} changed from ${chalk.red(remote)} to ${chalk.green(local)}`;
728
755
}
0 commit comments