diff --git a/src/utils/enum/descriptors/enum-descriptor.ts b/src/utils/enum/descriptors/enum-descriptor.ts new file mode 100644 index 0000000..7e60f69 --- /dev/null +++ b/src/utils/enum/descriptors/enum-descriptor.ts @@ -0,0 +1,48 @@ +import { NamedType, TypeOf, TypeOfResult } from "@/utils/types"; + +/** + * Interface that defines operations that should be implemented by an underlying type of an `Enum`. + * + * @template T - The underlying type that the enum is based on. + */ +export interface EnumDescriptor { + /** + * Gets the name of the underlying type. + */ + get name(): TypeOf; + + /** + * Gets the default value for the underlying type. + */ + get defaultValue(): T; + + /** + * Determines if a value has a specific flag. + * + * @param value - The value to check. + * @param flag - The flag to check for. + * + * @returns A boolean indicating whether the value has the specified flag. + */ + hasFlag(value: T, flag: T): boolean; + + /** + * Adds a flag to a value. + * + * @param value - The value to add the flag to. + * @param flag - The flag to add. + * + * @returns The updated value with the added flag. + */ + addFlag(value: T, flag: T): T; + + /** + * Removes a flag from a value. + * + * @param value - The value to remove the flag from. + * @param flag - The flag to remove. + * + * @returns The updated value with the removed flag. + */ + removeFlag(value: T, flag: T): T; +}