Skip to content

Commit

Permalink
Add empty array check to centredMovingAvg func
Browse files Browse the repository at this point in the history
  • Loading branch information
braddf committed Jul 14, 2023
1 parent 0ba2195 commit 82e0fba
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions lib/graphs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,9 @@ export const calculateCenteredMovingAverage = (
points: GenerationDataPoint[],
period: number
): GenerationDataPoint[] => {
if (points.length === 0) {
return [];
}
if (period % 2 == 0) {
throw new Error('Period must be an odd number');
} else if (period > points.length) {
Expand Down

0 comments on commit 82e0fba

Please sign in to comment.