Skip to content

Commit

Permalink
_median function fails if receive empty table.
Browse files Browse the repository at this point in the history
  • Loading branch information
lukasztackowiak committed Mar 24, 2022
1 parent 4d72937 commit ae37b97
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions src/graphEntry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -512,6 +512,7 @@ export default class GraphEntry {
private _median(items: EntityCachePoints) {
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
const itemsDup = this._filterNulls([...items]).sort((a, b) => a[1]! - b[1]!);
if (itemsDup.length === 0) return null;
const mid = Math.floor((itemsDup.length - 1) / 2);
if (itemsDup.length % 2 === 1) return itemsDup[mid][1];
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
Expand Down

0 comments on commit ae37b97

Please sign in to comment.