Skip to content
This repository has been archived by the owner on Jul 22, 2020. It is now read-only.

Commit

Permalink
feat: use lodash find instead of array find (handle nulls)
Browse files Browse the repository at this point in the history
  • Loading branch information
sunnygleason committed Sep 12, 2019
1 parent 9ac88a3 commit a9780bc
Showing 1 changed file with 4 additions and 8 deletions.
12 changes: 4 additions & 8 deletions api/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -623,16 +623,12 @@ async function getClusterInfo() {
node.nodePubkey = nodePubkey;
node.voteAccount = voteAccount;
node.votePubkey = votePubkey;
node.identity = identities.find(x => x.pubkey === nodePubkey);
node.uptime =
uptime &&
uptime.find(x => {
return x.nodePubkey === nodePubkey;
});
node.identity = _.find(identities, x => x.pubkey === nodePubkey);
node.uptime = _.find(uptime, x => x.nodePubkey === nodePubkey);

node.voteStatus =
voteAccounts.current.find(x => x.nodePubkey === nodePubkey) ||
voteAccounts.delinquent.find(x => x.nodePubkey === nodePubkey);
_.find(voteAccounts.current, x => x.nodePubkey === nodePubkey) ||
_.find(voteAccounts.delinquent, x => x.nodePubkey === nodePubkey);
node.activatedStake = node.voteStatus && node.voteStatus.activatedStake;
node.commission = node.voteStatus && node.voteStatus.commission;
}
Expand Down

0 comments on commit a9780bc

Please sign in to comment.