This repository has been archived by the owner on Jul 5, 2024. It is now read-only.
generated from JoshuaKGoldberg/create-typescript-app
-
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
14 changed files
with
164 additions
and
162 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
export function isComplexValue(arg: unknown): arg is object { | ||
return arg !== null && (typeof arg === "object" || typeof arg === "function"); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,22 @@ | ||
import { tsonAssert } from "../../tsonAssert.js"; | ||
import { TsonGuard } from "../../tsonAssert.js"; | ||
|
||
/** | ||
* Prevents `NaN` and `Infinity` from being serialized | ||
*/ | ||
|
||
export const tsonAssertNotInfinite = tsonAssert((v) => { | ||
if (typeof v !== "number") { | ||
return; | ||
} | ||
export const tsonNumberGuard: TsonGuard<Exclude<unknown, number>> = { | ||
assert(v: unknown) { | ||
if (typeof v !== "number") { | ||
return; | ||
} | ||
|
||
if (isNaN(v)) { | ||
throw new Error("Encountered NaN"); | ||
} | ||
if (isNaN(v)) { | ||
throw new Error("Encountered NaN"); | ||
} | ||
|
||
if (!isFinite(v)) { | ||
throw new Error("Encountered Infinity"); | ||
} | ||
}); | ||
if (!isFinite(v)) { | ||
throw new Error("Encountered Infinity"); | ||
} | ||
}, | ||
key: "tsonAssertNotInfinite", | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.