/** * Collection of helper functions for working with number enums. * * Example: * * ```typescript * enum MyNumberEnum { * Key1, * Key2, * Key3 * } * * // NOTE: It can't infer the type from the type param - types are not available * // at runtime in TypeScript. * const numberEnum = new NumberEnum(MyNumberEnum); * * const keys = numberEnum.keys; // keys === ['Key1', 'Key2', 'Key3'] * * const isKey = numberEnum.isKey('kEy3'); // isKey === true * const isValue = numberEnum.isValue('key3'); // isValue === false - text is a key; not a value * * const value1 = numberEnum.getValueForKey('key3'); // value === MyNumberEnum.Key3 (2) * const value2 = numberEnum.convertToValue(1); // value === MyNumberEnum.Key2 (1) * * const key = numberEnum.convertToKey('key2'); // key === 'Key2' * numberEnum.convertToKey('key2', true); // throws error - case doesn't match * ``` * @typeParam TEnum The type of the enum. */ export declare class NumberEnum { #private; /** * Initializes a new instance of the [[NumberEnum]] class. * @param enumType The type of the enum. * @throws [[InvalidParameterError]] If enumType parameter is not a valid number enum. */ constructor(enumType: Record); /** * The enum type. */ get type(): Record; /** * The keys of the enum. */ get keys(): string[]; /** * The values of the enum. */ get values(): TEnum[]; /** * Returns whether the specified text is a key in the enum (case insensitive). * @param text The text to be checked. * @param caseSensitive true if the comparison should be case sensitive. Defaults to false. * @returns true if text is a key in the enum; false otherwise. * @throws [[InvalidParameterError]] If text is undefined or null. */ isKey(text: string, caseSensitive?: boolean): boolean; /** * Returns whether the specified number is a value in the enum. * @param number The number to be checked. * @returns true if number is a value in the enum; false otherwise. * @throws [[InvalidParameterError]] If text is undefined or null. */ isValue(number: number): boolean; /** * Converts the specified text to an enum key. * @param text The text to convert to an enum key. * @param caseSensitive true if the comparison should be case sensitive. Defaults to false. * @returns text as an enum key. * @throws [[InvalidParameterError]] If text is not a key of the enum. */ convertToKey(text: string, caseSensitive?: boolean): string; /** * Converts the specified number to an enum value. * @param number The number to convert to an enum value. * @returns number as an enum value. * @throws [[InvalidParameterError]] If number is not a value of the enum. */ convertToValue(number: number): TEnum; /** * Gets the value for the specified key. * @param key The key of the enum value. * @param caseSensitive true if the comparison should be case sensitive. Defaults to false. * @returns The appropriate enum value. * @throws [[InvalidParameterError]] If key is not present in enumType. */ getValueForKey(key: string, caseSensitive?: boolean): TEnum; /** * Gets the key for the specified enum value. * @param value The value to get the key for. * @param enumType The type of the enum. * @throws [[InvalidParameterError]] If value is not a value for enumType. */ getKeyForValue(value: number): string; /** * Returns a JSON representation of the current object instance. * @returns A JSON representation of the current object instance. */ toJSON(): unknown; }