findIndex optimization

This commit is contained in:
Alexey 2020-08-06 18:04:08 +03:00
parent 523094bdc8
commit 3d95212b1d

View File

@ -139,8 +139,7 @@ class MerkleTree {
*/
indexOf(element, comparator) {
if (comparator) {
const result = this._layers[0].findIndex((el) => comparator(element, el))
return result === undefined ? -1 : result
return this._layers[0].findIndex((el) => comparator(element, el))
} else {
return this._layers[0].indexOf(element)
}