Skip to content

Commit

Permalink
lib: +char typeguard
Browse files Browse the repository at this point in the history
  • Loading branch information
jimmy-zhening-luo committed Jan 28, 2025
1 parent 7c92c63 commit 908f93c
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/lib/app/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,13 @@ export default abstract class App<
);
}

protected static char(string = "", cause = "") {
if (string.length !== 1)
throw new TypeError(`"${string}" is non-char (length: ${string.length})`, { cause });

return string as char;
}

private static error(app: stringful, error: unknown) {
function cast(e: unknown) {
return typeof e === "object" && e !== null && "message" in e
Expand Down

0 comments on commit 908f93c

Please sign in to comment.