findIndex optimization
This commit is contained in:
parent
523094bdc8
commit
3d95212b1d
@ -139,8 +139,7 @@ class MerkleTree {
|
|||||||
*/
|
*/
|
||||||
indexOf(element, comparator) {
|
indexOf(element, comparator) {
|
||||||
if (comparator) {
|
if (comparator) {
|
||||||
const result = this._layers[0].findIndex((el) => comparator(element, el))
|
return this._layers[0].findIndex((el) => comparator(element, el))
|
||||||
return result === undefined ? -1 : result
|
|
||||||
} else {
|
} else {
|
||||||
return this._layers[0].indexOf(element)
|
return this._layers[0].indexOf(element)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user