diff --git a/src/graphEntry.ts b/src/graphEntry.ts index 56c18eb..e1eb43d 100644 --- a/src/graphEntry.ts +++ b/src/graphEntry.ts @@ -513,6 +513,8 @@ 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; + if (itemsDup.length === 1) return itemsDup[0][1]; 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