Skip to content

Commit

Permalink
fest: check if initial value returned by the function is a number
Browse files Browse the repository at this point in the history
closes: #27
  • Loading branch information
lpatiny committed Oct 22, 2024
1 parent 6e10541 commit f8a4c20
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,11 @@ export function direct(
smallerValuesByDistance = [bestCurrentValue],
choiceLimit = undefined,
} = initialState;

if (typeof bestCurrentValue !== 'number' || Number.isNaN(bestCurrentValue)) {
throw new Error('The initial value is not a number');
}

if (
initialState.originalCoordinates &&
initialState.originalCoordinates.length > 0
Expand Down

0 comments on commit f8a4c20

Please sign in to comment.