Skip to content

Commit 46563f5

Browse files
Restrict isNumber to finite numbers
Because `NaN` and Infinity are not representable in JSON. Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
1 parent 2a939e7 commit 46563f5

1 file changed

Lines changed: 1 addition & 2 deletions

File tree

src/json/index.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,8 @@ export function isString(value: unknown): value is string {
3030
return typeof value === "string";
3131
}
3232

33-
/** Asserts that `value` is a number. */
3433
export function isNumber(value: unknown): value is number {
35-
return typeof value === "number";
34+
return typeof value === "number" && Number.isFinite(value);
3635
}
3736

3837
/** Asserts that `value` is either a string or undefined. */

0 commit comments

Comments
 (0)