template-project/node_modules/exiftool-vendored/dist/StrEnum.d.ts
2025-05-30 18:13:30 +08:00

36 lines
1.5 KiB
TypeScript

import { Maybe, Nullable } from "./Maybe";
export type StrEnumType<T extends string> = {
[K in T]: K;
};
export type StrEnumHelpers<T extends string> = {
values: T[];
length: number;
/** synonym for includes */
has(s: Nullable<string>): s is T;
includes(s: Nullable<string>): s is T;
getCI(s: Nullable<string>): Maybe<T>;
pick<O extends T>(...t: O[]): Extract<T, O>[];
omit<O extends T>(...t: O[]): Exclude<T, O>[];
indexOf(s: Nullable<string>): Maybe<number>;
ordinal(s: Nullable<string>): number;
/** synonym for getCI */
toValid(s: Nullable<string>): Maybe<T>;
/** @return the first value in arr that getCI returns a non-null value for */
firstValid(...arr: Nullable<string>[]): Maybe<T>;
mapValid<R>(s: Nullable<string>, f: (t: T) => R): Maybe<R>;
cmp(a: Nullable<string>, b: Nullable<string>): Maybe<number>;
lt(a: T, b: T): boolean;
next(s: Nullable<string>): Maybe<T>;
/**
* @return a new StrEnum with the values in reverse order.
*
* (This follows the new "toReversed" ES2023 naming convention for methods that return a new object)
*/
toReversed(): StrEnum<T>;
};
export type StrEnum<T extends string> = StrEnumType<T> & StrEnumHelpers<T>;
export type StrEnumKeys<Type> = Type extends StrEnum<infer X> ? X : never;
export declare function strEnum<T extends string>(...o: T[]): StrEnum<T>;
export declare const Directions: StrEnum<"North" | "South" | "East" | "West">;
export type Direction = StrEnumKeys<typeof Directions>;