forked from Meituan-Dianping/mpvue
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#2: Added 'generateSetDataPatch' function & supported multiple vm ins…
…tances
- Loading branch information
Showing
2 changed files
with
244 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
/* eslint-disable */ | ||
const isArray = Array.isArray | ||
const keyList = Object.keys | ||
const hasProp = Object.prototype.hasOwnProperty | ||
|
||
/** | ||
* @source: https://github.com/epoberezkin/fast-deep-equal | ||
*/ | ||
export default function equal (a, b) { | ||
if (a === b) return true | ||
|
||
var arrA = isArray(a), | ||
arrB = isArray(b), | ||
i, | ||
length, | ||
key | ||
|
||
if (arrA && arrB) { | ||
length = a.length | ||
if (length != b.length) return false | ||
for (i = 0; i < length; i++) { if (!equal(a[i], b[i])) return false } | ||
return true | ||
} | ||
|
||
if (arrA != arrB) return false | ||
|
||
var dateA = a instanceof Date, | ||
dateB = b instanceof Date | ||
if (dateA != dateB) return false | ||
if (dateA && dateB) return a.getTime() == b.getTime() | ||
|
||
var regexpA = a instanceof RegExp, | ||
regexpB = b instanceof RegExp | ||
if (regexpA != regexpB) return false | ||
if (regexpA && regexpB) return a.toString() == b.toString() | ||
|
||
if (a instanceof Object && b instanceof Object) { | ||
var keys = keyList(a) | ||
length = keys.length | ||
|
||
if (length !== keyList(b).length) { return false } | ||
|
||
for (i = 0; i < length; i++) { if (!hasProp.call(b, keys[i])) return false } | ||
|
||
for (i = 0; i < length; i++) { | ||
key = keys[i] | ||
if (!equal(a[key], b[key])) return false | ||
} | ||
|
||
return true | ||
} | ||
|
||
return false | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters