@snap/camera-kit
Version:
Camera Kit Web
38 lines • 1.55 kB
TypeScript
/**
* For instances where we'd like to define a Tuple to be of certain type and length.
* Example: TupleOf<number, 3> // [number, number, number]
*
* For more example and use cases regarding Recursive conditional types
* see: https://github.com/microsoft/TypeScript/pull/40002
*
* @internal
*/
type _TupleOf<T, N extends number, R extends unknown[]> = R["length"] extends N ? R : _TupleOf<T, N, [T, ...R]>;
export type TupleOf<T, N extends number> = N extends N ? (number extends N ? T[] : _TupleOf<T, N, []>) : never;
/**
* Converts snake_case string literal types to camelCase.
*
* @internal
*/
export type SnakeToCamelCase<S extends string> = S extends `${infer T}_${infer U}` ? `${T}${Capitalize<SnakeToCamelCase<U>>}` : S;
/**
* Converts camelCase string literal types to snake_case.
*
* @internal
*/
export type CamelToSnakeCase<S extends string> = S extends `${infer T}${infer U}` ? `${T extends Capitalize<T> ? "_" : ""}${Lowercase<T>}${CamelToSnakeCase<U>}` : S;
/**
* Maps an enum (usually defined in proto) to a record with publicly facing keys as camelCase string literals.
* The keys of the resulting record are the camelCased versions of the original enum keys,
* and the values are the corresponding enum values.
*
* @template T - The enum type to be transformed.
*
* @internal
*/
export type EnumToPublicStringLiteralMap<T> = {
[K in keyof T as SnakeToCamelCase<Lowercase<K & string>>]: T[K];
};
export type ExcludeKeys<T, K extends keyof T> = Omit<T, K>;
export {};
//# sourceMappingURL=types.d.ts.map