move deepEqual next to deepCopy
This commit is contained in:
parent
415c218863
commit
7b0b4f0850
|
@ -1,5 +1,5 @@
|
|||
/* global regExpTester debounce messageBox CodeMirror template colorMimicry msg
|
||||
$ $create t prefs tryCatch */
|
||||
$ $create t prefs tryCatch deepEqual */
|
||||
/* exported createAppliesToLineWidget */
|
||||
'use strict';
|
||||
|
||||
|
@ -574,30 +574,6 @@ function createAppliesToLineWidget(cm) {
|
|||
return hasSingleEscapes ? s : s.replace(/\\\\/g, '\\');
|
||||
}
|
||||
|
||||
function deepEqual(a, b, ignoredKeys) {
|
||||
if (!a || !b) return a === b;
|
||||
const type = typeof a;
|
||||
if (type !== typeof b) return false;
|
||||
if (type !== 'object') return a === b;
|
||||
if (Array.isArray(a)) {
|
||||
return Array.isArray(b) &&
|
||||
a.length === b.length &&
|
||||
a.every((v, i) => deepEqual(v, b[i], ignoredKeys));
|
||||
}
|
||||
for (const key in a) {
|
||||
if (!Object.hasOwnProperty.call(a, key) ||
|
||||
ignoredKeys && ignoredKeys.includes(key)) continue;
|
||||
if (!Object.hasOwnProperty.call(b, key)) return false;
|
||||
if (!deepEqual(a[key], b[key], ignoredKeys)) return false;
|
||||
}
|
||||
for (const key in b) {
|
||||
if (!Object.hasOwnProperty.call(b, key) ||
|
||||
ignoredKeys && ignoredKeys.includes(key)) continue;
|
||||
if (!Object.hasOwnProperty.call(a, key)) return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
function showRegExpTester(item) {
|
||||
regExpTester.toggle(true);
|
||||
regExpTester.update(
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/* exported getActiveTab onTabReady stringAsRegExp getTabRealURL openURL
|
||||
getStyleWithNoCode tryRegExp sessionStorageHash download
|
||||
getStyleWithNoCode tryRegExp sessionStorageHash download deepEqual
|
||||
closeCurrentTab */
|
||||
'use strict';
|
||||
|
||||
|
@ -357,6 +357,31 @@ function deepCopy(obj) {
|
|||
}
|
||||
|
||||
|
||||
function deepEqual(a, b, ignoredKeys) {
|
||||
if (!a || !b) return a === b;
|
||||
const type = typeof a;
|
||||
if (type !== typeof b) return false;
|
||||
if (type !== 'object') return a === b;
|
||||
if (Array.isArray(a)) {
|
||||
return Array.isArray(b) &&
|
||||
a.length === b.length &&
|
||||
a.every((v, i) => deepEqual(v, b[i], ignoredKeys));
|
||||
}
|
||||
for (const key in a) {
|
||||
if (!Object.hasOwnProperty.call(a, key) ||
|
||||
ignoredKeys && ignoredKeys.includes(key)) continue;
|
||||
if (!Object.hasOwnProperty.call(b, key)) return false;
|
||||
if (!deepEqual(a[key], b[key], ignoredKeys)) return false;
|
||||
}
|
||||
for (const key in b) {
|
||||
if (!Object.hasOwnProperty.call(b, key) ||
|
||||
ignoredKeys && ignoredKeys.includes(key)) continue;
|
||||
if (!Object.hasOwnProperty.call(a, key)) return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
function sessionStorageHash(name) {
|
||||
return {
|
||||
name,
|
||||
|
|
Loading…
Reference in New Issue
Block a user