chore: factor out Array.equals

Signed-off-by: Matej Focko <mfocko@redhat.com>
This commit is contained in:
Matej Focko 2022-05-07 16:53:04 +02:00
parent d709599ad9
commit fc1c9162d6
Signed by: mfocko
GPG key ID: 7C47D46246790496
3 changed files with 16 additions and 16 deletions

16
avl.js
View file

@ -1,19 +1,3 @@
// TODO: Factor out to common module
Array.prototype.equals = function (other) {
if (this.length != other.length) {
return false;
}
let i = this.length;
while (--i >= 0) {
if (this[i] !== other[i]) {
return false;
}
}
return true;
};
function balanceFactor(node) {
if (!node) {
return 0;

View file

@ -40,6 +40,8 @@
<script src="https://unpkg.com/@hpcc-js/wasm@0.3.11/dist/index.min.js"></script>
<script src="https://unpkg.com/d3-graphviz@3.0.5/build/d3-graphviz.js"></script>
<script src="utils.js"></script>
<script src="node.js"></script>
<script src="ranked_tree.js"></script>
<script src="avl.js"></script>

14
utils.js Normal file
View file

@ -0,0 +1,14 @@
Array.prototype.equals = function (other) {
if (this.length != other.length) {
return false;
}
let i = this.length;
while (--i >= 0) {
if (this[i] !== other[i]) {
return false;
}
}
return true;
};