Skip to content

Commit

Permalink
fix(isNumber): parse string parameter as number (allow string as para…
Browse files Browse the repository at this point in the history
…meter) (#444)

Co-authored-by: Jeroen Claassens <jeroen.claassens@live.nl>
  • Loading branch information
sawa-ko and favna committed Sep 2, 2022
1 parent 6ecbf3f commit 01e1b14
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion packages/utilities/src/lib/isNumber.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,6 @@
* @param input The number to verify
*/
export function isNumber(input: unknown): input is number {
return typeof input === 'number' && !isNaN(input) && Number.isFinite(input);
if (typeof input === 'string') input = Number(input);
return typeof input === 'number' && !Number.isNaN(input) && Number.isFinite(input);
}

0 comments on commit 01e1b14

Please sign in to comment.