@atomist/rug
Version:
TypeScript model for Atomist Rugs, see http://docs.atomist.com/
26 lines (25 loc) • 679 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
/**
* Check whether two nodes are structurally equivalent
*/
function structurallyEquivalent(a, b) {
if (a.nodeName() !== b.nodeName()) {
return false;
}
if (a.children().length !== b.children().length) {
return false;
}
if (a.value() === b.value()) {
return true;
}
for (var i = 0; i < a.children().length; i++) {
var ax = a.children()[i];
var bx = b.children()[i];
if (!structurallyEquivalent(ax, bx)) {
return false;
}
}
return true;
}
exports.structurallyEquivalent = structurallyEquivalent;