UNPKG

1.25 kBJavaScriptView Raw
1import dpi from './dpi';
2export function isEqual(value, other) {
3 if (value === other)
4 return true;
5 if (value === null || value === undefined)
6 return false;
7 if (typeof value === 'number' && isNaN(value))
8 return typeof other === 'number' && isNaN(other);
9 // 数组
10 if (Array.isArray(value)) {
11 if (!Array.isArray(other))
12 return false;
13 if (value.length !== other.length)
14 return false;
15 while (value.length) {
16 const index = other.findIndex(other => isEqual(value[0], other));
17 if (index === -1)
18 return false;
19 value.splice(0, 1);
20 other.splice(index, 1);
21 }
22 return true;
23 }
24 // 对象
25 if (typeof value === 'object') {
26 if (typeof other !== 'object' || Array.isArray(other))
27 return false;
28 if (Object.keys(value).length !== Object.keys(other).length)
29 return false;
30 let isTrue = true;
31 Object.keys(value).forEach((key) => {
32 isTrue = isTrue && isEqual(value[key], other[key]);
33 });
34 return isTrue;
35 }
36 return false;
37}
38export function noop() { }
39export { dpi, };
40//# sourceMappingURL=index.js.map
\No newline at end of file