Press n or j to go to the next uncovered block, b, p or k for the previous block.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 | 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 6x 6x 1x 1x 1165x 1165x 952x 952x 952x 1165x 213x 213x 156x 156x 213x 28x 28x 213x 29x 29x 213x 213x 213x 1165x 1165x 1x 1x 1891x 1891x 1863x 698x 698x 698x 686x 686x 686x 1746x 1740x 1740x 32x 32x 32x 1746x 6x 6x 6x 1746x 698x 12x 12x 1863x 1165x 1165x 1891x 28x 28x 1891x 1891x 1x 1x | /**
* Copyright © 2020 2021 2022 7thCode.(http://seventh-code.com/)
* This software is released under the MIT License.
* opensource.org/licenses/mit-license.php
*/
"use strict";
import {isType, isValue, isContainer} from "./base";
/**
* Handler
*
* @remarks
* 値が同一か?
*
* @param s
* @param d
* @returns boolean
*
*/
export abstract class DetectHandler {
abstract compare(s: any, d: any): boolean;
}
export class StructDiff {
private handler: DetectHandler | null;
constructor(handler: DetectHandler | null = null) {
this.handler = handler;
}
private isSameValue(s: any, d: any, comp_type: number): boolean {
let result = true;
if (this.handler) {
if (this.handler.compare) {
result = this.handler.compare(s, d);
}
} else {
switch (comp_type) {
case 0:
result = (isType(s) === isType(d));
break;
case 1:
result = (s === d);
break;
case 2:
result = true;
break;
default:
}
}
return result;
}
public isSame(s: any, d: any, comp_type: number = 0): boolean {
let result = true;
if ((isValue(s)) && (isValue(d))) {
if ((isContainer(s)) && (isContainer(d))) {
const attrs_s = Object.keys(s);
const attrs_d = Object.keys(d);
if (attrs_s.length === attrs_d.length) {
attrs_s.sort();
attrs_d.sort();
for (let index = 0; index < attrs_s.length; index++) {
if (attrs_s[index] === attrs_d[index]) {
let attr = attrs_s[index];
if (!(this.isSame(s[attr], d[attr], comp_type))) {
result = false;
break;
}
} else {
result = false;
break;
}
}
} else {
result = false;
}
} else {
result = this.isSameValue(s, d, comp_type);
}
} else {
result = false;
}
return result;
}
}
|