fix(utils): share clamp helpers
Co-authored-by: Gustavo Madeira Santana <gumadeiras@gmail.com>
This commit is contained in:
committed by
Peter Steinberger
parent
810394f43b
commit
7252938339
@@ -8,6 +8,14 @@ export async function ensureDir(dir: string) {
|
||||
await fs.promises.mkdir(dir, { recursive: true });
|
||||
}
|
||||
|
||||
export function clampNumber(value: number, min: number, max: number): number {
|
||||
return Math.max(min, Math.min(max, value));
|
||||
}
|
||||
|
||||
export function clampInt(value: number, min: number, max: number): number {
|
||||
return clampNumber(Math.floor(value), min, max);
|
||||
}
|
||||
|
||||
export type WebChannel = "web";
|
||||
|
||||
export function assertWebChannel(input: string): asserts input is WebChannel {
|
||||
|
||||
Reference in New Issue
Block a user