image library changes, bit flags changes

This commit is contained in:
2025-09-16 18:01:55 -04:00
parent 5934f1a91c
commit c4f32b1940
16 changed files with 119 additions and 284 deletions

View File

@@ -10,37 +10,42 @@
export class BitFlags<T extends number> {
private value: T;
constructor(initialValue: T | number = 0 as T) {
this.value = initialValue as T;
constructor(...initialValue: (T | number)[]) {
if (Array.isArray(initialValue)) {
// Combine multiple flags into one numeric value
this.value = initialValue.reduce((acc, flag) => acc | flag, 0) as T;
} else {
this.value = initialValue as T;
}
}
/** Get current numeric value */
public getValue(): T {
public getValue() {
return this.value;
}
/** Check if a specific flag is set */
public has(flag: T): boolean {
public has(flag: T) {
return (this.value & flag) === flag;
}
/** Add a flag */
public add(flag: T): void {
public add(flag: T) {
this.value = (this.value | flag) as T;
}
/** Remove a flag */
public remove(flag: T): void {
public remove(flag: T) {
this.value = (this.value & ~flag) as T;
}
/** Toggle a flag */
public toggle(flag: T): void {
public toggle(flag: T) {
this.value = (this.value ^ flag) as T;
}
/** Reset all flags */
public clear(): void {
public clear() {
this.value = 0 as T;
}
}

View File

@@ -4,6 +4,9 @@ import { z } from "zod";
import type { HonoEnv } from "./types.ts";
import { ZodSchema } from "zod/v4";
import { HTTPStatus } from "@oneday/http-status";
import Logging from "@proxnet/undead-logging";
const log = new Logging("Validation");
// thanks claude, this hurt my brain!
@@ -17,7 +20,10 @@ export const typedZValidator = <
recNetError?: string
) => {
return zValidator(target, schema, (result, c) => {
if (!result.success) {
log.w(`Validation failed: ${JSON.stringify(result.error)}`);
if (recNetError) return c.json({ success: false, error: recNetError }, httpOk == true ? HTTPStatus.OK : HTTPStatus.BadRequest);
else return c.json({ success: false, error: "Request validation failed" }, httpOk == true ? HTTPStatus.OK : HTTPStatus.BadRequest);
}