gnablib
Version:
A lean, zero dependency library to provide a useful base for your project.
36 lines (35 loc) • 944 B
TypeScript
/*! Copyright 2024 the gnablib contributors MPL-1.1 */
export interface ISafeNum {
get value(): number;
throwNot(): void | ISafeNum;
cast(): number | never;
is(): this is ISafeNum;
coerce(): ISafeNum;
atMost(lte: number): ISafeNum;
lt(lt: number): ISafeNum;
atLeast(gte: number): ISafeNum;
gt(gt: number): ISafeNum;
unsigned(): ISafeNum;
natural(): ISafeNum;
}
export interface ISafeStr {
get value(): string;
throwNot(): void | ISafeStr;
cast(): string | never;
is(): this is ISafeStr;
coerce(): ISafeStr;
}
export interface ISafeBool {
get value(): boolean;
throwNot(): void | ISafeBool;
cast(): boolean | never;
is(): this is ISafeBool;
coerce(): ISafeBool;
}
export interface ISafeLen {
throwNot(): void | ISafeLen;
is(): this is ISafeLen;
exactly(eq: number): ISafeLen;
atMost(lte: number): ISafeLen;
atLeast(gte: number): ISafeLen;
}