Skip to content

Commit

Permalink
feat: ignore empty arr
Browse files Browse the repository at this point in the history
  • Loading branch information
cool-firer committed Jul 24, 2024
1 parent daf920b commit 5baae00
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions packages/network-support/src/utils/score.ts
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ function getMedian(arr: number[]) {
}

export function calculateBigIntPercentile(arr: BigNumber[], percentile: number): BigNumber {
if (arr.length === 0) return new BigNumber(0);
const sortedArr = arr.slice().sort((a, b) => (a.lt(b) ? -1 : 1));
// const sortedArr = arr.slice().sort((a, b) => (a < b ? -1 : 1));
const index = Math.floor((percentile / 100) * (sortedArr.length - 1) + 0.5);
Expand Down

0 comments on commit 5baae00

Please sign in to comment.