/** * Collection of helper functions for working with string enums.\ * Example: * * ```typescript * enum MyStringEnum { * Key1: 'value1', * Key2: 'value2', * Key3: 'value3' * } * * // NOTE: It can't infer the type from the type param - types are not available * // at runtime in TypeScript. * const stringEnum = new StringEnum(MyStringEnum); * * const keys = stringEnum.keys; // keys === ['Key1', 'Key2', 'Key3'] * * const isKey = stringEnum.isKey('kEy3'); // isKey === true * const isValue = stringEnum.isValue('key3'); // isValue === false - text is a key; not a value * * const value1 = stringEnum.getValueForKey('key3'); // value === MyStringEnum.Key3 ('value3') * const value2 = stringEnum.convertToValue('VALUE2'); // value === MyStringEnum.Key2 ('value2') * * const key = stringEnum.convertToKey('key2'); // key === 'Key2' * stringEnum.convertToKey('key2', true); // throws error - case doesn't match * ``` * @typeParam TEnum The type of the enum. */ export declare class StringEnum { #private; /** * Initializes a new instance of the [[StringEnum]] class. * @param enumType The type of the enum. * @throws [[InvalidParameterError]] If enumType parameter is not a valid string 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 text is a value 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 value in the enum; false otherwise. * @throws [[InvalidParameterError]] If text is undefined or null. */ isValue(text: string, caseSensitive?: boolean): 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 text to an enum value. * @param text The text to convert to an enum value. * @param caseSensitive true if the comparison should be case sensitive. Defaults to false. * @returns text as an enum value. * @throws [[InvalidParameterError]] If text is not a value of the enum. */ convertToValue(text: string, caseSensitive?: boolean): 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 caseSensitive true if the comparison should be case sensitive. Defaults to false. * @param enumType The type of the enum. * @throws [[InvalidParameterError]] If value is not a value for enumType. */ getKeyForValue(value: string, caseSensitive?: boolean): string; /** * Returns a JSON representation of the current object instance. * @returns A JSON representation of the current object instance. */ toJSON(): unknown; }