mirror of
https://github.com/Kir-Antipov/mc-publish.git
synced 2024-11-25 18:01:07 -05:00
Made base interface for enum descriptors
This commit is contained in:
parent
8db475ab28
commit
33da1eacff
1 changed files with 48 additions and 0 deletions
48
src/utils/enum/descriptors/enum-descriptor.ts
Normal file
48
src/utils/enum/descriptors/enum-descriptor.ts
Normal file
|
@ -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<T> {
|
||||||
|
/**
|
||||||
|
* Gets the name of the underlying type.
|
||||||
|
*/
|
||||||
|
get name(): TypeOf<T>;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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;
|
||||||
|
}
|
Loading…
Reference in a new issue